Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Вот пируль:
- # -*- coding: utf-8 -*-
- ##----------------------------------------------------------------------
- ## отправить список коммутаторов, готовых к перезагрузке
- ##----------------------------------------------------------------------
- ## INTERFACE: IPeriodicTask
- ##----------------------------------------------------------------------
- ## DESCRIPTION:
- ## add managed object
- ##----------------------------------------------------------------------
- ## Copyright (C) 2007-2014 The NOC Project
- ## See LICENSE for details
- ##----------------------------------------------------------------------
- from noc.main.models.notificationgroup import *
- from noc.sa.models import *
- import string
- @pyrule
- def mail_test(timeout = None):
- TAG="boot"
- string_mo="=== reboot list"
- i=1
- mo = ManagedObject.objects.filter()
- for m in mo:
- if m.tags.count(TAG)!=0:
- string_mo = string_mo + "\n" + string.rjust(str(i),3) + ". " + string.ljust(m.name,15) + string.ljust(m.get_attr("platform","default"),15) + string.strip(m.street) + ", " + m.home
- i+=1
- string_mo = string_mo + "\n==="
- if i>1:
- subj="reboot list"
- body=string_mo
- NotificationGroup.objects.get(name="report").notify(subject = subj, body = body)
- return True
- ==============================
- А вот трэйс:
- 2014-05-26 08:00:14,489 UNHANDLED EXCEPTION (2014-05-26 08:00:14.486925)
- Working directory: /opt/noc
- <type 'exceptions.UnicodeEncodeError'>
- 'ascii' codec can't encode characters in position 100-108: ordinal not in range(128)
- START OF TRACEBACK
- ------------------------------------------------------------------------
- File: /opt/noc/main/models/__init__.py (Line: 396)
- Function: __call__
- 389 with self.compiled_lock:
- 390 requires_recompile = (self.name not in self.compiled_changed or
- 391 self.compiled_changed[self.name] < self.changed)
- 392 if not requires_recompile:
- 393 f = self.compiled_pyrules[self.name]
- 394 # Recompile rule and place in cache when necessary
- 395 if requires_recompile:
- 396 ==> f = self.compile_text(str(self.text))
- 397 with self.compiled_lock:
- 398 self.compiled_pyrules[self.name] = f
- 399 self.compiled_changed[self.name] = t
- 400 # Check interface
- 401 i = self.interface_class()
- 402 kwargs = i.clean(**kwargs)
- Variables:
- requires_recompile = True
- self = <PyRule: mail_test>
- t = datetime.datetime(2014, 5, 26, 8, 0, 14, 486841)
- kwargs = {'timeout': None}
- ------------------------------------------------------------------------
- File: /opt/noc/main/models/__init__.py (Line: 413)
- Function: call
- 406 return i.clean_result(result)
- 407
- 408 @classmethod
- 409 def call(cls, py_rule_name, **kwargs):
- 410 """
- 411 Call pyRule by name
- 412 """
- 413 ==> return cls.lookup(py_rule_name)(**kwargs)
- 414
- 415 ##
- 416 ## Search patters
- 417 ##
- 418 rx_mac_3_octets = re.compile("^([0-9A-F]{6}|[0-9A-F]{12})$", re.IGNORECASE)
- 419
- Variables:
- py_rule_name = u'mail_test'
- cls = <class 'noc.main.models.PyRule'>
- kwargs = {'timeout': None}
- ------------------------------------------------------------------------
- File: /opt/noc/main/scheduler/periodic.py (Line: 72)
- Function: task_wrapper
- 65 """Periodic thread target"""
- 66 logging.info(u"Periodic task=%s status=running" % unicode(task))
- 67 t = datetime.datetime.now()
- 68 cwd = os.getcwd()
- 69 try:
- 70 if task.periodic_name.startswith("pyrule:"):
- 71 status = PyRule.call(task.periodic_name[7:],
- 72 ==> timeout=task.timeout)
- 73 else:
- 74 status = task.periodic(task.timeout).execute()
- 75 except:
- 76 error_report()
- 77 status = False
- 78 logging.info(u"Periodic task=%s status=%s" % (unicode(task),
- Variables:
- self = <PeriodicScheduler(Thread-1, started daemon 139830202849024)>
- task = <Schedule: pyrule:mail_test:Any>
- cwd = '/opt/noc'
- t = datetime.datetime(2014, 5, 26, 8, 0, 14, 420948)
- ------------------------------------------------------------------------
- END OF TRACEBACK
- 2014-05-26 08:00:14,489 Periodic task=pyrule:mail_test:Any status=failed
- 2014-05-26 08:00:14,928 [main.jobs] Invalid job class: None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement