def delete (self, job_id, iter): if job_id: # delete file f = os.path.join (self.atdata, str(job_id)) if os.access(f, os.F_OK): os.unlink (f) execute = config.getAtrmbin()+ " " + str(job_id) commands.getoutput(execute)
def delete(self, job_id, iter): if job_id: # delete file f = os.path.join(self.atdata, str(job_id)) if os.access(f, os.F_OK): os.unlink(f) execute = config.getAtrmbin() + " " + str(job_id) commands.getoutput(execute)
def update (self, job_id, runat, command, title, output): #print "update" + str (job_id) + runat + command + title #remove old f = os.path.join (self.atdata, str (job_id)) if os.access (f, os.F_OK): os.unlink (f) execute = config.getAtrmbin()+ " " + str(job_id) commands.getoutput(execute) #add new tmpfile = tempfile.mkstemp () fd, path = tmpfile tmp = os.fdopen(fd, 'w') tmp.write (self.SCRIPT_DELIMITER + "\n") tmp.write (self.PREPEND_SCRIPT) if self.manual_poscorrect: tmp.write (self.POSIXLY_CORRECT_UNSET) display = "" if output > 0: display = os.getenv ('DISPLAY') tmp.write (self.DISPLAY % display ) tmp.write (command + "\n") tmp.close () if self.root == 1: if self.user != "root": #changes the ownership os.chown(path, self.uid, self.gid) execute = config.getSubin() + " " + self.user + " -c \"" + config.getAtbin() + " -f " + path + " " + runat + " && exit\"" else: execute = config.getAtbin() + " -f " + path + " " + runat else: execute = config.getAtbin() + " -f " + path + " " + runat p = Popen (execute, shell = True, env = self.at_env, stdin = PIPE, stdout = PIPE, stderr = PIPE, close_fds = True) (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr) err = child_stderr.readlines () job_id = 0 for line in err: t = self.parse (line, False) if t != False: job_id = t #print job_id desc = "" self.write_job_data (job_id, title, desc, output, display) os.unlink (path)
def update(self, job_id, runat, command, title, output): #print "update" + str (job_id) + runat + command + title #remove old f = os.path.join(self.atdata, str(job_id)) if os.access(f, os.F_OK): os.unlink(f) execute = config.getAtrmbin() + " " + str(job_id) commands.getoutput(execute) #add new tmpfile = tempfile.mkstemp() fd, path = tmpfile tmp = os.fdopen(fd, 'w') tmp.write(self.SCRIPT_DELIMITER + "\n") tmp.write(self.PREPEND_SCRIPT) if self.manual_poscorrect: tmp.write(self.POSIXLY_CORRECT_UNSET) display = "" if output > 0: display = os.getenv('DISPLAY') tmp.write(self.DISPLAY % display) tmp.write(command + "\n") tmp.close() if self.root == 1: if self.user != "root": #changes the ownership os.chown(path, self.uid, self.gid) execute = config.getSubin( ) + " " + self.user + " -c \"" + config.getAtbin( ) + " -f " + path + " " + runat + " && exit\"" else: execute = config.getAtbin() + " -f " + path + " " + runat else: execute = config.getAtbin() + " -f " + path + " " + runat p = Popen(execute, shell=True, env=self.at_env, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr) err = child_stderr.readlines() job_id = 0 for line in err: t = self.parse(line, False) if t != False: job_id = t #print job_id desc = "" self.write_job_data(job_id, title, desc, output, display) os.unlink(path)