def spool(self, jobData, hostname=None, filename=None, owner=None, format=None, skipLogin=False, block=False): """Spool the given job data.""" hostname = hostname or osutil.getlocalhost() owner = owner or self.user or getpass.getuser() cwd = os.path.abspath(os.getcwd()).replace('\\', '/') filename = filename or "no filename specified" attrs = { "spvers": self.SPOOL_VERSION, "hnm": hostname, "jobOwner": owner, "jobFile": filename, "jobcwd": cwd } if block: attrs["blocking"] = "spool" contentType = "application/tractor-spool" if format == "JSON": contentType += "-json" headers = {"Content-Type": contentType} return self._transaction(self.SPOOL, attrs, payload=jobData, translation=None, headers=headers, skipLogin=skipLogin)
def spool(self, jobData, hostname=None, filename=None, owner=None, format=None, skipLogin=False, block=False): """Spool the given job data.""" hostname = hostname or osutil.getlocalhost() owner = owner or self.user or getpass.getuser() cwd = os.path.abspath(os.getcwd()).replace('\\', '/') filename = filename or "no filename specified" attrs = {"spvers": self.SPOOL_VERSION, "hnm": hostname, "jobOwner": owner, "jobFile": filename, "jobcwd": cwd} if block: attrs["blocking"] = "spool" contentType = "application/tractor-spool" if format == "JSON": contentType += "-json" headers = {"Content-Type": contentType} return self._transaction( self.SPOOL, attrs, payload=jobData, translation=None, headers=headers, skipLogin=skipLogin)
def engineClient(self): """Return an instance of EngineClient pointing to desired engine.""" # use the module's singleton EngineClient object engineClient = EngineClient.TheEngineClient # set non-default EngineClient parameters based on options params = {} if self.parent.opts.engine: params["hostname"], params["port"] = \ EngineClient.hostnamePortForEngine(self.parent.opts.engine) # set user/password parameters based on options or password file contents if self.parent.opts.user: params["user"] = self.parent.opts.user if self.parent.opts.password: params["password"] = self.parent.opts.password if self.parent.opts.password_file: params["user"], params["password"] = usernamePasswordForFilename(self.parent.opts.password_file) params["debug"] = self.parent.opts.debug params["newSession"] = self.parent.opts.login # set engine parameters engineClient.setParam(**params) # waited until now to set session filename as it can depend on evaluation of other params if self.parent.opts.noSaveSession: sessionFilename = None elif self.parent.opts.sessionFilename: sessionFilename = self.parent.opts.sessionFilename else: sessionFilename = EngineClient.sessionFilename( app="tq", engineHostname=engineClient.hostname, port=engineClient.port, clientHostname=osutil.getlocalhost(), user=params.get("user", engineClient.user)) if sessionFilename: engineClient.setParam(sessionFilename=sessionFilename) # prompt for password if necessary if engineClient.needsPassword(): password = getpass.getpass("Enter password for %s@%s:%d: " % (engineClient.user, engineClient.hostname, engineClient.port)) engineClient.setParam(password=password) return engineClient
def sessionFilename(self): return os.path.join( self.prefsDir(), "%s.%s" % (osutil.getlocalhost(), self.SESSION_FILENAME_BASE))
return except KeyboardInterrupt, errMsg: log(str(errMsg)) self.closemsg = 'Ctrl-C' self.shutdownServer() return # this is an exit point from mainloop() except: self.closemsg = 'exception' printTraceback() if self.notify: try: log('Notify %s of shutdown' % str(self.notify)) body = getTraceback() subject = '%s:%d died' % (getlocalhost(), self.servPort) sendmail(self.notify, body, subject=subject) except: pass self.shutdownServer() return # this is an exit point from mainloop() # time.sleep(1) # slow down errors to avoid filling drive # --------------------------------------------------------------------------- # --------------------------------------------------------------------------- def test(): server = GenericServer(port=2225)
def sessionFilename(self): return os.path.join(self.prefsDir(), "%s.%s" % (osutil.getlocalhost(), self.SESSION_FILENAME_BASE))