diff options
author | Papoteur <papoteur@mageia.org> | 2020-10-17 12:42:36 +0200 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2020-10-17 12:42:56 +0200 |
commit | 87b1516092e1ad508c9af51d07e71ffa3f425a1b (patch) | |
tree | b6a8c3a2bfc3d9af384c9e69b4dadf85fb4275c4 /backend/magiback | |
parent | 6fd912ea3a1cf98005ec6f4f5f71685d65308770 (diff) | |
download | isodumper-87b1516092e1ad508c9af51d07e71ffa3f425a1b.tar isodumper-87b1516092e1ad508c9af51d07e71ffa3f425a1b.tar.gz isodumper-87b1516092e1ad508c9af51d07e71ffa3f425a1b.tar.bz2 isodumper-87b1516092e1ad508c9af51d07e71ffa3f425a1b.tar.xz isodumper-87b1516092e1ad508c9af51d07e71ffa3f425a1b.zip |
Reformat code
Diffstat (limited to 'backend/magiback')
-rwxr-xr-x | backend/magiback | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/backend/magiback b/backend/magiback index 7485773..49162b3 100755 --- a/backend/magiback +++ b/backend/magiback @@ -54,8 +54,8 @@ class Isodumper(raw_write.Dumper): """ def __init__(self): super().__init__() - APP="isodumper" - DIR="/usr/share/locale" + APP = "isodumper" + DIR = "/usr/share/locale" # Call translation catalog gettext.install(APP, localedir=DIR,) self.finished = threading.Event() @@ -73,10 +73,9 @@ class Isodumper(raw_write.Dumper): self.writing_perm = False self.writing_target = "" - - def do_write(self,source, target, size, dbus_context): + def do_write(self, source, target, size, dbus_context): self.finished.clear() - if check_permission('org.mageia.Magiback.Isodumper.write',dbus_context): + if check_permission('org.mageia.Magiback.Isodumper.write', dbus_context): self.thread = threading.Thread(target=self._do_write, args=(source, target, size, )) self.thread.start() logging.debug("Writing thread started") @@ -89,7 +88,7 @@ class Isodumper(raw_write.Dumper): def do_persistence(self, target, label, key): self.finished.clear() - if self.writing_perm and self.writing_target == target : + if self.writing_perm and self.writing_target == target: self.thread = threading.Thread(target=self._do_persistence, args=(target, label, key)) self.thread.start() logging.debug("Persistence thread started") @@ -126,19 +125,21 @@ class Isodumper(raw_write.Dumper): self.key_thread = threading.Thread(target=self._get_sum, args=(source,)) self.key_thread.start() - def check_write(self,target, source): + def check_write(self, target, source): if hasattr(self, 'key_thread'): self.key_thread.join() self.thread = threading.Thread(target=self._check_write, args=(target, source,)) self.thread.start() def run(self): - self.loop.run() + self.loop.run() + def check_permission(action, dbus_context): - """ Check permission - """ - return dbus_context.is_authorized(action, {'polkit.icon_name': 'isodumper.png',}, interactive=True) + """ Check permission + """ + return dbus_context.is_authorized(action, {'polkit.icon_name': 'isodumper.png', }, interactive=True) + class ConfFile(object): """ @@ -159,11 +160,11 @@ class ConfFile(object): def __init__(self): super().__init__() - def setName(self,file_name): + def setName(self, file_name): self.file_name = file_name def getFile(self): - with open(self.file_name,'r') as tcf : + with open(self.file_name, 'r') as tcf: # read the file content="" while 1: @@ -174,20 +175,20 @@ class ConfFile(object): return content def saveFile(self, tc, dbus_context): - if check_permission('org.mageia.Magiback.write',dbus_context): + if check_permission('org.mageia.Magiback.write', dbus_context): try: - with open(self.file_name,'w') as tcf : + with open(self.file_name, 'w') as tcf: tcf.write(tc) except: return False return True + if __name__ == '__main__': print("Running Magiback service.") bus = SystemBus() - conf_file = ConfFile() - bus.publish(DEAMON_ORG, conf_file, - ("Isodumper", Isodumper())) + conf_file = ConfFile() + bus.publish(DEAMON_ORG, conf_file, ("Isodumper", Isodumper())) loop = GLib.MainLoop() loop.run() logging.shutdown() |