ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/remove
(Generate patch)

Comparing UserCode/MitProd/Processing/bin/remove (file contents):
Revision 1.3 by paus, Mon Sep 19 21:45:41 2011 UTC vs.
Revision 1.4 by paus, Thu Oct 20 23:16:23 2011 UTC

# Line 4 | Line 4
4   #
5   # Author: C.Paus                                                                      (May 06, 2010)
6   #---------------------------------------------------------------------------------------------------
7 < import os,sys,getopt,re
7 > import os,sys,getopt,re,srm
8  
9   def debugPrint(text):
10 <    if debug == 1:
10 >    if debug:
11          print ' DEBUG: ' + text
12  
13   def clean(file):
# Line 25 | Line 25 | def exists(target):
25          cmd = 'rfdir ' + target
26      elif re.search('/pnfs/cmsaf.mit.edu/',target):
27          debugPrint(' Identified a tier-2 directory: ' + target)
28 <        cmd = 'ssh paus@cgate.mit.edu ls -1 ' + target + '\>\& /dev/null'
28 >        cmd = 'ssh paus@cgate.mit.edu ls -1 ' + target + ' \>\& /dev/null'
29 >    elif re.search('/mnt/hadoop/cms/store',target):
30 >        debugPrint(' Identified a tier-2 hadoop directory: ' + target)
31 >        target = srm.convertToUrl(target,debug)
32 >        cmd = 'srmls ' + target + ' >& /dev/null'
33      else:
34          debugPrint(' Identified a normal directory: ' + target)
35          cmd = 'ls -1 ' + target + '>& /dev/null'
36              
37      status = os.system(cmd)
38 <    debugPrint(' Status: %d' % status)
38 >    debugPrint(' Status: %d (on %s)' %(status,cmd))
39  
40      return (status == 0)
41  
# Line 42 | Line 46 | def remove(source):
46      elif re.search('/pnfs/cmsaf.mit.edu/',source):
47          debugPrint(' Identified tier-2 file')
48          cmd = 'ssh paus@cgate.mit.edu rm -rf ' + source
49 +    elif re.search('/mnt/hadoop/cms/store/user/paus',source):
50 +        debugPrint(' Identified a tier-2 hadoop directory: ' + source)
51 +        source = srm.convertToUrl(source,debug)
52 +        cmd = 'srmrm ' + source + ' >& /dev/null'
53      else:
54          debugPrint(' Identified a normal directory')
55          cmd = 'rm -rf ' + source
# Line 51 | Line 59 | def remove(source):
59      status = 0
60      if exe == 1:
61          status = os.system(cmd)
62 +        if status != 0:
63 +            print ' ERROR: remove returned error %d (on %s)'%(status,cmd)
64  
65      return status
66  
# Line 76 | Line 86 | except getopt.GetoptError, ex:
86   # Get all parameters for the production
87   # --------------------------------------------------------------------------------------------------
88   # Set defaults for each option
89 < debug = 0
89 > debug = False
90   exe   = 0
91  
92   # Read new values from the command line
# Line 86 | Line 96 | for opt, arg in opts:
96          print usage
97          sys.exit(0)
98      elif opt == '--debug':
99 <        debug = 1
99 >        debug = True
100      elif opt == '--exe':
101          exe   = 1
102  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines