diff options
Diffstat (limited to 'backend')
-rwxr-xr-x | backend/magiback | 37 | ||||
-rwxr-xr-x | backend/raw_write.py | 18 |
2 files changed, 29 insertions, 26 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() diff --git a/backend/raw_write.py b/backend/raw_write.py index cd80b85..8338a07 100755 --- a/backend/raw_write.py +++ b/backend/raw_write.py @@ -23,19 +23,21 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. +import gettext +import hashlib +import io +import logging ########### # imports # ########### -#import locale +# import locale import os -import io import sys -import gettext -from subprocess import call, Popen, PIPE -import hashlib -import gnupg import time -import logging +from subprocess import Popen, PIPE + +import gnupg + class Dumper(object): @@ -211,7 +213,7 @@ class Dumper(object): def udev_wait(self, operation): wait = Popen(["udevadm","settle","--timeout=15"], stderr=PIPE) - outs, errs = wait.communicate() + wait.communicate() working=True while working: time.sleep(0.5) |