Page MenuHomec4science

mvRuns.py
No OneTemporary

File Metadata

Created
Thu, Sep 12, 05:38

mvRuns.py

#!/usr/bin/env python
import BlackDynamite as BD
import os, sys, stat
import subprocess
import getopt
import socket
import datetime
################################################################
################################################################
parser = BD.BDParser()
parser.register_params(group="mvRuns",
params={"path":str},
mandatory={'path':True},
help={"path":"Path to the local machine where to store the run outputs"})
params = parser.parseBDParameters()
mybase = BD.Base(**params)
runSelector = BD.RunSelector(mybase)
run_list = runSelector.selectRuns(params,params,quiet=True)
for r,j in run_list:
print 'mv run,job:',r.id,j.id
url_src = r['machine_name'] + ':' + r['run_path']
if url_src[-1] == '/': url_src = url_src[:-1]
url_dest = params['path']
rsync_command = 'rsync --remove-source-files -auP {0} {1}'.format(url_src,url_dest)
print rsync_command
import subprocess,socket
if params['truerun'] == True:
ret = subprocess.call(rsync_command,shell=True)
else: ret = True
if ret: continue
f,p = os.path.split(r['run_path'])
print f,p
while p == '':
f,p = os.path.split(f)
# print '"',f,'" "',p,'"'
r['run_path'] = os.path.join(url_dest,p.strip())
r['machine_name'] = socket.gethostname()
r.update()
if params['truerun'] == True:
mybase.commit()

Event Timeline