aboutsummaryrefslogtreecommitdiffstats
path: root/lib/isodumper.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/isodumper.py')
-rwxr-xr-xlib/isodumper.py286
1 files changed, 143 insertions, 143 deletions
diff --git a/lib/isodumper.py b/lib/isodumper.py
index 590db25..98f47c5 100755
--- a/lib/isodumper.py
+++ b/lib/isodumper.py
@@ -168,23 +168,23 @@ class UDisks2(object):
drive = self.drive_for_device(self.device(device_node_path))
drive.Eject({'auth.no_user_interaction':True},
dbus_interface=self.DRIVE)
-
-def countFiles(directory):
- files = []
- if os.path.isdir(directory):
- for path, dirs, filenames in os.walk(directory):
- files.extend(filenames)
- return len(files)
-
-def makedirs(dest):
- if not os.path.exists(dest):
- os.makedirs(dest)
+#
+#def countFiles(directory):
+# files = []
+# if os.path.isdir(directory):
+# for path, dirs, filenames in os.walk(directory):
+# files.extend(filenames)
+# return len(files)
+#
+#def makedirs(dest):
+# if not os.path.exists(dest):
+# os.makedirs(dest)
class IsoDumper:
def __init__(self,user):
APP="isodumper"
DIR="/usr/share/locale"
- RELEASE="v0.41"
+ RELEASE="v0.42"
gettext.bindtextdomain(APP, DIR)
gettext.textdomain(APP)
@@ -485,74 +485,74 @@ class IsoDumper:
self.do_umount(target)
dialog.hide()
# Writing step
- # Iso dump or Uefi preparation
- uefi_checkbox=self.wTree.get_widget("uefi_check")
- if uefi_checkbox.get_active():
- #uefi mode : formats FAT32, names MGALIVE, copies the ISO
- target = self.dev.split('(')[1].split(')')[0]
- dev_name="MGALIVE"
- rc=self.raw_format(target, 'fat32', dev_name)
- if rc == 5:
- message = _("An error occurred while creating a partition.")
- self.logger(message)
- self.emergency()
- elif rc == 127:
- message = _('Authentication error.')
- self.logger(message)
- self.emergency()
- elif rc == 0:
- message = _('The device was formatted successfully.')
- self.logger(message)
-# time.sleep(2)
- seen=False
- part=target+'1'
- while(not seen):
- try:
- self.u.device(part)
- seen=True
- except:
- seen=False
- time.sleep(.5)
- try:
- dest=self.u.mount(part)
- except:
- self.logger(_("Error mounting the partition %s")%part)
- self.emergency()
- return
- if dest!="":
- self.logger(_("Mounted in: ")+dest)
- self.returncode=0
- task = self.files_write(source, dest, b)
- gobject.idle_add(task.next)
- self.operation=False
- while gtk.events_pending():
- gtk.main_iteration(True)
- if self.returncode==0:
- self.success()
- else:
- self.logger(_("Error copying files"))
- self.emergency()
- else:
- self.operation=False
- self.logger(_("Error mounting the partition %s")%part)
- self.emergency()
- else:
- message = _('An error occurred.')
- self.emergency()
- else:
+# # Iso dump or Uefi preparation
+# uefi_checkbox=self.wTree.get_widget("uefi_check")
+# if uefi_checkbox.get_active():
+# #uefi mode : formats FAT32, names MGALIVE, copies the ISO
+# target = self.dev.split('(')[1].split(')')[0]
+# dev_name="MGALIVE"
+# rc=self.raw_format(target, 'fat32', dev_name)
+# if rc == 5:
+# message = _("An error occurred while creating a partition.")
+# self.logger(message)
+# self.emergency()
+# elif rc == 127:
+# message = _('Authentication error.')
+# self.logger(message)
+# self.emergency()
+# elif rc == 0:
+# message = _('The device was formatted successfully.')
+# self.logger(message)
+## time.sleep(2)
+# seen=False
+# part=target+'1'
+# while(not seen):
+# try:
+# self.u.device(part)
+# seen=True
+# except:
+# seen=False
+# time.sleep(.5)
+# try:
+# dest=self.u.mount(part)
+# except:
+# self.logger(_("Error mounting the partition %s")%part)
+# self.emergency()
+# return
+# if dest!="":
+# self.logger(_("Mounted in: ")+dest)
+# self.returncode=0
+# task = self.files_write(source, dest, b)
+# gobject.idle_add(task.next)
+# self.operation=False
+# while gtk.events_pending():
+# gtk.main_iteration(True)
+# if self.returncode==0:
+# self.success()
+# else:
+# self.logger(_("Error copying files"))
+# self.emergency()
+# else:
+# self.operation=False
+# self.logger(_("Error mounting the partition %s")%part)
+# self.emergency()
+# else:
+# message = _('An error occurred.')
+# self.emergency()
+# else:
#Dump mode
- self.returncode=0
- b=os.path.getsize(source)
- task = self.raw_write(source, target, b)
- gobject.idle_add(task.next)
- while gtk.events_pending():
- gtk.main_iteration(True)
- task = self.check_write(target, b)
- gobject.idle_add(task.next)
- while gtk.events_pending():
- gtk.main_iteration(True)
- if self.returncode == 0:
- self.success()
+ self.returncode=0
+ b=os.path.getsize(source)
+ task = self.raw_write(source, target, b)
+ gobject.idle_add(task.next)
+ while gtk.events_pending():
+ gtk.main_iteration(True)
+ task = self.check_write(target, b)
+ gobject.idle_add(task.next)
+ while gtk.events_pending():
+ gtk.main_iteration(True)
+ if self.returncode == 0:
+ self.success()
else:
dialog.hide()
combo.set_sensitive(True)
@@ -704,70 +704,70 @@ class IsoDumper:
progress.set_fraction(1.0)
yield False
- def files_write(self, source, dest, size):
- self.operation=True
- self.logger(time.ctime(time.time()))
- temp_dir='/mnt/MGALIVE'
- makedirs(temp_dir)
- self.process=Popen(['mount', '-o', 'loop',source,temp_dir ], shell=False, stdout=PIPE)
- working=True
- while working:
- time.sleep(0.5)
- self.process.poll()
- rc=self.process.returncode
- if rc is None:
- working=True
- else:
- self.process = None
- working=False
- self.logger(_('ISO image mounted in ')+temp_dir)
- progress = self.wTree.get_widget("progressbar")
- progress.set_sensitive(True)
- progress.set_text(_('Writing ')+source.split('/')[-1]+_(' to ')+dest)
- self.logger(_('Executing copy from ')+source+_(' to ')+dest)
- while gtk.events_pending():
- gtk.main_iteration(True)
- total_files=countFiles(temp_dir)
- self.logger(_("%s file(s) to copy."%total_files))
- cumuled_size=0
- if total_files > 0:
- for path, dirs, filenames in os.walk(temp_dir):
- for directory in dirs:
- destDir = path.replace(temp_dir,dest)
- makedirs(os.path.join(destDir, directory))
- for sfile in filenames:
- srcFile = os.path.join(path, sfile)
- destFile = os.path.join(path.replace(temp_dir, dest), sfile)
- try:
- with open(srcFile, 'rb') as fsrc:
- with open(destFile, 'wb') as fdst:
- while 1:
- buf = fsrc.read(256*1024)
- if not buf:
- os.fsync(fdst)
- break
- fdst.write(buf)
- cumuled_size += len(buf)
- progress.set_fraction(min(float(cumuled_size)/size,1))
- print float(cumuled_size)/size
- while gtk.events_pending():
- gtk.main_iteration(True)
- except:
- self.returncode=1
- return
- while gtk.events_pending():
- gtk.main_iteration(True)
- yield True
- self.process = Popen(['umount', temp_dir ], shell=False, stdout=PIPE)
- while True :
- self.process.poll()
- if self.process.returncode != None:
- break
- self.logger(_('Image ')+source.split('/')[-1]+_(' successfully written to ')+dest)
- self.logger(time.ctime(time.time()))
- else:
- self.returncode=1
-
+# def files_write(self, source, dest, size):
+# self.operation=True
+# self.logger(time.ctime(time.time()))
+# temp_dir='/mnt/MGALIVE'
+# makedirs(temp_dir)
+# self.process=Popen(['mount', '-o', 'loop',source,temp_dir ], shell=False, stdout=PIPE)
+# working=True
+# while working:
+# time.sleep(0.5)
+# self.process.poll()
+# rc=self.process.returncode
+# if rc is None:
+# working=True
+# else:
+# self.process = None
+# working=False
+# self.logger(_('ISO image mounted in ')+temp_dir)
+# progress = self.wTree.get_widget("progressbar")
+# progress.set_sensitive(True)
+# progress.set_text(_('Writing ')+source.split('/')[-1]+_(' to ')+dest)
+# self.logger(_('Executing copy from ')+source+_(' to ')+dest)
+# while gtk.events_pending():
+# gtk.main_iteration(True)
+# total_files=countFiles(temp_dir)
+# self.logger(_("%s file(s) to copy."%total_files))
+# cumuled_size=0
+# if total_files > 0:
+# for path, dirs, filenames in os.walk(temp_dir):
+# for directory in dirs:
+# destDir = path.replace(temp_dir,dest)
+# makedirs(os.path.join(destDir, directory))
+# for sfile in filenames:
+# srcFile = os.path.join(path, sfile)
+# destFile = os.path.join(path.replace(temp_dir, dest), sfile)
+# try:
+# with open(srcFile, 'rb') as fsrc:
+# with open(destFile, 'wb') as fdst:
+# while 1:
+# buf = fsrc.read(256*1024)
+# if not buf:
+# os.fsync(fdst)
+# break
+# fdst.write(buf)
+# cumuled_size += len(buf)
+# progress.set_fraction(min(float(cumuled_size)/size,1))
+# print float(cumuled_size)/size
+# while gtk.events_pending():
+# gtk.main_iteration(True)
+# except:
+# self.returncode=1
+# return
+# while gtk.events_pending():
+# gtk.main_iteration(True)
+# yield True
+# self.process = Popen(['umount', temp_dir ], shell=False, stdout=PIPE)
+# while True :
+# self.process.poll()
+# if self.process.returncode != None:
+# break
+# self.logger(_('Image ')+source.split('/')[-1]+_(' successfully written to ')+dest)
+# self.logger(time.ctime(time.time()))
+# else:
+# self.returncode=1
+#
def success(self):
self.operation=False
dialog = self.wTree.get_widget("success_dialog")