Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching to python3 and removing some old/unfinished bits #24

Open
wants to merge 8 commits into
base: htcondor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions DatabaseExample

This file was deleted.

124 changes: 65 additions & 59 deletions Inf_Classes.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env python

import xml.dom.minidom as minidom
from __future__ import print_function
from copy import deepcopy
from glob import glob

import os

class JobConfig(object):
def __init__(self,node):
def __init__(self, node):
for item in node.attributes.items():
if(item[0]=='JobName'): self.JobName = item[1]
if(item[0]=='OutputLevel'): self.OutputLevel = item[1]
if item[0] == "JobName":
self.JobName = item[1]
if item[0] == "OutputLevel":
self.OutputLevel = item[1]
self.Libs = []
for child in node.getElementsByTagName('Library'):
for lib in child.attributes.items():
Expand All @@ -23,117 +22,124 @@ def __init__(self,node):
for item in node.getElementsByTagName('Cycle'):
self.Job_Cylce.append(Cycle(item))


class Cycle(object):
def __init__(self,node):
def __init__(self, node):
self.cacheData = 0
for item in node.attributes.items():
if(item[0]=='Name'): self.Cyclename = item[1]
#if(item[0]=='RunMode'): self.RunMode = item[1]
#if(item[0]=='ProofServer'): self.ProofServer = item[1]
#if(item[0]=='ProofWorkDir'): self.ProofWorkDir = item[1]
if(item[0]=='OutputDirectory'): self.OutputDirectory = item[1]
if(item[0]=='PostFix'): self.PostFix = item[1]
if(item[0]=='TargetLumi'): self.TargetLumi = item[1]

self.Cycle_InputData =[]
for item in node.getElementsByTagName('InputData'):
self.Cycle_InputData.append(InputData(item,self.cacheData))
if self.Cycle_InputData[-1].Cacheable=='True': self.cacheData = True
if item[0] == "Name":
self.Cyclename = item[1]
if item[0] == "OutputDirectory":
self.OutputDirectory = item[1]
if item[0] == "PostFix":
self.PostFix = item[1]
if item[0] == "TargetLumi":
self.TargetLumi = item[1]

self.Cycle_InputData = []
for item in node.getElementsByTagName("InputData"):
self.Cycle_InputData.append(InputData(item, self.cacheData))
if self.Cycle_InputData[-1].Cacheable == "True":
self.cacheData = True

self.Cycle_UserConf = []
for child in node.getElementsByTagName('UserConfig'):
for item in child.getElementsByTagName('Item'):
name = None
name = None
value = None
for attr in item.attributes.items():
if(attr[0]=='Name'): name=attr[1]
if(attr[0]=='Value'): value=attr[1]
self.Cycle_UserConf.append(UserConfig(name,value))
if attr[0] == "Name":
name = attr[1]
if attr[0] == "Value":
value = attr[1]
self.Cycle_UserConf.append(UserConfig(name, value))

#print self.Cycle_UserConf
UC_sframe_weight = filter(lambda uc: uc.Name == 'use_sframe_weight', self.Cycle_UserConf)
UC_sframe_weight = list(filter(lambda uc: uc.Name == 'use_sframe_weight', self.Cycle_UserConf))
self.usingSFrameWeight = not (UC_sframe_weight and UC_sframe_weight[0].Value == 'false')


class InputData(object):
def __init__(self,node,cacheMe):
self.NEventsSkip = 0
def __init__(self, node, cacheMe):
self.NEventsSkip = 0
for item in node.attributes.items():
if ' ' in item[1]:
print 'Space in',item[0],'=',item[1]
print 'Aborting since this is most probably wrong'
print("Space in", item[0], "=", item[1])
print("Aborting since this is most probably wrong")
exit(0)
if(item[0]=='Lumi'): self.Lumi = item[1]
if(item[0]=='NEventsMax'): self.NEventsMax = item[1]
if(item[0]=='Type'): self.Type = item[1]
if(item[0]=='Version'): self.Version = item[1]
if(item[0]=='Cacheable'):
if item[1]=='True' and not cacheMe:
res = raw_input('Cacheable is set to True. Are you sure you want to continue? Y/[N] ')
if item[0] == "Lumi":
self.Lumi = item[1]
if item[0] == "NEventsMax":
self.NEventsMax = item[1]
if item[0] == "Type":
self.Type = item[1]
if item[0] == "Version":
self.Version = item[1]
if item[0] == "Cacheable":
if item[1] == "True" and not cacheMe:
res = input("Cacheable is set to True. Are you sure you want to continue? Y/[N] ")
if res.lower() != 'y':
exit(0)
else: cacheMe = True
else:
cacheMe = True
self.Cacheable = item[1]
if(item[0]=='NEventsSkip'): self.NEventsSkip = item[1]
#print self.Version
self.io_list =InputList()
if item[0] == "NEventsSkip":
self.NEventsSkip = item[1]
self.io_list = InputList()
for item in node.childNodes:
#print item.nodeValue
if not item.nodeType == 3:
help_list = []
#print item.nodeName
help_list.append(item.nodeName)
for entry in item.attributes.items():
for y in entry:
help_list.append(y)
if item.nodeName == "In":
self.io_list.FileInfoList.append(help_list)
elif item.nodeName == "InputTree":
if len(self.io_list.InputTree)==0:
self.io_list.InputTree=help_list
if len(self.io_list.InputTree) == 0:
self.io_list.InputTree = help_list
elif self.io_list.InputTree != help_list:
print 'not using the same InputTree. Prefere to exit'
print("not using the same InputTree. Prefere to exit")
exit(0)
else:
self.io_list.other.append(help_list)



expanded_list = []
for help_list in self.io_list.FileInfoList:
expanded_list += _expand_help_list_filenames(help_list)
self.io_list.FileInfoList = expanded_list

def split_NEvents(self,NEventsBreak,LastBreak):
def split_NEvents(self, NEventsBreak, LastBreak):
self.NEventsBreak = NEventsBreak
self.LastBreak = LastBreak
self.LastBreak = LastBreak


class UserConfig(object):
def __init__(self,Name,Value):
def __init__(self, Name, Value):
self.Name = Name
self.Value = Value


class InputList(object):
def __init__(self):
self.FileInfoList =[]
self.FileInfoList = []
self.InputTree = []
self.other =[]
self.other = []


def _expand_help_list_filenames(help_list):
filenames = filter(lambda s: '*' in s, help_list)
filenames = list(filter(lambda s: '*' in s, help_list))
if not filenames:
return [help_list]
assert(len(filenames) == 1)
assert len(filenames) == 1
pattern = filenames[0]
real_filenames = glob(pattern)
if not real_filenames:
raise RuntimeError('No files found for pattern: %s'%pattern)
raise RuntimeError("No files found for pattern: %s" % pattern)
new_help_list = []
for new_file in real_filenames:
new_list = deepcopy(help_list)
new_help_list.append(new_list)
for i in xrange(len(new_list)):
for i in range(len(new_list)):
if new_list[i] == pattern:
new_list[i] = new_file
return new_help_list
Loading