Merge pull request #18895 from home-assistant/upgrade-slacker

Upgrade slacker to 0.11.0
pull/18892/head^2
Daniel Høyer Iversen 2018-12-02 08:45:02 +01:00 committed by GitHub
commit 253dc66129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -17,7 +17,7 @@ from homeassistant.components.notify import (
BaseNotificationService) BaseNotificationService)
from homeassistant.const import (CONF_API_KEY, CONF_USERNAME, CONF_ICON) from homeassistant.const import (CONF_API_KEY, CONF_USERNAME, CONF_ICON)
REQUIREMENTS = ['slacker==0.9.65'] REQUIREMENTS = ['slacker==0.11.0']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -39,14 +39,15 @@ ATTR_FILE_AUTH_DIGEST = 'digest'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string, vol.Required(CONF_API_KEY): cv.string,
vol.Required(CONF_CHANNEL): cv.string, vol.Required(CONF_CHANNEL): cv.string,
vol.Optional(CONF_USERNAME): cv.string,
vol.Optional(CONF_ICON): cv.string, vol.Optional(CONF_ICON): cv.string,
vol.Optional(CONF_USERNAME): cv.string,
}) })
def get_service(hass, config, discovery_info=None): def get_service(hass, config, discovery_info=None):
"""Get the Slack notification service.""" """Get the Slack notification service."""
import slacker import slacker
channel = config.get(CONF_CHANNEL) channel = config.get(CONF_CHANNEL)
api_key = config.get(CONF_API_KEY) api_key = config.get(CONF_API_KEY)
username = config.get(CONF_USERNAME) username = config.get(CONF_USERNAME)
@ -115,15 +116,15 @@ class SlackNotificationService(BaseNotificationService):
'content': None, 'content': None,
'filetype': None, 'filetype': None,
'filename': filename, 'filename': filename,
# if optional title is none use the filename # If optional title is none use the filename
'title': title if title else filename, 'title': title if title else filename,
'initial_comment': message, 'initial_comment': message,
'channels': target 'channels': target
} }
# Post to slack # Post to slack
self.slack.files.post('files.upload', self.slack.files.post(
data=data, 'files.upload', data=data,
files={'file': file_as_bytes}) files={'file': file_as_bytes})
else: else:
self.slack.chat.post_message( self.slack.chat.post_message(
target, message, as_user=self._as_user, target, message, as_user=self._as_user,
@ -154,13 +155,13 @@ class SlackNotificationService(BaseNotificationService):
elif local_path: elif local_path:
# Check whether path is whitelisted in configuration.yaml # Check whether path is whitelisted in configuration.yaml
if self.is_allowed_path(local_path): if self.is_allowed_path(local_path):
return open(local_path, "rb") return open(local_path, 'rb')
_LOGGER.warning("'%s' is not secure to load data from!", _LOGGER.warning(
local_path) "'%s' is not secure to load data from!", local_path)
else: else:
_LOGGER.warning("Neither URL nor local path found in params!") _LOGGER.warning("Neither URL nor local path found in params!")
except OSError as error: except OSError as error:
_LOGGER.error("Can't load from url or local path: %s", error) _LOGGER.error("Can't load from URL or local path: %s", error)
return None return None

View File

@ -1427,7 +1427,7 @@ sisyphus-control==2.1
skybellpy==0.1.2 skybellpy==0.1.2
# homeassistant.components.notify.slack # homeassistant.components.notify.slack
slacker==0.9.65 slacker==0.11.0
# homeassistant.components.sleepiq # homeassistant.components.sleepiq
sleepyq==0.6 sleepyq==0.6