示例#1
0
def main(argv):
   inputFolder= ''
   try:
      opts, args = getopt.getopt(argv,"hi:o:",["ifolder="])
   except getopt.GetoptError:
      print 'test.py -i <inputFolder>'
      sys.exit(2)
   for opt, arg in opts:
      if opt == '-h':
         print 'test.py -i <inputFolder>'
         sys.exit()
      elif opt in ("-i", "--ifolder"):
         inputFolder = arg
   if inputFolder=='':
      print 'test.py -i <inputFolder>'
      sys.exe()
   print 'Input folder is "'+inputFolder+'"'
   for item in os.listdir(inputFolder):
      curFolder=os.path.join(inputFolder,item)
      curXML=os.path.join(curFolder,'meta/meta.xml')
      print('Looking at folder: '+curFolder)
      if os.path.isfile(curXML):
         print('Parsing XML file')
         e = xml.etree.ElementTree.parse(curXML).getroot()
         prodCode=e.find('product_code').text
         compCode=e.find('company_code').text
         name=e.find('longname_en').text.replace('\n', ' ').replace('\r', '').replace(':',' -').replace('BAYONETTA','Bayonetta').replace('THE LEGEND OF ZELDA','The Legend of Zelda -')
         newName=(name+' ['+prodCode[-4:]+compCode[-2:]+']')
         newFolder=os.path.join(inputFolder,newName)
         print('Renaming '+curFolder+' to '+newFolder)
         os.rename(curFolder,newFolder)
      else:
	     print 'Error '+curXML+' not found'
 def daemonize(self):
     # do the UNIX double-fork magic, see Stevens' "Advanced Programming in the UNIX Environment" for details (ISBN 0201563177)        
     # first fork
     try:
         self.pid = os.fork()
         if self.pid > 0:
             sys.exit(0)
     except OSError as e:
         print e
         sys.exe(1)
     
     # decouple from parent environment
     os.chdir("/")
     os.setsid()
     os.umask(0)        
     
     # second fork
     try:
         self.pid = os.fork()
         if self.pid > 0:
             sys.exit(0)
     except OSError as e:
         print e
         sys.exe(1)
         
     # close file descriptors
     sys.stdout.flush()
     sys.stderr.flush()
示例#3
0
        if o == "-s":
            dbSet += 1
            db = "sqlite://;schema=" + a + ";dbname=CONDBR2"
        if o == "-d":
            dbSet += 1
            db = a
        if o == "-l":
            levelOfDetail = int(a)
        if o == "-f":
            folderName = a

        pass

    if dbSet > 1:
        print "ERROR, inconsistent parameters! -d and -s are mutually exclusive"
        sys.exe(-1)

    # print run1,run2

    if tag is None:
        from LArConditionsCommon.getCurrentFolderTag import getCurrentFolderTag

        (current, next) = getCurrentFolderTag("COOLOFL_LAR/CONDBR2", "/LAR/BadChannelsOfl/EventVeto")
        if current is None:
            print "Failed to get CURRENT folder level tag!"
            sys.exit(-1)
        else:
            tag = current

    print "Reading event veto info from db %s, tag %s" % (db, tag),
    if run1 is not None: