1
2
3
4 """
5 Interface for configuring pre/post icetray scripts
6
7 copyright (c) 2005 the icecube collaboration
8
9 @version: $Revision: $
10 @date: $Date: $
11 @author: Juan Carlos Diaz Velez <juancarlos@icecube.wisc.edu>
12 """
13
14 import os
15 import re
16 import sys
17 import math
18 import dircache
19 import time
20 import string
21 import shutil
22 import cPickle
23 from ipmodule import IPBaseClass
24 import logging
25
27 """
28 This class provides an interface for preprocessing files in iceprod
29 """
30
36
37
39 if not IPBaseClass.Execute(self,stats): return 0
40 infile = self.GetParameter('infile')
41 outfile = self.GetParameter('outfile')
42 cmd = "mv %s %s" % (infile,outfile)
43 retval = os.system(cmd)
44 if retval == 0:
45 return retval
46 else:
47 self.logger.error("Failed to execute command '%s'" % cmd)
48 raise Exception, "Failed to execute command '%s'" % cmd
49
50
52 """
53 This class provides functionality for renaming multiple files using Bash
54 substitutions.
55 """
56
58 IPBaseClass.__init__(self)
59 self.AddParameter('inpattern','Pattern to match against file names when checking for files to rename','')
60 self.AddParameter('outpattern','Bash substitution expression to be applied to filenames when output','')
61 self.logger = logging.getLogger('iceprod::RenameMultipleFiles')
62
63
65 if not IPBaseClass.Execute(self,stats): return 0
66 inpattern = self.GetParameter('inpattern')
67 outpattern = self.GetParameter('outpattern')
68 cmd = "for i in %s; do mv $i ${i/%s}; done" % (inpattern, outpattern)
69 retval = os.system(cmd)
70 if retval == 0:
71 return retval
72 else:
73 msg = "Failed to execute command '%s'" % cmd
74 self.logger.error(msg)
75 raise Exception, msg
76
77
79 """
80 This class provides an interface for preprocessing files in iceprod
81 """
82
88
89
91 if not IPBaseClass.Execute(self,stats): return 0
92 filelist = self.GetParameter('filelist')
93 retval = 0
94 cmd = ''
95 for file in filelist:
96 cmd = "rm -f %s" % file
97 retval += os.system(cmd)
98 if retval == 0:
99 return retval
100 else:
101 self.logger.error("Failed to execute command '%s'" % cmd)
102 raise Exception, "Failed to execute command '%s'" % cmd
103
104
106 """
107 This class provides an interface for preprocessing files in iceprod
108 """
109
115
116
118 if not IPBaseClass.Execute(self,stats): return 0
119 filelist = self.GetParameter('filelist')
120 retval = 0
121 cmd = ''
122 for file in filelist:
123 dir = os.path.dirname(file)
124 cmd = "tar"
125 if os.path.isdir(dir):
126 cmd += " -C%s " % dir
127 if not os.path.exists(tar):
128 cmd += " -cf"
129 else:
130 cmd += " -uf"
131 cmd += " %s %s" %(tar,os.path.basename(file))
132 self.logger.debug(cmd)
133 retval += os.system(cmd)
134 if retval == 0:
135 return retval
136 else:
137 self.logger.error("Failed to execute command '%s'" % cmd)
138 raise Exception, "Failed to execute command '%s'" % cmd
139
140
142 """
143 This class provides an interface for preprocessing files in iceprod
144 """
145
147 IPBaseClass.__init__(self)
148 self.AddParameter('inputfilelist','The names of the files you want to merge',[])
149 self.AddParameter('outputfile','Name of output tarball',"summary.xml")
150 self.logger = logging.getLogger('iceprod::SummaryMerger')
151
152
172