def get_compile_msgs (request): log = request.REQUEST ['log'] logger.debug ("getting compilation messages: log=%s", log) process_username = ViewUtil.get_os_username () text = GraysonUtil.readFileAsString (log) text = unicode (text.replace ('\n', '<br/>')) if text else 'An unknown error occurred compiling the model.' return ViewUtil.get_text_response (text)
def get_flow_status (request): path = os.path.join (settings.GRAYSONWEB_WORKFLOW_ROOT, request.REQUEST ['path']) output = [] executor = Executor ({ 'flowPath' : path }) pegasus = os.environ ['PEGASUS_HOME'] executor.execute (command = "%s/bin/pegasus-status -l ${flowPath}" % pegasus, pipe = True, processor = lambda n : output.append (n)) return ViewUtil.get_text_response (''.join (output))
def get_flow_file (request): username = '' if 'addUser' in request.REQUEST: user = ViewUtil.get_user (request) username = user.username path = os.path.join (settings.GRAYSONWEB_WORKFLOW_ROOT, username, request.REQUEST ['path']) text = GraysonUtil.readFileAsString (path) if os.path.exists (path) else '' print ("path: %s", path) return ViewUtil.get_text_response (text)
def runs (request): flow = request.REQUEST ['flow'] response = ViewUtil.get_text_response ('fail') if flow: flows = get_flows (request) for f in flows: logger.error ('argh %s', f) print 'argh %s' % f name = f ['flow'] if flow == name: context = { 'flow' : f } response = ViewUtil.get_response (get_template_name ('runs.html'), request, context) break return response
def get_job_output (request): user = ViewUtil.get_user (request) workdir = request.REQUEST ['workdir'] workflow_id = request.REQUEST ['workflowid'] job_id = request.REQUEST ['jobid'] run_id = request.REQUEST ['runid'] if not run_id: run_id = "" if not workflow_id: workflow_id = "" logger.debug ("getting job output: workdir=%s, workflowid: %s, runid: %s, jobid: %s", workdir, workflow_id, run_id, job_id) process_username = ViewUtil.get_os_username () workdirPath = GraysonUtil.form_workdir_path (workdir, process_username, workflow_id, run_id) workdirPath = ViewUtil.form_workflow_path (user, workdirPath) logger.debug ("workdirPath: %s", workdirPath) text = "" if job_id.startswith ('/'): job_id = job_id [1:] concrete = os.path.join (workdirPath, job_id) logger.debug ('concrete: --- %s', concrete) if os.path.exists (concrete): logger.debug ("concrete --- : %s", concrete) text = GraysonUtil.readFile (concrete) else: logger.debug ("regex: --- : %s", concrete) workflow = GridWorkflow (workdirPath) outputs = workflow.getOutputFiles (subworkflows = [ workdirPath ], item = job_id) jobOutput = None if outputs and len (outputs) > 0: jobOutput = outputs [0] logger.debug ("got job output: %s \n for job_id: %s", jobOutput, job_id) if jobOutput: text = GraysonUtil.readFileAsString (jobOutput) return ViewUtil.get_text_response (text)
def getfile (request): # TODO: construct path dynamically and selectively for security purposes. return ViewUtil.get_text_response (GraysonUtil.readFile (request.REQUEST ['file']))