def metrics(self, metrics): for name, results in metrics.items(): for key,value in results['results'].items(): logger.info('Pushing %s-%s => %s' % (name, key, repr(value))) v, u = value try: self.api.update_status('%s-%s => %s %s' % (name, key, repr(v), u)) except tweepy.error.TweepError as e: logger.error(repr(e.reason))
def metrics(self, metrics): for name, results in metrics.items(): for key, value in results['results'].items(): logger.info('Pushing %s-%s => %s' % (name, key, repr(value))) v, u = value try: self.api.update_status('%s-%s => %s %s' % (name, key, repr(v), u)) except tweepy.error.TweepError as e: logger.error(repr(e.reason))
def message(self, msg): try: if msg['type'] == 'chat': self.chat(msg) elif msg['type'] == 'error': self.error(msg) else: logger.error('Unknown message type: %s' % self.msgToString(msg)) except: logger.exception('Failed to parse message')
def metrics(self, metrics): d = {} for name, results in metrics.items(): for key,value in results['results'].items(): d[name + '-' + key] = value try: response, content = httplib2.Request(self.url, method=self.method, body=json.dumps(d)) if response != 200: logger.error('%s responded with (%i) %s' % (self.url, response, content)) except httplib2.HttpLib2Error as e: logger.error(repr(e))
def metrics(self, metrics): d = {} for name, results in metrics.items(): for key, value in results['results'].items(): d[name + '-' + key] = value try: response, content = httplib2.Request(self.url, method=self.method, body=json.dumps(d)) if response != 200: logger.error('%s responded with (%i) %s' % (self.url, response, content)) except httplib2.HttpLib2Error as e: logger.error(repr(e))
def err(msg): logger.error(repr(msg))
def error(self, msg): logger.error('Received error %s' % self.msgToString(msg))