def npm(proj: str, buildPath: str, cfg: dict, log: Callable[[str], None]) -> bool: successful = True root = cfg.get("root", "") output = cfg.get("output", "") env = cfg.get("env", {}) cwd = getProjPath(proj) + "/" + root if output: try: log(">>> yarn install\n") rv = runSubprocess(["yarn", "install"], log, cwd=cwd, env=env) if rv != 0: raise Exception(rv) log(">>> yarn build\n") rv = runSubprocess(["yarn", "build"], log, cwd=cwd, env=env) if rv != 0: raise Exception(rv) log(">>> creating output archive...\n") shutil.make_archive(buildPath + "/output", "zip", root_dir=cwd, base_dir="./" + output) except Exception as e: successful = False log("yarn failed: " + str(e) + "\n") else: successful = False log("Missing 'output' in config") return successful
def updateGit(proj: str, ref: str, log: Callable[[str], None]): successful = True try: log(">>> git fetch --all\n") rv = runSubprocess(["git", "fetch", "--all"], log, cwd=getProjPath(proj)) if rv != 0: raise Exception(rv) log(">>> git reset --hard " + ref + "\n") rv = runSubprocess(["git", "reset", "--hard", ref], log, cwd=getProjPath(proj)) if rv != 0: raise Exception(rv) log(">>> git diff --stat " + ref + "~1 " + ref + "\n") rv = runSubprocess(["git", "diff", "--stat=100", ref + "~1", ref], log, cwd=getProjPath(proj)) if rv != 0: raise Exception(rv) except Exception as e: successful = False log("git operations failed: " + str(e) + "\n") return successful
def terminate(self): logging.debug('Terminating job: %s' % self.id) if self._attributes['state'] == 'dr': stdout, _ = utils.runSubprocess('qdel -f %s' % self.id) else: stdout, _ = utils.runSubprocess('qdel %s' % self.id) return stdout
def _getTokenStatus(cls): stdout, _ = utils.runSubprocess(cls.QLIC_COMMAND) licenseServerTypes = list() licenseServerTypes.extend(bi.LICENSE_SERVER_TYPES) # licenseServerTypes.extend(bi.PAMCRASH_LICENSE_SERVER_TYPES) # licenseServerTypes.extend(bi.NASTRAN_LICENSE_SERVER_TYPES) lines = stdout.splitlines() for licenseServerType in licenseServerTypes: # locate corresponding line for line in lines: if licenseServerType.QUEUE_CODE in line: break status = dict() for label, value in zip(cls.QLIC_COUMNS, line.split()): if label != 'resource': try: value = int(value) except ValueError as e: value = 0 status[label] = value cls.tokenStatus[licenseServerType] = status
def doCompile(proj: str, buildPath: str, cfg: dict, log: Callable[[str], None]) -> bool: successful = True copyFolderStructure(getProjPath(proj), buildPath) main = cfg.get("main", None) if main: cmd = [ "latexmk", "-interaction=nonstopmode", # "-gg", "-file-line-error", "-outdir=" + buildPath, "-pdf", main + ".tex" ] env = { "max_print_line": "100", "error_line": "254", "half_error_line": "238" } log(">>> " + (" ".join(cmd)) + "\n") rv = runSubprocess(cmd, log, cwd=getProjPath(proj), env=env) if rv != 0: log("latexmk failed: " + str(rv) + "\n") successful = False else: log("Missing 'main' in config") successful = False return successful
def _setDetailedAttributes(self): # prevent None in queue_name queueName = self._attributes['queue_name'] if queueName is None and 'soft_req_queue' in self._attributes: self._attributes['queue_name'] = self._attributes['soft_req_queue'] elif queueName is None: self._attributes['queue_name'] = self._attributes['hard_req_queue'] # try to replace missing host if '*' in self._attributes['hard_req_queue']: for key, value in self._attributes.iteritems(): if 'hard_request' in key and '.lan' in value: self._attributes['queue_name'] = self._attributes[ 'hard_req_queue'].replace('*', value) break self._attributes['queue_name_hr'] = '%s@%s' % ( self.licenceServer.NAME, self._attributes['queue_name'].split('@')[-1]) if self.isOutOfTheQueue: return stdout, _ = utils.runSubprocess('qstat -j %s' % self.id) lines = stdout.splitlines() for line in lines[1:]: parts = line.split(':') self._attributes[parts[0]] = ', '.join( [p.strip() for p in parts[1:]]) self._attributes['priority'] = self._attributes['JAT_prio'] # update tree item attributes when all attributes are obtained if self.treeItem is not None: self.treeItem.updateAttributes()
def _getOutOfQueueJobsStat(cls): ''' qhost: hostName = mb-u24.cax.lan qlic -w: pamcrash1 ext.opawar=[33] ext.opawar@mb-so3=33 stekly=[66] qxt3 bouda@mb-u15=50 ''' # check jobs running out of the queue stdout, _ = utils.runSubprocess('qlic -w') lines = stdout.splitlines() licenseServerQueueCodes = dict() for licenseServer in bi.LICENSE_SERVER_TYPES: licenseServerQueueCodes[licenseServer.QUEUE_CODE] = licenseServer outOfQueueJobsParams = list() for line in lines: parts = line.split() if len(parts) == 2 and parts[0]: licenseServerQueueCode = parts[0].strip() # skip different queues if licenseServerQueueCode not in licenseServerQueueCodes: continue # only running jobs if '@' in line: hostInfo = parts[-1].strip() hostInfoParts = hostInfo.split('@') userName = hostInfoParts[0] host = hostInfoParts[-1] hostParts = host.split('=') noOfTokens = int(hostParts[-1]) hostName = hostParts[0] + '.cax.lan' licenseServer = licenseServerQueueCodes[licenseServerQueueCode] # if hostName in cls._hostsStat: jobId = len(outOfQueueJobsParams) attributes = { 'JB_job_number': jobId, 'JB_name': RunningJob.OUT_OF_THE_QUEUE_NAME, 'JB_owner': userName, 'state': 'r', 'JB_submission_time': '-', 'queue_name': licenseServer.CODE + '@' + hostName, 'JAT_prio': '-', 'full_job_name': 'N/A', 'hard_request': noOfTokens, 'hard_req_queue': licenseServer.CODE + '@*', 'JAT_start_time': '-', 'slots': '-' } outOfQueueJobsParams.append(attributes) return outOfQueueJobsParams