def notify_mailme(self, arguments={}): cls = self.__class__ appier.ensure_pip("mailme", package="mailme_api") import mailme retries = arguments.get("retries", 3) logger = appier.get_logger() logger.debug("Running Mailme notification ...") api = mailme.API() return cls._retry(lambda: api.send(arguments), count=retries)
def load(self): appier.Part.load(self) self._api = None self.owner.bind("exception", self.exception) if self.log: appier.ensure_pip("opbeat", package="opbeat_api", delayed=True)
def notify_mailme(self, arguments = {}): cls = self.__class__ appier.ensure_pip("mailme", package = "mailme_api") import mailme retries = arguments.get("retries", 3) logger = appier.get_logger() logger.debug("Running Mailme notification ...") api = mailme.API() return cls._retry(lambda: api.send(arguments), count = retries)
def load(self): appier.Part.load(self) self._api = None self.owner.bind("exception", self.exception) log = appier.conf("OPBEAT_LOG", False, cast = bool) if log: appier.ensure_pip("opbeat", package = "opbeat_api")
def load(self): appier.Part.load(self) self._api = None self.owner.bind("exception", self.exception) if self.log: appier.ensure_pip( "opbeat", package = "opbeat_api", delayed = True )
def notify_nexmo(self, arguments = {}): cls = self.__class__ appier.ensure_pip("nexmo", package = "nexmo_api") import nexmo sender = arguments["sender"] receiver = arguments["receiver"] text = arguments["text"] retries = arguments.get("retries", 3) logger = appier.get_logger() logger.debug("Running Nexmo notification for '%s' ..." % receiver) api = nexmo.API() return cls._retry(lambda: api.send_sms(sender, receiver, text), count = retries)
def notify_nexmo(self, arguments={}): cls = self.__class__ appier.ensure_pip("nexmo", package="nexmo_api") import nexmo sender = arguments["sender"] receiver = arguments["receiver"] text = arguments["text"] retries = arguments.get("retries", 3) logger = appier.get_logger() logger.debug("Running Nexmo notification for '%s' ..." % receiver) api = nexmo.API() return cls._retry(lambda: api.send_sms(sender, receiver, text), count=retries)
def _get_kafka(cls): if hasattr(cls, "_kafka"): return cls._kafka appier.ensure_pip("kafka", package="kafka-python") import kafka kafka_server = appier.conf("KAFKA_SERVER", "localhost:9092") client_id = appier.conf("KAFKA_PRODUCER_CLIENT_ID", None) compression_type = appier.conf("KAFKA_COMPRESSION_TYPE", None) retries = appier.conf("KAFKA_RETRIES", 0, cast=int) batch_size = appier.conf("KAFKA_BATCH_SIZE", 16384, cast=int) linger_ms = appier.conf("KAFKA_LINGER", 0, cast=int) connections_max_idle_ms = appier.conf("KAFKA_CONNECTIONS_MAX_IDLE", 540000, cast=int) max_request_size = appier.conf("KAFKA_MAX_REQUEST_SIZE", 1048576, cast=int) retry_backoff_ms = appier.conf("KAFKA_RETRY_BACKOFF", 100, cast=int) request_timeout_ms = appier.conf("KAFKA_REQUEST_TIMEOUT", 30000, cast=int) cls._kafka = kafka.KafkaProducer( bootstrap_servers=kafka_server, client_id=client_id, compression_type=compression_type, retries=retries, batch_size=batch_size, linger_ms=linger_ms, connections_max_idle_ms=connections_max_idle_ms, max_request_size=max_request_size, retry_backoff_ms=retry_backoff_ms, request_timeout_ms=request_timeout_ms) return cls._kafka
def ensure_live(self): appier.ensure_pip("live", package = "live_api")
def ensure_github(self): appier.ensure_pip("github", package = "github_api_python")
def ensure_facebook(self): appier.ensure_pip("facebook", package = "facebook_api")
def ensure_google(self): appier.ensure_pip("google", package="google_api")
def ensure_facebook(self): appier.ensure_pip("facebook", package="facebook_api")
def ensure_live(self): appier.ensure_pip("live", package="live_api")
def ensure_twitter(self): appier.ensure_pip("twitter", package = "twitter_api")
def ensure_google(self): appier.ensure_pip("google", package = "google_api")