def updateProgress(): totprogress = 0 for i in page["progress"]: totprogress += utilities.floatDivision( float(page["progress"][i]), 100) QtCore.QMetaObject.invokeMethod(ui.progress, "setValue", QtCore.Qt.QueuedConnection, QtCore.Q_ARG("int", utilities.calcPercent(totprogress, numthreads2)))
def updateProgress(): totprogress = 0 for i in page["progress"]: totprogress += utilities.floatDivision( float(page["progress"][i]), 100) QtCore.QMetaObject.invokeMethod( ui.progress, "setValue", QtCore.Qt.QueuedConnection, QtCore.Q_ARG("int", utilities.calcPercent(totprogress, numthreads2)))
def runthread(self): logger.logI(self.tn, logger.I, _("Starting generation of the ISO image")) # Make a last verification on the SquashFS squashfs.doSFSChecks(isotreel + "casper/filesystem.squashfs", configutils.getValue(configs[configutils.isolevel])) self.setProgress(self.tn, 5) # Generate MD5 checksums logger.logV(self.tn, logger.I, _("Generating MD5 sums")) files = open(isotreel + "md5sum.txt", "w") for x in fsutil.listdir(isotreel, {"recurse": True}): i = re.sub(r"^ *" + isotreel + "/*", "./", x) if not "isolinux" in i and not "md5sum" in i: logger.logVV(self.tn, logger.I, _("Writing MD5 sum of") + " " + i) fmd5 = fsutil.genFinalMD5(i, x) if fmd5 != "" and fmd5 != None: files.write(fmd5) files.close() self.setProgress(self.tn, 15) logger.logI(self.tn, logger.I, _("Generating the ISO")) location = (configutils.getValue(configs[configutils.isodir]) + "/" + configutils.getValue(configs[configutils.isolocation])) patt = re.compile("^ *([0-9]+)\.?[0-9]*%.*$") appnd = "32" if sys.maxsize > 2 ** 32: appnd = "64" os.environ["LD_PRELOAD"] = os.path.split(os.path.realpath(__file__))[0] + "/isatty" + appnd + ".so" isocmd = subprocess.Popen(shlex.split(configutils.getValue(configs[configutils.isogenerator]) + " -o " + location + " " + isogenopts + " -V \"" + configutils.getValue(configs[configutils.label]) + "\" " + isotreel), stderr=subprocess.PIPE, universal_newlines=True) oldprogress = 0 while isocmd.poll() is None: output = isocmd.stderr.readline() match = patt.match(output) if match != None: progress = int(match.group(1)) if progress > oldprogress: # 1.4285714285714286 is just 100 / 70 self.setProgress(self.tn, 15 + int(utilities.floatDivision(progress, 1.4285714285714286))) oldprogress = progress sys.stdout.write(output) sys.stdout.flush() os.environ["LD_PRELOAD"] = "" self.setProgress(self.tn, 85) # Generate the MD5 sum logger.logV(self.tn, logger.I, _("Generating MD5 sum for the ISO")) files = open(location + ".md5", "w") files.write(fsutil.genFinalMD5("./" + configutils.getValue(configs[configutils.isolocation]), location)) files.close()
def setProgress(tn, progress): logger.logVV(tn, logger.D, "Setting progress to " + str(progress) + " (from thread " + threading.current_thread().name + ")") #return # Do something here if progress > 100: progress = 100 elif progress < 0: progress = 0 page["progress"][tn] = progress totprogress = 0 for i in page["progress"]: totprogress += utilities.floatDivision(float(page["progress"][i]), 100) QtCore.QMetaObject.invokeMethod(ui.progress, "setValue", QtCore.Qt.QueuedConnection, QtCore.Q_ARG("int", utilities.calcPercent(totprogress, numthreads2)))
def setProgress(tn, progress): logger.logVV( tn, logger.D, "Setting progress to " + str(progress) + " (from thread " + threading.current_thread().name + ")") #return # Do something here if progress > 100: progress = 100 elif progress < 0: progress = 0 page["progress"][tn] = progress totprogress = 0 for i in page["progress"]: totprogress += utilities.floatDivision( float(page["progress"][i]), 100) QtCore.QMetaObject.invokeMethod( ui.progress, "setValue", QtCore.Qt.QueuedConnection, QtCore.Q_ARG("int", utilities.calcPercent(totprogress, numthreads2)))
def runthread(self): logger.logI(tn, logger.I, _("Generating compressed filesystem")) # Generate the SquashFS file # Options: # -b 1M Use a 1M blocksize (maximum) # -no-recovery No recovery files # -always-use-fragments Fragment blocks for files larger than the blocksize (1M) # -comp Compression type logger.logVV(tn, logger.I, _("Generating options")) opts = "-b 1M -no-recovery -no-duplicates -always-use-fragments" opts = opts + " -comp " + configutils.getValue(configs[ configutils.sfscomp]) opts = opts + " " + configutils.getValue(configs[configutils.sfsopts]) sfsex = "dev etc home media mnt proc sys var run usr/lib/ubiquity/apt-setup/generators/40cdrom tmp" sfspath = isotreel + "casper/filesystem.squashfs" if os.path.exists(sfspath): fsutil.rm(sfspath) # This line would match the pattern below: [==========/ ] 70/300 20% patt = re.compile("^ *\[=*. *\] *[0-9]*/[0-9]* *([0-9]*)% *$") appnd = "32" if sys.maxsize > 2 ** 32: appnd = "64" # Hack to make sure all output is given os.environ["LD_PRELOAD"] = os.path.split( os.path.realpath(__file__))[0] + "/isatty" + appnd + ".so" logger.logI(tn, logger.I, _( "Adding the edited /etc and /var to the filesystem")) logger.logI(tn, logger.I, logger.MTab + _( "This might take a couple of minutes")) sfscmd = subprocess.Popen( shlex.split("mksquashfs " + tmpsys + " " + sfspath + " " + opts), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) oldprogress = 0 while sfscmd.poll() is None: output = sfscmd.stdout.readline() match = patt.match(output) if match is not None: sys.stdout.write("\r" + match.group(0)) sys.stdout.flush() progress = int(match.group(1)) if progress > oldprogress: self.setProgress( tn, int(utilities.floatDivision(progress, 2))) oldprogress = progress elif len(output.strip()) > 0: logger.logI(tn, logger.I, output.rstrip(), noterm=True, nogui=True) sys.stdout.write("\n") logger.logI(tn, logger.I, _( "Adding the rest of the system (this can take a while)")) sfscmd = subprocess.Popen( shlex.split( "mksquashfs / " + sfspath + " " + opts + " -e " + sfsex), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) oldprogress = 0 while sfscmd.poll() is None: output = sfscmd.stdout.readline() match = patt.match(output) if match is not None: sys.stdout.write("\r" + match.group(0)) sys.stdout.flush() progress = int(match.group(1)) if progress > oldprogress: self.setProgress( tn, 50 + int(utilities.floatDivision(progress, 2))) oldprogress = progress elif len(output.strip()) > 0: logger.logI(tn, logger.I, output.rstrip(), noterm=True, nogui=True) sys.stdout.write("\n") os.environ["LD_PRELOAD"] = "" # Make sure the SquashFS file is OK doSFSChecks( sfspath, int(configutils.getValue(configs[configutils.isolevel]))) # Find the size after it is uncompressed logger.logV(tn, logger.I, _("Writing the size")) files = open(isotreel + "casper/filesystem.size", "w") files.write(str(fsutil.getSFSInstSize(sfspath)) + "\n") files.close()
def runthread(self): logger.logI(tn, logger.I, _("Generating compressed filesystem")) # Generate the SquashFS file # Options: # -b 1M Use a 1M blocksize (maximum) # -no-recovery No recovery files # -always-use-fragments Fragment blocks for files larger than the blocksize (1M) # -comp Compression type logger.logVV(tn, logger.I, _("Generating options")) opts = "-b 1M -no-recovery -no-duplicates -always-use-fragments" opts = opts + " -comp " + configutils.getValue( configs[configutils.sfscomp]) opts = opts + " " + configutils.getValue(configs[configutils.sfsopts]) sfsex = "dev etc home media mnt proc sys var run usr/lib/ubiquity/apt-setup/generators/40cdrom tmp" sfspath = isotreel + "casper/filesystem.squashfs" if os.path.exists(sfspath): fsutil.rm(sfspath) # This line would match the pattern below: [==========/ ] 70/300 20% patt = re.compile("^ *\[=*. *\] *[0-9]*/[0-9]* *([0-9]*)% *$") appnd = "32" if sys.maxsize > 2**32: appnd = "64" # Hack to make sure all output is given os.environ["LD_PRELOAD"] = os.path.split( os.path.realpath(__file__))[0] + "/isatty" + appnd + ".so" logger.logI(tn, logger.I, _("Adding the edited /etc and /var to the filesystem")) logger.logI(tn, logger.I, logger.MTab + _("This might take a couple of minutes")) sfscmd = subprocess.Popen(shlex.split("mksquashfs " + tmpsys + " " + sfspath + " " + opts), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) oldprogress = 0 while sfscmd.poll() is None: output = sfscmd.stdout.readline() match = patt.match(output) if match is not None: sys.stdout.write("\r" + match.group(0)) sys.stdout.flush() progress = int(match.group(1)) if progress > oldprogress: self.setProgress(tn, int(utilities.floatDivision(progress, 2))) oldprogress = progress elif len(output.strip()) > 0: logger.logI(tn, logger.I, output.rstrip(), noterm=True, nogui=True) sys.stdout.write("\n") logger.logI(tn, logger.I, _("Adding the rest of the system (this can take a while)")) sfscmd = subprocess.Popen(shlex.split("mksquashfs / " + sfspath + " " + opts + " -e " + sfsex), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) oldprogress = 0 while sfscmd.poll() is None: output = sfscmd.stdout.readline() match = patt.match(output) if match is not None: sys.stdout.write("\r" + match.group(0)) sys.stdout.flush() progress = int(match.group(1)) if progress > oldprogress: self.setProgress( tn, 50 + int(utilities.floatDivision(progress, 2))) oldprogress = progress elif len(output.strip()) > 0: logger.logI(tn, logger.I, output.rstrip(), noterm=True, nogui=True) sys.stdout.write("\n") os.environ["LD_PRELOAD"] = "" # Make sure the SquashFS file is OK doSFSChecks(sfspath, int(configutils.getValue(configs[configutils.isolevel]))) # Find the size after it is uncompressed logger.logV(tn, logger.I, _("Writing the size")) files = open(isotreel + "casper/filesystem.size", "w") files.write(str(fsutil.getSFSInstSize(sfspath)) + "\n") files.close()