aboutsummaryrefslogtreecommitdiffstats
path: root/backend/raw_write.py
diff options
context:
space:
mode:
Diffstat (limited to 'backend/raw_write.py')
-rwxr-xr-xbackend/raw_write.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/backend/raw_write.py b/backend/raw_write.py
index dbf8e19..d369d82 100755
--- a/backend/raw_write.py
+++ b/backend/raw_write.py
@@ -34,6 +34,7 @@ from subprocess import call, Popen, PIPE
import hashlib
import gnupg
import time
+import logging
class Dumper(object):
@@ -47,6 +48,7 @@ class Dumper(object):
ifc=io.open(source, "rb",1)
except:
message = _('Reading error.')+ source
+ logging.debug(message)
self.return_state = False
self.return_message = message
self.finished.set()
@@ -85,6 +87,7 @@ class Dumper(object):
ofc.write(buf)
except:
message = _("Writing error.")
+ logging.debug(message)
self.return_state = False
self.return_message = message
self.finished.set()
@@ -98,6 +101,7 @@ class Dumper(object):
os.fsync(ofc)
except:
message = _("Writing error.")
+ logging.debug(message)
self.return_state = False
self.return_message = message
self.finished.set()
@@ -114,11 +118,13 @@ class Dumper(object):
self._progress = 100
self.finished.set()
self.return_state = True
- self.return_message = _("Success")
+ self.return_message = _("Writing terminated")
+ logging.debug(self.return_message)
return
def _do_unmount(self, target):
target = target[0]
+ logging.debug("Starting unmounting")
message = _("No partition is mounted.")
retcode = 0
try:
@@ -144,12 +150,13 @@ class Dumper(object):
message += _('Error, umount returned {}').format(str(retcode))
except OSError as e:
message += _('Execution failed: {}').format(str(e))
- print(message)
+ logging.info(message)
return not bool(retcode), message
def _get_sum(self, source):
self.return_state = False
self.return_message = ""
+ logging.debug("Starting getting sum")
# Check if the sum file has a valid signature
gpg = gnupg.GPG()
gpg.encoding = 'utf-8'
@@ -178,8 +185,10 @@ class Dumper(object):
except:
self.return_message = _("Sum SHA512 file {} not found\n").format(source+'.sha512')
self.sum_file = False
+ logging.info(self.return_message)
def _check_write(self, target, source):
+ logging.debug("Start checking")
self.return_state = False
self.return_message = ""
b = os.path.getsize(source)
@@ -219,13 +228,15 @@ class Dumper(object):
#pass
self._progress = 100
+ logging.info(self.return_message)
self.return_state = True
self.finished.set()
def _do_persistence(self, target, label):
+ logging.debug("Start doing persistence partition")
p = Popen(["fdisk",target], stdin = PIPE)
p.communicate(input=b'n\np\n3\n\n\nw\n')
- # exemple mkfs.ext4 -L mgalive-persist /dev/sdf3
+ # example mkfs.ext4 -L mgalive-persist /dev/sdf3
process = Popen(['mkfs.ext4','-L', label, target+"3"])
working=True
while working:
@@ -237,7 +248,7 @@ class Dumper(object):
else:
process = None
working= False
- print(rc)
+ logging.debug("Persistence partition done")
return rc