本文整理汇总了Python中event.Event.description方法的典型用法代码示例。如果您正苦于以下问题:Python Event.description方法的具体用法?Python Event.description怎么用?Python Event.description使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类event.Event
的用法示例。
在下文中一共展示了Event.description方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: join
# 需要导入模块: from event import Event [as 别名]
# 或者: from event.Event import description [as 别名]
def join(self):
try:
stdout, stderr, returncode = SubProcessTask.join(self)
event = Event()
event.service = self.name
event.ttl = self.ttl * self.ttl_multiplier
event.host = self.host
event.tags = self.tags
event.attributes = self.attributes
output, attributes = self.parse_nagios_output(stdout)
event.description = "Note: %s\nCommand: %s\nOutput: %s\n" % (self.note, self.raw_command, output)
if returncode in self.exitcodes:
event.state = self.exitcodes[returncode]
else:
event.state = 'unknown'
if attributes:
if 'metric' in self.config and self.config['metric'] in attributes:
metric_key = self.config['metric']
else:
metric_key = attributes.keys()[0]
event.attributes.update(attributes)
event.metric = float(NUMERIC_REGEX.match(attributes[metric_key]).group(1))
self.events.append(event)
except Exception as e:
log.error("Exception joining task '%s':\n%s" % (self.name, str(e)))
示例2: join
# 需要导入模块: from event import Event [as 别名]
# 或者: from event.Event import description [as 别名]
def join(self):
try:
json_result = self.q.get(timeout=(self.ttl * 0.3))
self.proc.join()
log.debug('CloudKickTask: Processing %s metrics' % (len(json_result['metrics'])))
for metric in json_result['metrics']:
note = metric['note'] if 'note' in metric else self.note
event = Event()
event.ttl = self.ttl * self.ttl_multiplier
event.host = self.host
event.tags = self.tags
event.service = metric['name']
event.state = metric['state']
event.metric = metric['value']
event.description = "%s\nWarn threshold: %s, Error threshold: %s" % (note,
metric['warn_threshold'],
metric['error_threshold'])
if 'attributes' in metric:
event.attributes = metric['attributes']
self.events.append(event)
except Exception as e:
log.error("Exception joining CloudKickTask '%s'\n%s" % (self.name, traceback.format_exc()))
self.locked = False
示例3: getBestEvent
# 需要导入模块: from event import Event [as 别名]
# 或者: from event.Event import description [as 别名]
def getBestEvent(self, filename='events.json'):
"""Returns the event most relevant to this user's interests."""
if filename not in [f for f in os.listdir('.') if os.path.isfile(f)]:
raise IOError('Error: events file ' + filename + ' not found.')
data = json.load(open(filename))
best_event = Event()
best_score = 0
for event in data['events']:
iter_event = Event()
# The declarations are split to keep the Item __init__ method for automatically calling the API to populate the model.
iter_event.description = event['description']
iter_event.name = event['name']
iter_event.model = ConceptModel(model=event['model']['concepts'], maturity=1)
iter_event.starttime = event['starttime']
iter_event.endtime = event['endtime']
iter_event.location = event['location']
iter_event.picture = event['picture']
iter_event.name = event['name']
iter_event.url = event['url']
score = best_event.compareTo(iter_event)
if score >= best_score:
# print(self.exceptions)
if iter_event.name not in self.exceptions:
best_event = iter_event
best_score = score
return best_event
示例4: GetSingleEvent
# 需要导入模块: from event import Event [as 别名]
# 或者: from event.Event import description [as 别名]
def GetSingleEvent(self, eventLandingPage):
eventLandingPage = self.urlify(eventLandingPage)
self.page = requests.get(eventLandingPage)
eventTree = html.fromstring(self.page.text)
new_event = Event()
new_event.source = eventLandingPage.encode('utf-8')
new_event.name = self.multipleXPaths(self.eventName_xpath, eventTree, 'name')
new_event.location += self.multipleXPaths(self.eventLocation_xpath, eventTree, 'location')
new_event.description = self.multipleXPaths(self.eventDescription_xpath, eventTree, 'description')
new_event.datetime = self.multipleXPaths(self.eventDateTime_xpath, eventTree, 'datetime')
new_event.price = self.multipleXPaths(self.eventPrice_xpath, eventTree, 'price')
new_event.imagePath = self.multipleXPaths(self.eventImage_xpath, eventTree, 'imagePath')
new_event.imagePath = self.urlify(new_event.imagePath)
new_event.dump = SiteText(eventLandingPage).gettext()
new_event.cleanContent()
# print (new_event)
# print (new_event.name), " name"
# print (new_event.location), " location"
# print (new_event.description), " description"
# print (new_event.datetime), " datetime"
# print (new_event.price), " price"
# print (new_event.imagePath), " imagePath"
return new_event
示例5: join
# 需要导入模块: from event import Event [as 别名]
# 或者: from event.Event import description [as 别名]
def join(self):
try:
stdout, stderr, returncode = SubProcessTask.join(self)
try:
results = json.loads(stdout)
except Exception as e:
log.error("Failed to parse JSON. '%s':\n%s" % (self.name, str(e)))
return
for result in results:
for field in ['service', 'state', 'description', 'metric']:
if field not in result:
log.error("Event missing field '%s'" % (field))
continue
event = Event()
event.ttl = self.ttl * self.ttl_multiplier
event.attributes = dict(self.attributes)
if 'host' in result and result['host'] is not None:
event.host = result['host']
else:
event.host = self.host
if 'tags' in result and result['tags'] is not None:
event.tags = self.tags.union(result['tags'])
else:
event.tags = self.tags
if "attributes" in result:
attributes = result["attributes"]
event.attributes.update(dict((self.clean_attribute_name(key), attributes[key]) for key in attributes))
event.service = result['service']
event.state = result['state']
event.metric = result['metric']
event.description = "%s\n%s" % (self.note, result['description'])
self.events.append(event)
except Exception as e:
log.exception("Exception joining task '%s':\n%s" % (self.name, str(e)))
示例6: parseOneJson
# 需要导入模块: from event import Event [as 别名]
# 或者: from event.Event import description [as 别名]
def parseOneJson(self, obj):
count = 0;
if ((obj[self.eventResults] is not None) and (len(obj[self.eventResults])>0)):
for result in obj[self.eventResults]:
count += 1
sys.stdout.write("\rGetting " + str(count) + " of " + str(len(obj[self.eventResults])))
sys.stdout.flush()
event = Event()
event.name = self.checkIfList(self.eventName, result)
event.location = self.checkIfList(self.location, result)
event.description = self.checkIfList(self.description, result)
event.datetime = self.checkIfList(self.eventTime, result)
event.price = self.checkIfList(self.price, result)
event.imagePath = self.checkIfList(self.image, result)
event.dump = self.checkIfList(self.description, result)
event.forceStr()
self.allEvents.append(event)
print "\n"
return True
else:
return False