-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_cra_interface.py
74 lines (53 loc) · 1.81 KB
/
run_cra_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
print "running..."
import sys
import os
"""
#Interface for running run_cra from php
"""
os.chdir('/n/www/kirschner.med.harvard.edu/docroot/corecop')
#sys.path.append('/n/www/kirschner.med.harvard.edu/docroot/corecop')
#sys.path.append('/n/www/kirschner.med.harvard.edu/docroot/corecop/aux')
import subprocess
"""
Toolbox for working with LOGS
"""
"""
CONTACT_EMAIL = "<contact-email>"
def add_line_to_log(log_file, line):
with open(log_file, "a") as lfil:
lfil.write(str(line) + "\n")
def srun(command, error, output, queue, timelim, wait):
full_command = ['/usr/bin/srun', '--partition='+str(queue), '--time='+str(timelim), '--output='+str(output), '--error='+str(error)]
full_command.extend(command.split())
full_command_str = " ".join(full_command)
print full_command_str
proc = subprocess.Popen(full_command)
if wait:
proc.wait()
return proc
class Job:
def __init__(self, job_string, lfil=None):
self.job_string = job_string
self.lfil = lfil
def run(self, error = 'error_test', output='output_test', queue='short', timelim = 60, wait = False, return_process = False):
if self.lfil is not None:
logtools.add_line_to_log(self.lfil, "<CMD:> [SRUN] " + self.job_string)
proc = srun(self.job_string, error, output, queue, timelim, wait)
if wait and self.lfil is not None:
logtools.add_line_to_log(self.lfil, "<CMD EXECUTED>")
if return_process:
return proc
"""
#print os.getcwd()
#import aux
#import aux.jobs
#import jobs
sys.stdout.flush()
sys.stderr.flush()
command_string = "python run_cra.py"
for a in sys.argv[1:]:
command_string += " " + a
print command_string + "\n"
#job = Job(command_string)
#job.run(wait=True, output="interface_test_out", error="interface_test_err")
print "done"