69 from __future__
import absolute_import
70 from __future__
import print_function
80 from project_modules.ifdherror
import IFDHError
102 for var
in (
'X509_USER_CERT',
'X509_USER_KEY'):
103 if var
in os.environ:
104 save_vars[var] = os.environ[var]
109 cmd = [
'ifdh',
'cp', source, destination]
110 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
113 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
115 thread.join(timeout=31000000)
116 if thread.is_alive():
117 print(
'Terminating subprocess.')
124 for var
in list(save_vars.keys()):
125 os.environ[var] = save_vars[var]
126 raise IFDHError(cmd, rc, jobout, joberr)
130 for var
in list(save_vars.keys()):
131 os.environ[var] = save_vars[var]
147 for var
in (
'X509_USER_CERT',
'X509_USER_KEY'):
148 if var
in os.environ:
149 save_vars[var] = os.environ[var]
154 cmd = [
'ifdh',
'ls', path,
'%d' % depth]
155 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
158 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
160 thread.join(timeout=600)
161 if thread.is_alive():
162 print(
'Terminating subprocess.')
169 for var
in list(save_vars.keys()):
170 os.environ[var] = save_vars[var]
171 raise IFDHError(cmd, rc, jobout, joberr)
175 for var
in list(save_vars.keys()):
176 os.environ[var] = save_vars[var]
180 return jobout.splitlines()
196 for var
in (
'X509_USER_CERT',
'X509_USER_KEY'):
197 if var
in os.environ:
198 save_vars[var] = os.environ[var]
203 cmd = [
'ifdh',
'll', path,
'%d' % depth]
204 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
207 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
209 thread.join(timeout=60)
210 if thread.is_alive():
211 print(
'Terminating subprocess.')
218 for var
in list(save_vars.keys()):
219 os.environ[var] = save_vars[var]
220 raise IFDHError(cmd, rc, jobout, joberr)
224 for var
in list(save_vars.keys()):
225 os.environ[var] = save_vars[var]
229 return jobout.splitlines()
244 for var
in (
'X509_USER_CERT',
'X509_USER_KEY'):
245 if var
in os.environ:
246 save_vars[var] = os.environ[var]
251 cmd = [
'ifdh',
'mkdir', path]
252 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
255 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
257 thread.join(timeout=60)
258 if thread.is_alive():
259 print(
'Terminating subprocess.')
266 for var
in list(save_vars.keys()):
267 os.environ[var] = save_vars[var]
268 raise IFDHError(cmd, rc, jobout, joberr)
272 for var
in list(save_vars.keys()):
273 os.environ[var] = save_vars[var]
292 for var
in (
'X509_USER_CERT',
'X509_USER_KEY'):
293 if var
in os.environ:
294 save_vars[var] = os.environ[var]
299 cmd = [
'ifdh',
'rmdir', path]
300 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
303 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
305 thread.join(timeout=60)
306 if thread.is_alive():
307 print(
'Terminating subprocess.')
314 for var
in list(save_vars.keys()):
315 os.environ[var] = save_vars[var]
316 raise IFDHError(cmd, rc, jobout, joberr)
320 for var
in list(save_vars.keys()):
321 os.environ[var] = save_vars[var]
340 for var
in (
'X509_USER_CERT',
'X509_USER_KEY'):
341 if var
in os.environ:
342 save_vars[var] = os.environ[var]
347 cmd = [
'ifdh',
'chmod',
'%o' % mode, path]
348 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
351 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
353 thread.join(timeout=60)
354 if thread.is_alive():
355 print(
'Terminating subprocess.')
362 print(
'Warning: ifdh chmod failed for path %s' % path)
366 for var
in list(save_vars.keys()):
367 os.environ[var] = save_vars[var]
386 for var
in (
'X509_USER_CERT',
'X509_USER_KEY'):
387 if var
in os.environ:
388 save_vars[var] = os.environ[var]
393 cmd = [
'ifdh',
'mv', src, dest]
394 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
397 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
399 thread.join(timeout=60)
400 if thread.is_alive():
401 print(
'Terminating subprocess.')
408 for var
in list(save_vars.keys()):
409 os.environ[var] = save_vars[var]
410 raise IFDHError(cmd, rc, jobout, joberr)
414 for var
in list(save_vars.keys()):
415 os.environ[var] = save_vars[var]
434 for var
in (
'X509_USER_CERT',
'X509_USER_KEY'):
435 if var
in os.environ:
436 save_vars[var] = os.environ[var]
441 cmd = [
'ifdh',
'rm', path]
442 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
445 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
447 thread.join(timeout=60)
448 if thread.is_alive():
449 print(
'Terminating subprocess.')
456 for var
in list(save_vars.keys()):
457 os.environ[var] = save_vars[var]
458 raise IFDHError(cmd, rc, jobout, joberr)
462 for var
in list(save_vars.keys()):
463 os.environ[var] = save_vars[var]
474 cmd = [
'cp', source, destination]
478 buffer_pid = os.fork()
484 jobinfo = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
487 thread = threading.Thread(target=wait_for_subprocess, args=[jobinfo, q])
489 thread.join(timeout=600)
490 if thread.is_alive():
496 print(
'Terminating subprocess.')
514 buffer_result = os.waitpid(buffer_pid, 0)
515 rc = buffer_result[1]/256
517 raise IFDHError(cmd, rc,
'',
'')
537 jobout, joberr = jobinfo.communicate(input)
550 ok = subprocess.call([
'klist',
'-s'], stdout=-1, stderr=-1)
552 raise RuntimeError(
'Please get a kerberos ticket.')
573 subprocess.check_call([
'kx509'], stdout=-1, stderr=-1)
599 if 'X509_USER_CERT' in os.environ
and 'X509_USER_KEY' in os.environ:
600 cmd=[
'voms-proxy-init',
602 '-cert', os.environ[
'X509_USER_CERT'],
603 '-key', os.environ[
'X509_USER_KEY'],
606 subprocess.check_call(cmd, stdout=-1, stderr=-1)
612 cmd=[
'voms-proxy-init',
618 subprocess.check_call(cmd, stdout=-1, stderr=-1)
634 if 'X509_USER_PROXY' in os.environ:
635 subprocess.check_call([
'voms-proxy-info',
636 '-file', os.environ[
'X509_USER_PROXY'],
637 '-exists'], stdout=-1, stderr=-1)
638 elif 'X509_USER_CERT' in os.environ
and 'X509_USER_KEY' in os.environ:
639 subprocess.check_call([
'voms-proxy-info',
640 '-file', os.environ[
'X509_USER_CERT'],
641 '-exists'], stdout=-1, stderr=-1)
643 subprocess.check_call([
'voms-proxy-info',
'-exists'], stdout=-1, stderr=-1)
648 x509_path =
convert_str(subprocess.check_output([
'voms-proxy-info',
'-path'], stderr=-1))
649 os.environ[
'X509_USER_PROXY'] = x509_path.strip()
664 if 'X509_USER_PROXY' in os.environ:
665 subprocess.check_call([
'voms-proxy-info',
666 '-file', os.environ[
'X509_USER_PROXY'],
667 '-exists'], stdout=-1, stderr=-1)
668 elif 'X509_USER_CERT' in os.environ
and 'X509_USER_KEY' in os.environ:
669 subprocess.check_call([
'voms-proxy-info',
670 '-file', os.environ[
'X509_USER_CERT'],
671 '-exists'], stdout=-1, stderr=-1)
673 subprocess.check_call([
'voms-proxy-info',
'-exists'], stdout=-1, stderr=-1)
676 raise RuntimeError(
'Please get a kca certificate.')
686 subprocess.check_call([
'voms-proxy-info',
'-exists'], stdout=-1, stderr=-1)
687 subprocess.check_call([
'voms-proxy-info',
'-exists',
'-acissuer'], stdout=-1, stderr=-1)
701 subprocess.check_call([
'voms-proxy-info',
'-exists'], stdout=-1, stderr=-1)
702 subprocess.check_call([
'voms-proxy-info',
'-exists',
'-acissuer'], stdout=-1, stderr=-1)
705 raise RuntimeError(
'Please get a grid proxy.')
717 jobinfo = subprocess.Popen([
'which',
'jobsub_submit'],
718 stdout=subprocess.PIPE,
719 stderr=subprocess.PIPE)
720 jobout, joberr = jobinfo.communicate()
723 jobsub_path = jobout.splitlines()[0].
strip()
724 if jobsub_path !=
'':
730 print(
'Please set up jobsub_client')
738 return "fndca1.fnal.gov"
745 if path.startswith(
'/pnfs/')
and not path.startswith(
'/pnfs/fnal.gov/usr/'):
746 return '/pnfs/fnal.gov/usr/' + path[6:]
759 if path.startswith(
'/pnfs/'):
769 if path.startswith(
'/pnfs/'):
779 if path.startswith(
'/pnfs/'):
780 return 'srm://fndca1.fnal.gov:8443/srm/managerv2?SFN=/pnfs/fnal.gov/usr/' + path[6:]
790 return '%sgpvm01.fnal.gov' % os.environ[
'EXPERIMENT']
802 if mode_str[0] ==
'b':
804 elif mode_str[0] ==
'c':
806 elif mode_str[0] ==
'd':
808 elif mode_str[0] ==
'l':
810 elif mode_str[0] ==
'p':
812 elif mode_str[0] ==
's':
813 mode += stat.S_IFSOCK
814 elif mode_str[0] ==
'-':
821 if mode_str[1] ==
'r':
823 if mode_str[2] ==
'w':
825 if mode_str[3] ==
'x':
827 elif mode_str[3] ==
's':
830 elif mode_str[3] ==
'S':
835 if mode_str[4] ==
'r':
837 if mode_str[5] ==
'w':
839 if mode_str[6] ==
'x':
841 elif mode_str[6] ==
's':
844 elif mode_str[6] ==
'S':
849 if mode_str[7] ==
'r':
851 if mode_str[8] ==
'w':
853 if mode_str[9] ==
'x':
855 elif mode_str[9] ==
't':
858 elif mode_str[9] ==
'T':
879 for ev
in (
'EXPERIMENT',
'SAM_EXPERIMENT'):
885 hostname = socket.gethostname()
886 n = hostname.find(
'gpvm')
891 raise RuntimeError(
'Unable to determine experiment.')
907 if 'ROLE' in os.environ:
908 result = os.environ[
'ROLE']
914 user = getpass.getuser()
916 result =
'Production'
932 raise RuntimeError(
'Function get_setup_script_path not implemented.')
939 raise RuntimeError(
'Function dimensions not implemented.')
953 if stage.ana_data_stream !=
None and len(stage.ana_data_stream) > 0:
954 dim1 =
'( data_stream %s and %s )' % (stage.ana_data_stream[index], dim)
957 if stage.data_stream !=
None and len(stage.data_stream) > 0:
958 dim1 =
'( data_stream %s and %s )' % (stage.data_stream[index], dim)
983 return 'fnal-dcache:'
991 raise RuntimeError(
'Function get_dropbox not implemented.')
1027 if 'X509_USER_PROXY' in os.environ:
1028 subject =
convert_str(subprocess.check_output([
'voms-proxy-info',
1029 '-file', os.environ[
'X509_USER_PROXY'],
1030 '-subject'], stderr=-1))
1031 elif 'X509_USER_CERT' in os.environ
and 'X509_USER_KEY' in os.environ:
1032 subject =
convert_str(subprocess.check_output([
'voms-proxy-info',
1033 '-file', os.environ[
'X509_USER_CERT'],
1034 '-subject'], stderr=-1))
1036 subject =
convert_str(subprocess.check_output([
'voms-proxy-info',
'-subject'],
1043 n = subject.rfind(
'/CN=')
1046 if cn.strip().isdigit():
1048 subject = subject[:n]
1077 raise RuntimeError(
'Unable to determine authenticated user.')
1102 for pid
in os.listdir(
'/proc'):
1103 if pid.isdigit()
and int(pid) != os.getpid():
1104 procfile = os.path.join(
'/proc', pid)
1106 pstat = os.stat(procfile)
1110 if pstat.st_uid == os.getuid():
1114 cmdfile = os.path.join(
'/proc', pid,
'cmdline')
1115 cmd =
open(cmdfile).read()
1116 words = cmd.split(
'\0')
1132 if word.endswith(
'project.py'):
1137 if xml == 1
and word == xmlname:
1139 elif stage == 1
and word == stagename:
1149 elif word ==
'--stage':
1151 elif word ==
'--submit':
1153 elif word ==
'--makeup':
1156 if project != 0
and submit+makeup != 0
and xmlmatch != 0
and stagematch != 0:
1237 from experiment_utilities
import *
do one_file $F done echo for F in find $TOP name CMakeLists txt print
def dimensions_datastream
def get_setup_script_path
open(RACETRACK) or die("Could not open file $RACETRACK for writing")