def prepare(self): if fileExists(self.src_file, 'r'): if self.src_isDir: self.src_size = float(self.dirSize(self.src_file)) else: self.src_size = float(os.path.getsize(self.src_file)) self.updateTime = max(1000, int(self.src_size * 0.000001 * 0.5)) # based on 20Mb/s transfer rate self.progressTimer.start(self.updateTime, True)
def progressUpdate(self): if not fileExists(self.dst_file, 'r'): return if self.dst_isDir: dst_dir_size = self.dst_file if self.src_isDir and self.src_file.endswith("/"): mv_dir = self.src_file[:-1].rsplit("/", 1) if len(mv_dir) == 2: dst_dir_size = self.dst_file + mv_dir[1] dst_size = float(self.dirSize(dst_dir_size)) else: dst_size = float(os.path.getsize(self.dst_file)) progress = dst_size / self.src_size * 100.0 self.setProgress(progress) self.progressTimer.start(self.updateTime, True)
def unpackModus(self, id): if id == 1: # This is done in a subshell because using two # communicating Popen commands can deadlock on the # pipe output. Using communicate() avoids deadlock # on reading stdout and stderr from the pipe. fname = shellquote(self.sourceDir + self.filename) p = subprocess.Popen("ar -t %s > /dev/null 2>&1" % fname, shell=True) if p.wait(): cmd = "tar -xOf %s ./data.tar.gz | tar -tzf -" % fname else: cmd = "ar -p %s data.tar.gz | tar -tzf -" % fname self.unpackPopen(cmd, UnpackInfoScreen) elif id == 4: self.ulist = [] if fileExists("/usr/bin/opkg"): self.session.openWithCallback(self.doCallBack, Console, title=_("Installing Plugin ..."), cmdlist=(("opkg", "install", self.sourceDir + self.filename),))