def run_script(script, only_tell=False, **kwargs): #if kwargs: # script = re.sub( # '|'.join(re.escape(name) for name in kwargs), # lambda match: R_literal(kwargs[match.group(0)]), # script # ) script = ''.join([ key + ' <- ' + R_literal(kwargs[key]) + '\n' for key in kwargs ]) + script if only_tell: print script return process = legion.subprocess_Popen( ['Rscript', '-'], bufsize=1<<24, stdin=subprocess.PIPE, close_fds=True, ) process.stdin.write(script) process.stdin.close() assert 0 == process.wait(), 'R failed'
def run(args, stdin=None, stdout=subprocess.PIPE, stderr=None): return legion.subprocess_Popen( args, bufsize=1 << 24, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, )
def run(args, stdin=None, stdout=subprocess.PIPE, stderr=None): return legion.subprocess_Popen( args, bufsize=1<<24, stdin=stdin, stdout=stdout, stderr=stderr, close_fds=True, )
def __init__(self, filename, command): self.command = command f_out = open(filename, 'wb') self.process = legion.subprocess_Popen( command, stdin=subprocess.PIPE, stdout=f_out, # bufsize = 1<<24, close_fds=True) f_out.close()
def __init__(self, filename, command): self.command = command f_out = open(filename,'wb') self.process = legion.subprocess_Popen( command, stdin = subprocess.PIPE, stdout = f_out, # bufsize = 1<<24, close_fds = True ) f_out.close()