Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def wake(self):
self.sleeping = False
if self.disabled:
# module is disabled so don't wake
return
if self.cache_time is None:
return
# new style modules can signal they want to cache forever
if self.cache_time == Py3.CACHE_FOREVER:
return
# restart
self._py3_wrapper.timeout_queue_add(self, self.cache_time)
def add_udev_trigger(self, trigger_action, subsystem):
"""
Subscribe to the requested udev subsystem and apply the given action.
"""
if self._py3_wrapper.udev_monitor.subscribe(self, trigger_action, subsystem):
if trigger_action == "refresh_and_freeze":
# FIXME: we may want to disable refresh instead of using cache_timeout
self.module_class.cache_timeout = Py3.CACHE_FOREVER
except Exception as e:
msg = "Instance `{}`, user method `{}` failed"
msg = msg.format(self.module_full_name, meth)
if not self.testing:
self._py3_wrapper.report_exception(msg, notify_user=False)
# added error
self.runtime_error(str(e) or e.__class__.__name__, meth)
cache_time = time() + getattr(
self.module_class, "cache_timeout", self.config["cache_timeout"]
)
if cache_time is None:
cache_time = time() + self.config["cache_timeout"]
self.cache_time = cache_time
# new style modules can signal they want to cache forever
if cache_time == Py3.CACHE_FOREVER:
return
# don't be hasty mate
# set timeout to do update next time one is needed
if not cache_time:
cache_time = time() + self.config["minimum_interval"]
self._py3_wrapper.timeout_queue_add(self, cache_time)
)
# module working correctly so ensure module works as
# expected
self.allow_config_clicks = True
self.error_messages = None
self.error_hide = False
# mark module as updated
self.set_updated()
except ModuleErrorException as e:
# module has indicated that it has an error
self.runtime_error(e.msg, meth)
if e.timeout:
if e.timeout is Py3.CACHE_FOREVER:
cache_time = Py3.CACHE_FOREVER
else:
cache_time = time() + e.timeout
else:
cache_time = time() + getattr(
self.module_class,
"cache_timeout",
self.config["cache_timeout"],
)
except Exception as e:
msg = "Instance `{}`, user method `{}` failed"
msg = msg.format(self.module_full_name, meth)
if not self.testing:
self._py3_wrapper.report_exception(msg, notify_user=False)
# added error
self.runtime_error(str(e) or e.__class__.__name__, meth)
"method {} returned {} ".format(meth, result)
)
# module working correctly so ensure module works as
# expected
self.allow_config_clicks = True
self.error_messages = None
self.error_hide = False
# mark module as updated
self.set_updated()
except ModuleErrorException as e:
# module has indicated that it has an error
self.runtime_error(e.msg, meth)
if e.timeout:
if e.timeout is Py3.CACHE_FOREVER:
cache_time = Py3.CACHE_FOREVER
else:
cache_time = time() + e.timeout
else:
cache_time = time() + getattr(
self.module_class,
"cache_timeout",
self.config["cache_timeout"],
)
except Exception as e:
msg = "Instance `{}`, user method `{}` failed"
msg = msg.format(self.module_full_name, meth)
if not self.testing:
self._py3_wrapper.report_exception(msg, notify_user=False)
# added error