event.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. """
  2. BitBake 'Event' implementation
  3. Classes and functions for manipulating 'events' in the
  4. BitBake build tools.
  5. """
  6. # Copyright (C) 2003, 2004 Chris Larson
  7. #
  8. # SPDX-License-Identifier: GPL-2.0-only
  9. #
  10. import sys
  11. import pickle
  12. import logging
  13. import atexit
  14. import traceback
  15. import ast
  16. import threading
  17. import bb.utils
  18. import bb.compat
  19. import bb.exceptions
  20. # This is the pid for which we should generate the event. This is set when
  21. # the runqueue forks off.
  22. worker_pid = 0
  23. worker_fire = None
  24. logger = logging.getLogger('BitBake.Event')
  25. class Event(object):
  26. """Base class for events"""
  27. def __init__(self):
  28. self.pid = worker_pid
  29. class HeartbeatEvent(Event):
  30. """Triggered at regular time intervals of 10 seconds. Other events can fire much more often
  31. (runQueueTaskStarted when there are many short tasks) or not at all for long periods
  32. of time (again runQueueTaskStarted, when there is just one long-running task), so this
  33. event is more suitable for doing some task-independent work occassionally."""
  34. def __init__(self, time):
  35. Event.__init__(self)
  36. self.time = time
  37. Registered = 10
  38. AlreadyRegistered = 14
  39. def get_class_handlers():
  40. return _handlers
  41. def set_class_handlers(h):
  42. global _handlers
  43. _handlers = h
  44. def clean_class_handlers():
  45. return bb.compat.OrderedDict()
  46. # Internal
  47. _handlers = clean_class_handlers()
  48. _ui_handlers = {}
  49. _ui_logfilters = {}
  50. _ui_handler_seq = 0
  51. _event_handler_map = {}
  52. _catchall_handlers = {}
  53. _eventfilter = None
  54. _uiready = False
  55. _thread_lock = threading.Lock()
  56. _thread_lock_enabled = False
  57. if hasattr(__builtins__, '__setitem__'):
  58. builtins = __builtins__
  59. else:
  60. builtins = __builtins__.__dict__
  61. def enable_threadlock():
  62. global _thread_lock_enabled
  63. _thread_lock_enabled = True
  64. def disable_threadlock():
  65. global _thread_lock_enabled
  66. _thread_lock_enabled = False
  67. def execute_handler(name, handler, event, d):
  68. event.data = d
  69. addedd = False
  70. if 'd' not in builtins:
  71. builtins['d'] = d
  72. addedd = True
  73. try:
  74. ret = handler(event)
  75. except (bb.parse.SkipRecipe, bb.BBHandledException):
  76. raise
  77. except Exception:
  78. etype, value, tb = sys.exc_info()
  79. logger.error("Execution of event handler '%s' failed" % name,
  80. exc_info=(etype, value, tb.tb_next))
  81. raise
  82. except SystemExit as exc:
  83. if exc.code != 0:
  84. logger.error("Execution of event handler '%s' failed" % name)
  85. raise
  86. finally:
  87. del event.data
  88. if addedd:
  89. del builtins['d']
  90. def fire_class_handlers(event, d):
  91. if isinstance(event, logging.LogRecord):
  92. return
  93. eid = str(event.__class__)[8:-2]
  94. evt_hmap = _event_handler_map.get(eid, {})
  95. for name, handler in list(_handlers.items()):
  96. if name in _catchall_handlers or name in evt_hmap:
  97. if _eventfilter:
  98. if not _eventfilter(name, handler, event, d):
  99. continue
  100. execute_handler(name, handler, event, d)
  101. ui_queue = []
  102. @atexit.register
  103. def print_ui_queue():
  104. global ui_queue
  105. """If we're exiting before a UI has been spawned, display any queued
  106. LogRecords to the console."""
  107. logger = logging.getLogger("BitBake")
  108. if not _uiready:
  109. from bb.msg import BBLogFormatter
  110. # Flush any existing buffered content
  111. sys.stdout.flush()
  112. sys.stderr.flush()
  113. stdout = logging.StreamHandler(sys.stdout)
  114. stderr = logging.StreamHandler(sys.stderr)
  115. formatter = BBLogFormatter("%(levelname)s: %(message)s")
  116. stdout.setFormatter(formatter)
  117. stderr.setFormatter(formatter)
  118. # First check to see if we have any proper messages
  119. msgprint = False
  120. msgerrs = False
  121. # Should we print to stderr?
  122. for event in ui_queue[:]:
  123. if isinstance(event, logging.LogRecord) and event.levelno >= logging.WARNING:
  124. msgerrs = True
  125. break
  126. if msgerrs:
  127. logger.addHandler(stderr)
  128. else:
  129. logger.addHandler(stdout)
  130. for event in ui_queue[:]:
  131. if isinstance(event, logging.LogRecord):
  132. if event.levelno > logging.DEBUG:
  133. logger.handle(event)
  134. msgprint = True
  135. # Nope, so just print all of the messages we have (including debug messages)
  136. if not msgprint:
  137. for event in ui_queue[:]:
  138. if isinstance(event, logging.LogRecord):
  139. logger.handle(event)
  140. if msgerrs:
  141. logger.removeHandler(stderr)
  142. else:
  143. logger.removeHandler(stdout)
  144. ui_queue = []
  145. def fire_ui_handlers(event, d):
  146. global _thread_lock
  147. global _thread_lock_enabled
  148. if not _uiready:
  149. # No UI handlers registered yet, queue up the messages
  150. ui_queue.append(event)
  151. return
  152. if _thread_lock_enabled:
  153. _thread_lock.acquire()
  154. errors = []
  155. for h in _ui_handlers:
  156. #print "Sending event %s" % event
  157. try:
  158. if not _ui_logfilters[h].filter(event):
  159. continue
  160. # We use pickle here since it better handles object instances
  161. # which xmlrpc's marshaller does not. Events *must* be serializable
  162. # by pickle.
  163. if hasattr(_ui_handlers[h].event, "sendpickle"):
  164. _ui_handlers[h].event.sendpickle((pickle.dumps(event)))
  165. else:
  166. _ui_handlers[h].event.send(event)
  167. except:
  168. errors.append(h)
  169. for h in errors:
  170. del _ui_handlers[h]
  171. if _thread_lock_enabled:
  172. _thread_lock.release()
  173. def fire(event, d):
  174. """Fire off an Event"""
  175. # We can fire class handlers in the worker process context and this is
  176. # desired so they get the task based datastore.
  177. # UI handlers need to be fired in the server context so we defer this. They
  178. # don't have a datastore so the datastore context isn't a problem.
  179. fire_class_handlers(event, d)
  180. if worker_fire:
  181. worker_fire(event, d)
  182. else:
  183. # If messages have been queued up, clear the queue
  184. global _uiready, ui_queue
  185. if _uiready and ui_queue:
  186. for queue_event in ui_queue:
  187. fire_ui_handlers(queue_event, d)
  188. ui_queue = []
  189. fire_ui_handlers(event, d)
  190. def fire_from_worker(event, d):
  191. fire_ui_handlers(event, d)
  192. noop = lambda _: None
  193. def register(name, handler, mask=None, filename=None, lineno=None):
  194. """Register an Event handler"""
  195. # already registered
  196. if name in _handlers:
  197. return AlreadyRegistered
  198. if handler is not None:
  199. # handle string containing python code
  200. if isinstance(handler, str):
  201. tmp = "def %s(e):\n%s" % (name, handler)
  202. try:
  203. code = bb.methodpool.compile_cache(tmp)
  204. if not code:
  205. if filename is None:
  206. filename = "%s(e)" % name
  207. code = compile(tmp, filename, "exec", ast.PyCF_ONLY_AST)
  208. if lineno is not None:
  209. ast.increment_lineno(code, lineno-1)
  210. code = compile(code, filename, "exec")
  211. bb.methodpool.compile_cache_add(tmp, code)
  212. except SyntaxError:
  213. logger.error("Unable to register event handler '%s':\n%s", name,
  214. ''.join(traceback.format_exc(limit=0)))
  215. _handlers[name] = noop
  216. return
  217. env = {}
  218. bb.utils.better_exec(code, env)
  219. func = bb.utils.better_eval(name, env)
  220. _handlers[name] = func
  221. else:
  222. _handlers[name] = handler
  223. if not mask or '*' in mask:
  224. _catchall_handlers[name] = True
  225. else:
  226. for m in mask:
  227. if _event_handler_map.get(m, None) is None:
  228. _event_handler_map[m] = {}
  229. _event_handler_map[m][name] = True
  230. return Registered
  231. def remove(name, handler):
  232. """Remove an Event handler"""
  233. _handlers.pop(name)
  234. if name in _catchall_handlers:
  235. _catchall_handlers.pop(name)
  236. for event in _event_handler_map.keys():
  237. if name in _event_handler_map[event]:
  238. _event_handler_map[event].pop(name)
  239. def get_handlers():
  240. return _handlers
  241. def set_handlers(handlers):
  242. global _handlers
  243. _handlers = handlers
  244. def set_eventfilter(func):
  245. global _eventfilter
  246. _eventfilter = func
  247. def register_UIHhandler(handler, mainui=False):
  248. bb.event._ui_handler_seq = bb.event._ui_handler_seq + 1
  249. _ui_handlers[_ui_handler_seq] = handler
  250. level, debug_domains = bb.msg.constructLogOptions()
  251. _ui_logfilters[_ui_handler_seq] = UIEventFilter(level, debug_domains)
  252. if mainui:
  253. global _uiready
  254. _uiready = _ui_handler_seq
  255. return _ui_handler_seq
  256. def unregister_UIHhandler(handlerNum, mainui=False):
  257. if mainui:
  258. global _uiready
  259. _uiready = False
  260. if handlerNum in _ui_handlers:
  261. del _ui_handlers[handlerNum]
  262. return
  263. def get_uihandler():
  264. if _uiready is False:
  265. return None
  266. return _uiready
  267. # Class to allow filtering of events and specific filtering of LogRecords *before* we put them over the IPC
  268. class UIEventFilter(object):
  269. def __init__(self, level, debug_domains):
  270. self.update(None, level, debug_domains)
  271. def update(self, eventmask, level, debug_domains):
  272. self.eventmask = eventmask
  273. self.stdlevel = level
  274. self.debug_domains = debug_domains
  275. def filter(self, event):
  276. if isinstance(event, logging.LogRecord):
  277. if event.levelno >= self.stdlevel:
  278. return True
  279. if event.name in self.debug_domains and event.levelno >= self.debug_domains[event.name]:
  280. return True
  281. return False
  282. eid = str(event.__class__)[8:-2]
  283. if self.eventmask and eid not in self.eventmask:
  284. return False
  285. return True
  286. def set_UIHmask(handlerNum, level, debug_domains, mask):
  287. if not handlerNum in _ui_handlers:
  288. return False
  289. if '*' in mask:
  290. _ui_logfilters[handlerNum].update(None, level, debug_domains)
  291. else:
  292. _ui_logfilters[handlerNum].update(mask, level, debug_domains)
  293. return True
  294. def getName(e):
  295. """Returns the name of a class or class instance"""
  296. if getattr(e, "__name__", None) is None:
  297. return e.__class__.__name__
  298. else:
  299. return e.__name__
  300. class OperationStarted(Event):
  301. """An operation has begun"""
  302. def __init__(self, msg = "Operation Started"):
  303. Event.__init__(self)
  304. self.msg = msg
  305. class OperationCompleted(Event):
  306. """An operation has completed"""
  307. def __init__(self, total, msg = "Operation Completed"):
  308. Event.__init__(self)
  309. self.total = total
  310. self.msg = msg
  311. class OperationProgress(Event):
  312. """An operation is in progress"""
  313. def __init__(self, current, total, msg = "Operation in Progress"):
  314. Event.__init__(self)
  315. self.current = current
  316. self.total = total
  317. self.msg = msg + ": %s/%s" % (current, total);
  318. class ConfigParsed(Event):
  319. """Configuration Parsing Complete"""
  320. class MultiConfigParsed(Event):
  321. """Multi-Config Parsing Complete"""
  322. def __init__(self, mcdata):
  323. self.mcdata = mcdata
  324. Event.__init__(self)
  325. class RecipeEvent(Event):
  326. def __init__(self, fn):
  327. self.fn = fn
  328. Event.__init__(self)
  329. class RecipePreFinalise(RecipeEvent):
  330. """ Recipe Parsing Complete but not yet finalised"""
  331. class RecipeTaskPreProcess(RecipeEvent):
  332. """
  333. Recipe Tasks about to be finalised
  334. The list of tasks should be final at this point and handlers
  335. are only able to change interdependencies
  336. """
  337. def __init__(self, fn, tasklist):
  338. self.fn = fn
  339. self.tasklist = tasklist
  340. Event.__init__(self)
  341. class RecipeParsed(RecipeEvent):
  342. """ Recipe Parsing Complete """
  343. class BuildBase(Event):
  344. """Base class for bitbake build events"""
  345. def __init__(self, n, p, failures = 0):
  346. self._name = n
  347. self._pkgs = p
  348. Event.__init__(self)
  349. self._failures = failures
  350. def getPkgs(self):
  351. return self._pkgs
  352. def setPkgs(self, pkgs):
  353. self._pkgs = pkgs
  354. def getName(self):
  355. return self._name
  356. def setName(self, name):
  357. self._name = name
  358. def getFailures(self):
  359. """
  360. Return the number of failed packages
  361. """
  362. return self._failures
  363. pkgs = property(getPkgs, setPkgs, None, "pkgs property")
  364. name = property(getName, setName, None, "name property")
  365. class BuildInit(BuildBase):
  366. """buildFile or buildTargets was invoked"""
  367. def __init__(self, p=[]):
  368. name = None
  369. BuildBase.__init__(self, name, p)
  370. class BuildStarted(BuildBase, OperationStarted):
  371. """Event when builds start"""
  372. def __init__(self, n, p, failures = 0):
  373. OperationStarted.__init__(self, "Building Started")
  374. BuildBase.__init__(self, n, p, failures)
  375. class BuildCompleted(BuildBase, OperationCompleted):
  376. """Event when builds have completed"""
  377. def __init__(self, total, n, p, failures=0, interrupted=0):
  378. if not failures:
  379. OperationCompleted.__init__(self, total, "Building Succeeded")
  380. else:
  381. OperationCompleted.__init__(self, total, "Building Failed")
  382. self._interrupted = interrupted
  383. BuildBase.__init__(self, n, p, failures)
  384. class DiskFull(Event):
  385. """Disk full case build aborted"""
  386. def __init__(self, dev, type, freespace, mountpoint):
  387. Event.__init__(self)
  388. self._dev = dev
  389. self._type = type
  390. self._free = freespace
  391. self._mountpoint = mountpoint
  392. class DiskUsageSample:
  393. def __init__(self, available_bytes, free_bytes, total_bytes):
  394. # Number of bytes available to non-root processes.
  395. self.available_bytes = available_bytes
  396. # Number of bytes available to root processes.
  397. self.free_bytes = free_bytes
  398. # Total capacity of the volume.
  399. self.total_bytes = total_bytes
  400. class MonitorDiskEvent(Event):
  401. """If BB_DISKMON_DIRS is set, then this event gets triggered each time disk space is checked.
  402. Provides information about devices that are getting monitored."""
  403. def __init__(self, disk_usage):
  404. Event.__init__(self)
  405. # hash of device root path -> DiskUsageSample
  406. self.disk_usage = disk_usage
  407. class NoProvider(Event):
  408. """No Provider for an Event"""
  409. def __init__(self, item, runtime=False, dependees=None, reasons=None, close_matches=None):
  410. Event.__init__(self)
  411. self._item = item
  412. self._runtime = runtime
  413. self._dependees = dependees
  414. self._reasons = reasons
  415. self._close_matches = close_matches
  416. def getItem(self):
  417. return self._item
  418. def isRuntime(self):
  419. return self._runtime
  420. def __str__(self):
  421. msg = ''
  422. if self._runtime:
  423. r = "R"
  424. else:
  425. r = ""
  426. extra = ''
  427. if not self._reasons:
  428. if self._close_matches:
  429. extra = ". Close matches:\n %s" % '\n '.join(self._close_matches)
  430. if self._dependees:
  431. msg = "Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s" % (r, self._item, ", ".join(self._dependees), r, extra)
  432. else:
  433. msg = "Nothing %sPROVIDES '%s'%s" % (r, self._item, extra)
  434. if self._reasons:
  435. for reason in self._reasons:
  436. msg += '\n' + reason
  437. return msg
  438. class MultipleProviders(Event):
  439. """Multiple Providers"""
  440. def __init__(self, item, candidates, runtime = False):
  441. Event.__init__(self)
  442. self._item = item
  443. self._candidates = candidates
  444. self._is_runtime = runtime
  445. def isRuntime(self):
  446. """
  447. Is this a runtime issue?
  448. """
  449. return self._is_runtime
  450. def getItem(self):
  451. """
  452. The name for the to be build item
  453. """
  454. return self._item
  455. def getCandidates(self):
  456. """
  457. Get the possible Candidates for a PROVIDER.
  458. """
  459. return self._candidates
  460. def __str__(self):
  461. msg = "Multiple providers are available for %s%s (%s)" % (self._is_runtime and "runtime " or "",
  462. self._item,
  463. ", ".join(self._candidates))
  464. rtime = ""
  465. if self._is_runtime:
  466. rtime = "R"
  467. msg += "\nConsider defining a PREFERRED_%sPROVIDER entry to match %s" % (rtime, self._item)
  468. return msg
  469. class ParseStarted(OperationStarted):
  470. """Recipe parsing for the runqueue has begun"""
  471. def __init__(self, total):
  472. OperationStarted.__init__(self, "Recipe parsing Started")
  473. self.total = total
  474. class ParseCompleted(OperationCompleted):
  475. """Recipe parsing for the runqueue has completed"""
  476. def __init__(self, cached, parsed, skipped, masked, virtuals, errors, total):
  477. OperationCompleted.__init__(self, total, "Recipe parsing Completed")
  478. self.cached = cached
  479. self.parsed = parsed
  480. self.skipped = skipped
  481. self.virtuals = virtuals
  482. self.masked = masked
  483. self.errors = errors
  484. self.sofar = cached + parsed
  485. class ParseProgress(OperationProgress):
  486. """Recipe parsing progress"""
  487. def __init__(self, current, total):
  488. OperationProgress.__init__(self, current, total, "Recipe parsing")
  489. class CacheLoadStarted(OperationStarted):
  490. """Loading of the dependency cache has begun"""
  491. def __init__(self, total):
  492. OperationStarted.__init__(self, "Loading cache Started")
  493. self.total = total
  494. class CacheLoadProgress(OperationProgress):
  495. """Cache loading progress"""
  496. def __init__(self, current, total):
  497. OperationProgress.__init__(self, current, total, "Loading cache")
  498. class CacheLoadCompleted(OperationCompleted):
  499. """Cache loading is complete"""
  500. def __init__(self, total, num_entries):
  501. OperationCompleted.__init__(self, total, "Loading cache Completed")
  502. self.num_entries = num_entries
  503. class TreeDataPreparationStarted(OperationStarted):
  504. """Tree data preparation started"""
  505. def __init__(self):
  506. OperationStarted.__init__(self, "Preparing tree data Started")
  507. class TreeDataPreparationProgress(OperationProgress):
  508. """Tree data preparation is in progress"""
  509. def __init__(self, current, total):
  510. OperationProgress.__init__(self, current, total, "Preparing tree data")
  511. class TreeDataPreparationCompleted(OperationCompleted):
  512. """Tree data preparation completed"""
  513. def __init__(self, total):
  514. OperationCompleted.__init__(self, total, "Preparing tree data Completed")
  515. class DepTreeGenerated(Event):
  516. """
  517. Event when a dependency tree has been generated
  518. """
  519. def __init__(self, depgraph):
  520. Event.__init__(self)
  521. self._depgraph = depgraph
  522. class TargetsTreeGenerated(Event):
  523. """
  524. Event when a set of buildable targets has been generated
  525. """
  526. def __init__(self, model):
  527. Event.__init__(self)
  528. self._model = model
  529. class ReachableStamps(Event):
  530. """
  531. An event listing all stamps reachable after parsing
  532. which the metadata may use to clean up stale data
  533. """
  534. def __init__(self, stamps):
  535. Event.__init__(self)
  536. self.stamps = stamps
  537. class FilesMatchingFound(Event):
  538. """
  539. Event when a list of files matching the supplied pattern has
  540. been generated
  541. """
  542. def __init__(self, pattern, matches):
  543. Event.__init__(self)
  544. self._pattern = pattern
  545. self._matches = matches
  546. class ConfigFilesFound(Event):
  547. """
  548. Event when a list of appropriate config files has been generated
  549. """
  550. def __init__(self, variable, values):
  551. Event.__init__(self)
  552. self._variable = variable
  553. self._values = values
  554. class ConfigFilePathFound(Event):
  555. """
  556. Event when a path for a config file has been found
  557. """
  558. def __init__(self, path):
  559. Event.__init__(self)
  560. self._path = path
  561. class MsgBase(Event):
  562. """Base class for messages"""
  563. def __init__(self, msg):
  564. self._message = msg
  565. Event.__init__(self)
  566. class MsgDebug(MsgBase):
  567. """Debug Message"""
  568. class MsgNote(MsgBase):
  569. """Note Message"""
  570. class MsgWarn(MsgBase):
  571. """Warning Message"""
  572. class MsgError(MsgBase):
  573. """Error Message"""
  574. class MsgFatal(MsgBase):
  575. """Fatal Message"""
  576. class MsgPlain(MsgBase):
  577. """General output"""
  578. class LogExecTTY(Event):
  579. """Send event containing program to spawn on tty of the logger"""
  580. def __init__(self, msg, prog, sleep_delay, retries):
  581. Event.__init__(self)
  582. self.msg = msg
  583. self.prog = prog
  584. self.sleep_delay = sleep_delay
  585. self.retries = retries
  586. class LogHandler(logging.Handler):
  587. """Dispatch logging messages as bitbake events"""
  588. def emit(self, record):
  589. if record.exc_info:
  590. etype, value, tb = record.exc_info
  591. if hasattr(tb, 'tb_next'):
  592. tb = list(bb.exceptions.extract_traceback(tb, context=3))
  593. # Need to turn the value into something the logging system can pickle
  594. record.bb_exc_info = (etype, value, tb)
  595. record.bb_exc_formatted = bb.exceptions.format_exception(etype, value, tb, limit=5)
  596. value = str(value)
  597. record.exc_info = None
  598. fire(record, None)
  599. def filter(self, record):
  600. record.taskpid = worker_pid
  601. return True
  602. class MetadataEvent(Event):
  603. """
  604. Generic event that target for OE-Core classes
  605. to report information during asynchrous execution
  606. """
  607. def __init__(self, eventtype, eventdata):
  608. Event.__init__(self)
  609. self.type = eventtype
  610. self._localdata = eventdata
  611. class ProcessStarted(Event):
  612. """
  613. Generic process started event (usually part of the initial startup)
  614. where further progress events will be delivered
  615. """
  616. def __init__(self, processname, total):
  617. Event.__init__(self)
  618. self.processname = processname
  619. self.total = total
  620. class ProcessProgress(Event):
  621. """
  622. Generic process progress event (usually part of the initial startup)
  623. """
  624. def __init__(self, processname, progress):
  625. Event.__init__(self)
  626. self.processname = processname
  627. self.progress = progress
  628. class ProcessFinished(Event):
  629. """
  630. Generic process finished event (usually part of the initial startup)
  631. """
  632. def __init__(self, processname):
  633. Event.__init__(self)
  634. self.processname = processname
  635. class SanityCheck(Event):
  636. """
  637. Event to run sanity checks, either raise errors or generate events as return status.
  638. """
  639. def __init__(self, generateevents = True):
  640. Event.__init__(self)
  641. self.generateevents = generateevents
  642. class SanityCheckPassed(Event):
  643. """
  644. Event to indicate sanity check has passed
  645. """
  646. class SanityCheckFailed(Event):
  647. """
  648. Event to indicate sanity check has failed
  649. """
  650. def __init__(self, msg, network_error=False):
  651. Event.__init__(self)
  652. self._msg = msg
  653. self._network_error = network_error
  654. class NetworkTest(Event):
  655. """
  656. Event to run network connectivity tests, either raise errors or generate events as return status.
  657. """
  658. def __init__(self, generateevents = True):
  659. Event.__init__(self)
  660. self.generateevents = generateevents
  661. class NetworkTestPassed(Event):
  662. """
  663. Event to indicate network test has passed
  664. """
  665. class NetworkTestFailed(Event):
  666. """
  667. Event to indicate network test has failed
  668. """
  669. class FindSigInfoResult(Event):
  670. """
  671. Event to return results from findSigInfo command
  672. """
  673. def __init__(self, result):
  674. Event.__init__(self)
  675. self.result = result