def do_run_script(self, answer): answer = answer and answer[1] if answer in ("YES", "PAR", "YES_BG", "PAR_BG"): if not os.access(self.commando, os.R_OK): self.session.open(MessageBox, _("Script '%s' must have read permission to be able to run it") % self.commando, type=MessageBox.TYPE_ERROR, close_on_any_key=True) return nice = config.plugins.filecommander.script_priority_nice.value or '' ionice = config.plugins.filecommander.script_priority_ionice.value or '' if nice: nice = 'nice -n %d ' %nice if ionice: ionice = 'ionice -c %d ' %ionice priority = '%s%s' %(nice,ionice) if self.commando.endswith('.sh'): if os.access(self.commando, os.X_OK): if 'PAR' in answer: cmdline = "%s%s '%s'" %(priority, self.commando, self.parameter) else: cmdline = "%s%s" %(priority, self.commando) else: if 'PAR' in answer: cmdline = "%s/bin/sh %s '%s'" %(priority, self.commando, self.parameter) else: cmdline = "%s/bin/sh %s" %(priority, self.commando) else: if 'PAR' in answer: cmdline = "%s/usr/bin/python %s '%s'" %(priority, self.commando, self.parameter) else: cmdline = "%s/usr/bin/python %s" %(priority, self.commando) elif answer == "VIEW": try: yfile = os.stat(self.commando) except OSError as oe: self.session.open(MessageBox, _("%s: %s") % (self.commando, oe.strerror), type=MessageBox.TYPE_ERROR) return if (yfile.st_size < 1000000): self.session.open(vEditor, self.commando) if answer and answer != "VIEW": if answer.endswith('_BG'): global task_Stout, task_Sterr task_Stout = [] task_Sterr = [] if 'PAR' in answer: name = '%s%s %s' %(priority, self.commando, self.parameter) else: name = '%s%s' %(priority, self.commando) job = Job(_("Run script") + " ('%s')" %name) task = Task(job, name) task.postconditions.append(task_postconditions()) task.processStdout = task_processStdout task.processStderr = task_processSterr task.setCmdline(cmdline) job_manager.AddJob(job, onSuccess=self.finishedCB, onFail=self.failCB) self.jobs += 1 self.onLayout() else: self.session.open(Console, cmdlist=(cmdline,))
def createJob(self): self.job = Job("Image flashing job") self.job.afterEvent = "close" cwd = self["filelist"].getCurrentDirectory() md5verify(self.job, cwd, self.md5sum) writeNAND(self.job, [self.nfifile], self.box) self["key_blue"].text = "" self["key_yellow"].text = "" self["key_green"].text = "" job_manager.AddJob(self.job) self.session.openWithCallback(self.flashed, JobView, self.job, cancelable = False, backgroundable = False, afterEventChangeable = False)
def createJob(self): self.job = Job("Image flashing job") param = [self.nfifile] writeNAND(self.job, param, self.box) #writeNAND2(self.job,param) #writeNAND3(self.job,param) self.job.state_changed.append(self.update_job) self.job.end = 540 self.cwd = self["filelist"].getCurrentDirectory() self["job_progressbar"].range = self.job.end self.startJob()
def cut(self, name, inpath, outpath, inlen, outlen, clist): job = Job(_("Execute cuts")) CutTask(job, self.session, name, inpath, outpath, inlen, outlen, mcut_path, clist) JobManager.AddJob(job, onFail=self.noFail) self.close(True)
def deleteFiles(fileList, name): job = Job(_("Deleting files")) task = DeleteFolderTask(job, name) task.openFiles(fileList) JobManager.AddJob(job)