Commit 1aca020d authored by Devaev Maxim's avatar Devaev Maxim

Using constructor instead initService(), first run not emits signals

parent b2babf58
...@@ -97,31 +97,40 @@ class DisksSmart(service.FunctionObject) : ...@@ -97,31 +97,40 @@ class DisksSmart(service.FunctionObject) :
##### Public classes ##### ##### Public classes #####
class Service(service.Service) : class Service(service.Service) :
def initService(self) : def __init__(self) :
shared.Functions.addShared(DISKS_SMART_SHARED_NAME) service.Service.__init__(self)
### #####
self.__disks_smart = DisksSmart(DISKS_SMART_SHARED_NAME, self) self.__udev_client = gudev.Client(["block"])
shared.Functions.addSharedObject(DISKS_SMART_OBJECT_NAME, self.__disks_smart)
### self.__disks_smart = DisksSmart(DISKS_SMART_OBJECT_NAME, self)
self.__udev_client = gudev.Client(["block"])
### Public ###
def initService(self) :
shared.Functions.addShared(DISKS_SMART_SHARED_NAME)
shared.Functions.addSharedObject(DISKS_SMART_SHARED_NAME, self.__disks_smart)
logger.verbose("{mod}: First devices request...") logger.verbose("{mod}: First devices request...")
disks_smart_shared = shared.Functions.shared(DISKS_SMART_SHARED_NAME) disks_smart_shared = shared.Functions.shared(DISKS_SMART_SHARED_NAME)
disks_filter_regexp = re.compile(config.value(SERVICE_NAME, "disks_filter")) disks_filter_regexp = re.compile(config.value(SERVICE_NAME, "disks_filter"))
devices_count = 0
for device in self.__udev_client.query_by_subsystem("block") : for device in self.__udev_client.query_by_subsystem("block") :
if disks_filter_regexp.match(device.get_name()) : device_name = device.get_name()
self.udevEvent(self.__udev_client, "add", device) if disks_filter_regexp.match(device_name) :
disks_smart_shared.addSharedObject(device_name, Disk(device.get_device_file(),
dbus_tools.joinPath(DISKS_SMART_SHARED_NAME, device_name), self))
devices_count += 1
logger.verbose("{mod}: Added %d devices" % (devices_count))
self.__udev_client.connect("uevent", self.udevEvent) self.__udev_client.connect("uevent", self.udevEvent)
logger.verbose("{mod}: Start polling udev events") logger.verbose("{mod}: Start polling udev events for \"block\"")
def closeService(self) : def closeService(self) :
self.__udev_client.disconnect_by_func(self.udevEvent) self.__udev_client.disconnect_by_func(self.udevEvent)
logger.verbose("{mod}: Stop polling udev events") logger.verbose("{mod}: Stop polling udev events for \"block\"")
### ###
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment