Ejemplo n.º 1
0
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'
Ejemplo n.º 2
0
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,
    )
Ejemplo n.º 3
0
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,
    )
Ejemplo n.º 4
0
 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()
Ejemplo n.º 5
0
 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()