class CreateFile2Short(batch.BatchQ): _ = batch.WildCard() directory = batch.Property() command = batch.Property() terminal = batch.Pipeline(BashTerminal) create_dir = home_create_dir(directory,_) create_file = send_command(command)
class CreateFileShort(batch.BatchQ): _ = batch.WildCard() directory = batch.Property() command = batch.Property() terminal = batch.Controller(BashTerminal) create_dir = home_create_dir(directory, _) create_file = send_command(command, inherits=create_dir)
class CreateFile3(CreateFile2): server = batch.Property() username = batch.Property() password = batch.Property() # This overwrites our previous terminal and SSH is now used # instead. One of neat things about this method is that no instance # of Bash will be opened as the terminal is just overridden. # Still a new terminal is created for every instance of the object. terminal = batch.Pipeline(SSHTerminal, server,username,password)
class CreateFile1(batch.BatchQ): _ = batch.WildCard() directory = batch.Property() command = batch.Property() terminal = batch.Pipeline(BashTerminal) create_file = batch.Function() \ .home().chdir(_) \ .chdir(directory).send_command(command)
class CreateFile2(batch.BatchQ): _ = batch.WildCard() directory = batch.Property() command = batch.Property() terminal = batch.Pipeline(BashTerminal) create_dir = batch.Function(verbose=True) \ .home().chdir(_) \ .exists(directory).don(1).mkdir(directory, True) \ .chdir(directory) create_file = batch.Function(create_dir) \ .send_command(command)
class CreateFileAndDirectory(batch.BatchQ): _ = batch.WildCard() directory = batch.Property() command = batch.Property() terminal = batch.Controller(BashTerminal) create_dir = batch.Function() \ .home().chdir(_) \ .exists(directory).Qdon(1).mkdir(directory, True) \ .chdir(directory) create_file = batch.Function(create_dir) \ .send_command(command)
class NoHUP(batch.BatchQ): _r = batch.WildCard(reverse = True) _ = batch.WildCard() input_directory = batch.Property() working_directory = batch.Property() command = batch.Property() terminal = batch.Controller(BashTerminal) workdir = batch.Function() \ .home().chdir(_).exists(working_directory) \ .don(1).mkdir(working_directory).chdir(working_directory) _set_copy_dirs = batch.Function(workdir, verbose=False) \ .pjoin(input_directory, "/*").pjoin(working_directory, "/").cp(_r, _r) \ transfer_infiles = batch.Function(_set_copy_dirs , verbose=False) \ .cp(_r, _r).don(1).throw("Failed to transfer files.") transfer_outfiles = batch.Function(_set_copy_dirs, verbose=False) \ .cp(_, _).don(1).throw("Failed to transfer files.") startjob = batch.Function(workdir) \ .join("(", command, " > .bacthq.output & echo $! > .batchq.pid )").send_command(_) transfer_startjob = batch.Function(transfer_infiles) \ .call(startjob) getpid = batch.Function(workdir) \ .cat(".batchq.pid") isrunning = batch.Function(getpid) \ .isrunning(_) wasstarted = batch.Function(workdir) \ .exists(".batchq.output") log = batch.Function(wasstarted) \ .do(1).cat(".batchq.output") clean = batch.Function(wasstarted) \ .do(1).rm(".batchq.*", force = True)
class NoHUPStart(batch.BatchQ): _r = batch.WildCard(reverse = True) _ = batch.WildCard() input_directory = batch.Property() working_directory = batch.Property() command = batch.Property() terminal = batch.Controller(BashTerminal) workdir = batch.Function() \ .home().chdir(_).exists(working_directory) \ .don(1).mkdir(working_directory).chdir(working_directory) _set_copy_dirs = batch.Function(workdir, verbose=False) \ .pjoin(input_directory, "/*").pjoin(working_directory, "/").cp(_r, _r) \ transfer_infiles = batch.Function(_set_copy_dirs , verbose=False) .cp(_r, _r).don(1).throw("Failed to transfer files.")
class HelloParam(batch.BatchQ): message = batch.Property("Parameter") ctrl = batch.Controller(Pipeline) fnc = batch.Function().hello(message)
class CreateFileSSH(CreateFileShort): server = batch.Property() username = batch.Property() password = batch.Property() terminal = batch.Controller(SSHTerminal, server, username, password)
class Q3(batch.BatchQ): message = batch.Property("Hello property") pipe = batch.Controller(TestPipe2) fnc = batch.Function().hello_world(message)