1 """
2 Sandbox functions used in the job wrapper script on the worker node.
3 The text of this module is sourced into the job wrapper script.
4 It therefore may use ###TAGS### which are expanded in the wrapper script.
5 """
6
7 INPUT_TARBALL_NAME = '_input_sandbox.tgz'
8 OUTPUT_TARBALL_NAME = '_output_sandbox.tgz'
9 PYTHON_DIR = '_python'
10
27
28
29
30
31
32
33
34
35
36
37
38
39
40
52
53
55 """Get all files matching output patterns except filtered with filter and
56 write them to the destination directory.
57 This function is called by wrapper script at the run time.
58 Arguments:
59 'output_patterns': list of filenames or patterns.
60 'filter': function to filter files (return True to except)
61 'dest_dir': destination directory for output files
62 """
63
64 from Ganga.Utility.files import multi_glob,recursive_copy
65
66 for f in multi_glob(output_patterns,filter):
67 try:
68 recursive_copy(f,dest_dir)
69 except Exception,x:
70 print "ERROR: (job ###JOBID### createOutput )",x
71
72
74 """Get all files matching output patterns except filtered with filter and
75 put them to the Sandbox tarball in destination directory.
76 This function is called by wrapper script at the run time.
77 Arguments:
78 'output_patterns': list of filenames or patterns.
79 'filter': function to filter files (return True to except)
80 'dest_dir': destination directory for tarball
81 """
82
83 tgzfile = os.path.join(dest_dir,OUTPUT_TARBALL_NAME)
84
85 from Ganga.Utility.files import multi_glob,recursive_copy
86 outputlist = multi_glob(output_patterns,filter)
87
88
89
90
91
92 if len(outputlist) > 0:
93 if os.system("tar czf %s %s"%(tgzfile," ".join(outputlist))) != 0:
94 print "ERROR: (job ###JOBID### createPackedOutput ) can't creat tarball"
95
96
97
98
99
100
101
102
103