예제 #1
0
def create_scripts(commands, subbase="submit", sleep='1m'):
    # Some interesting things we do here:
    # 1) cat the script for the logfile
    # 2) sleep to prevent overload
    # 3) Return the exit value of the command
    sleeps = linspace(0,parse_sleep(sleep),len(commands))
    for i, (command,sleep) in enumerate(zip(commands,sleeps)):
        filename = subbase+".%i"%(i+1)
        f = open(filename,'w')
        f.write('%s'%(os.path.basename(filename)).center(35,'#'))
        f.write('\n\n')
        f.write("cat $0;\n")
        f.write("sleep %i;\n"%(sleep))
        f.write(command)
        f.write("\nexit $?;")
        f.write("\n\n")
        f.write("Output follows...".center(35,'#'))
        f.write("\n\n")
        f.close()
예제 #2
0
def random_sleep(sleep):
    RANDOM=32767
    # convert to seconds
    sleep = parse_sleep(sleep)
    return int(RANDOM/sleep)