Inheritance diagram for python::GBSManager::GBSManager:
Public Member Functions | |
def | __init__ |
def | WriteFamily |
def | GetType |
def | __repr__ |
def | GetTask |
def | ListModels |
def | ListTasks |
def | GetSchemaVersion |
def | AddTask |
def | __init__ |
def | GetName |
def | GetModel |
def | GetParent |
def | GetStoreLocation |
def | MakeChildDirectory |
def | Read |
def | Write |
def | Rename |
Private Member Functions | |
def | _DoMemberIO |
def | __HouseKeeping |
def | __ReloadChildren |
def | _SetSchemaVersion |
Private Attributes | |
__schemaVersion | |
__taskManagers | |
__taskManagersModels |
Top level object from which to create, list and destroy Tasks. This class inherits from GBSObject and adds the following user callable methods
Definition at line 11 of file GBSManager.py.
def python::GBSManager::GBSManager::__HouseKeeping | ( | self | ) | [private] |
Perform start up house-keeping chores.
Definition at line 121 of file GBSManager.py.
00125 : 00126 """Perform start up house-keeping chores.""" 00127 00128 chores = GetConfigValue("HouseKeepingCommands") 00129 if ( chores ): 00130 print "Manager performing start of job house-keeping:-" 00131 for chore in chores.split(' ;'): print " %s " % chore
def python::GBSObject::GBSObject::__init__ | ( | self, | ||
name, | ||||
parent, | ||||
model | ||||
) | [inherited] |
Definition at line 10 of file GBSObject.py.
00015 : 00016 self.__name = name # Object name, must be unique within scope of parent 00017 self.__parent = parent # Parent (None for Manager) 00018 self.__model = model # Model name 00019 Log(self,logger.SYNOPSIS,"Creating a " + self.GetType() + " named " + self.__name) 00020 00021 # After creation, either read current state from disk, if state file exists, 00022 # or create state file (and if necessary supporting directory) if it doesn't. 00023 00024 if os.path.isfile(self.GetStoreLocation()): 00025 self.Read() else:
def python::GBSManager::GBSManager::__init__ | ( | self, | ||
name, | ||||
parent, | ||||
model, | ||||
model_args | ||||
) |
Definition at line 19 of file GBSManager.py.
00022 : parent = None, model = 'default' and model_args = {} 00023 def __init__(self,name,parent,model,model_args): 00024 self.__schemaVersion = 0 # Incremented each time the schema changes (See schema_migrator.py) 00025 self.__taskManagers = {} # Volatile: Hash name -> Task 00026 self.__taskManagersModels = {} # Volatile: Hash name -> Task models 00027 00028 GBSObject.__init__(self,name,parent,model) 00029 00030 self.MakeChildDirectory() 00031 self.__ReloadChildren() 00032 00033 # Migrate schema 00034 migrate(self)
def python::GBSManager::GBSManager::__ReloadChildren | ( | self | ) | [private] |
Reload child Tasks from disk. Loop over all *.state files, read their model name and then recreate.
Definition at line 132 of file GBSManager.py.
00134 : print " - command failed with exit code %d" % exit_code 00135 00136 def __ReloadChildren(self): 00137 00138 """Reload child Tasks from disk. 00139 00140 Loop over all *.state files, read their model name and then recreate.""" 00141 00142 import os, re 00143 00144 child_dir = self.GetStoreLocation("child_dir") 00145 child_state_files = os.listdir(child_dir) 00146 for child_state_file in child_state_files: 00147 00148 # Only look at *.state files 00149 child_state_file_spec = child_dir + "/" + child_state_file 00150 if not os.path.isfile(child_state_file_spec): continue 00151 mo = re.search(r"^(.*)\.state$",child_state_file) 00152 if not mo: continue 00153 child_name = mo.group(1) 00154 00155 # Have to sneak a look at the child's state file to get the model. 00156 # This is the one case where the parent's model may not be the same 00157 # as the child's; Manager is always the "default" model 00158 child_model = "" 00159 f = open(child_state_file_spec) 00160 for line in f: 00161 mo = re.search(r"Model Name:\s*(\S+)",line) 00162 if mo: child_model = mo.group(1) 00163 f.close() 00164 00165 if not child_model:
def python::GBSManager::GBSManager::__repr__ | ( | self | ) |
Reimplemented from python::GBSObject::GBSObject.
Definition at line 45 of file GBSManager.py.
00045 :task.WriteFamily() 00046 00047 def GetType(self): return "GBSManager" 00048 00049 def __repr__(self) : 00050 return GBSObject.__repr__(self) + "\n"\
def python::GBSManager::GBSManager::_DoMemberIO | ( | self, | ||
ioh | ||||
) | [private] |
Reimplemented from python::GBSObject::GBSObject.
Definition at line 35 of file GBSManager.py.
00039 : self.__schemaVersion = ioh("+Schema Version","i",self.__schemaVersion)
def python::GBSManager::GBSManager::_SetSchemaVersion | ( | self, | ||
ver | ||||
) | [private] |
Set current schema version number.
Definition at line 166 of file GBSManager.py.
00166 : Cannot find model for Task in " + str(child_state_file_spec)) 00167 continue 00168 self.AddTask(child_name,child_model) 00169 00170 def _SetSchemaVersion(self,ver): 00171 00172 """Set current schema version number.""" 00173
def python::GBSManager::GBSManager::AddTask | ( | self, | ||
task_name, | ||||
model_name = "default" | ||||
) |
Create a new Task called task_name using model model_name e.g. task = manager.AddTask("Joe","default")
Definition at line 92 of file GBSManager.py.
00096 : 00097 00098 """Create a new Task called task_name using model model_name e.g. task = manager.AddTask("Joe","default")""" 00099 00100 # Check that the name is legal and not already in use. 00101 if re.search(r"[^a-zA-Z0-9_\-]",task_name): 00102 print "Sorry, '" + str(task_name) + "' is an illegal task name (characters other than alphanumeric, '_' and '-')" 00103 return 00104 if self.__taskManagers.has_key(task_name): 00105 print "Sorry, there already is a Task named " + str(task_name) 00106 return None 00107 00108 # Check the model is valid 00109 model_name_valid = 0 00110 reg = GetModelRegistry().GetRegistry() 00111 for m_name,m in reg.iteritems(): 00112 if model_name == m_name: model_name_valid = 1 00113 if not model_name_valid: 00114 print "Sorry %s is not a valid model, the following are available:-" % model_name 00115 for m_name,m in reg.iteritems(): 00116 print " " + m_name.ljust(15) + m.GetTitle() 00117 return None 00118 tm = GetModelRegistry().CreateObject(model_name,"Task",task_name,self) self.__taskManagers[task_name] = tm
def python::GBSObject::GBSObject::GetModel | ( | self | ) | [inherited] |
def python::GBSObject::GBSObject::GetName | ( | self | ) | [inherited] |
def python::GBSObject::GBSObject::GetParent | ( | self | ) | [inherited] |
def python::GBSManager::GBSManager::GetSchemaVersion | ( | self | ) |
def python::GBSObject::GBSObject::GetStoreLocation | ( | self, | ||
type = "self" | ||||
) | [inherited] |
Return storage location: parent directory, self or child directory. type is one of "parent_dir" parent's child directory "self" object's state file "child_dir" directory for own children
Definition at line 38 of file GBSObject.py.
00039 : return self.__name 00040 def GetModel(self): return self.__model 00041 def GetParent(self): return self.__parent 00042 00043 def GetStoreLocation(self,type="self"): 00044 00045 """Return storage location: parent directory, self or child directory. 00046 00047 type is one of "parent_dir" parent's child directory 00048 "self" object's state file 00049 "child_dir" directory for own children""" 00050 00051 loc = "" 00052 if self.__parent == None : loc = GBSConfig.GetConfig().GetValue("DataDirectory") 00053 else : loc = self.__parent.GetStoreLocation("parent_dir") + "/" + self.__parent.GetName() 00054 if type != "parent_dir": loc += "/" + self.GetName()
def python::GBSManager::GBSManager::GetTask | ( | self, | ||
name | ||||
) |
Retrieve existing Task e.g. task = manager.GetTask("Fred")
Definition at line 53 of file GBSManager.py.
00057 : 00058 00059 """Retrieve existing Task e.g. task = manager.GetTask("Fred")""" 00060 00061 if not self.__taskManagers.has_key(name): print "Sorry, there is no Task named " + str(name)
def python::GBSManager::GBSManager::GetType | ( | self | ) |
Reimplemented from python::GBSObject::GBSObject.
Definition at line 43 of file GBSManager.py.
00043 : 00044 self.Write() for task_name,task in self.__taskManagers.iteritems():task.WriteFamily()
def python::GBSManager::GBSManager::ListModels | ( | self | ) |
List all available models
Definition at line 62 of file GBSManager.py.
00064 : return self.__taskManagers[name] 00065 00066 def ListModels(self): 00067 00068 """List all available models""" 00069 00070 print "The following models are available:-\n" 00071 reg = GetModelRegistry().GetRegistry() 00072 for m_name,m in reg.iteritems(): 00073 print "Model: " + m_name
def python::GBSManager::GBSManager::ListTasks | ( | self | ) |
List all existing Tasks
Definition at line 74 of file GBSManager.py.
00075 :" + m.GetTitle() + "\nDescription:" 00076 print m.GetDescription() 00077 00078 def ListTasks(self): 00079 00080 """List all existing Tasks""" 00081 00082 print "The following tasks are setup up:-\n" 00083 first = 1 00084 for task_name,task in self.__taskManagers.iteritems(): 00085 if first:
def python::GBSObject::GBSObject::MakeChildDirectory | ( | self | ) | [inherited] |
If directory used to store child objects does not exist, create it
Definition at line 55 of file GBSObject.py.
00055 : loc += ".state" 00056 return loc 00057 00058 # I/O 00059 00060 def MakeChildDirectory(self): 00061 00062 """If directory used to store child objects does not exist, create it""" 00063 00064 child_dir = self.GetStoreLocation("child_dir")
def python::GBSObject::GBSObject::Read | ( | self | ) | [inherited] |
Definition at line 65 of file GBSObject.py.
00065 : Log(self,logger.SYNOPSIS,"Creating directory for child objects:" + str(child_dir))
def python::GBSObject::GBSObject::Rename | ( | self, | ||
new_name | ||||
) | [inherited] |
Rename to new_name (does not perform I/O - that must be done by caller).
Definition at line 82 of file GBSObject.py.
00082 : 00083 self.__model = ioh("Model Name","s",self.__model) 00084 self.__name = ioh("Object Name","s",self.__name) 00085 00086 00087 def Rename(self,new_name): 00088 """Rename to new_name (does not perform I/O - that must be done by caller).""" self.__name = new_name
def python::GBSObject::GBSObject::Write | ( | self | ) | [inherited] |
def python::GBSManager::GBSManager::WriteFamily | ( | self | ) |
Reimplemented from python::GBSObject::GBSObject.
Definition at line 39 of file GBSManager.py.
00039 : 00040 self.__schemaVersion = ioh("+Schema Version","i",self.__schemaVersion) 00041 GBSObject._DoMemberIO(self,ioh) 00042 def WriteFamily(self):
Definition at line 20 of file GBSManager.py.
Definition at line 21 of file GBSManager.py.
Definition at line 22 of file GBSManager.py.