def _setINIFile(self,path,iniDict):
     path = os.path.join(self.mainDaemon.ETC_DIR,path)
     
     #create folder if does not exist
     pathDir = os.path.dirname(path)
     if not os.path.isdir(pathDir):
         os.mkdir(pathDir)
     
     iniSource =  getINIstringtoDict(self._getINIFile(path))
     newConfig={}
     
     for section in iniDict.keys():
         if section in iniSource:
             newConfig[section] = mergeDicts(iniSource[section],iniDict[section])
         else:
             newConfig[section] = iniDict[section]
     
     config = dictToConfig(newConfig)
     try:
         #shutil.copy(path,path + "." + str(int(time.time())))
         pass
     except:
         pass
     config.write(open(path,"w"))
     #print newConfig
     return {"succeeded": True}
Example #2
0
def getServerAvilableDependencies(server):
    ''' Get a dict of the available dependencies that can be created for a server
     
     :param server: the server that is going to have the new dependency
     :return: A dict of servers and their description '''
    response = getDataFromServer("getServerDependencyMap",{"server": server})
    if response == None:
        return {}
    else:
        depMap = json.loads(response["dependencyMap"])
        return mergeDicts(depMap["available"], depMap["existing"])
Example #3
0
 def appendToLog(self):
     ''' Appends to the log the current status
     '''
     try:
         connection = self.engine.connect()
         for server in self.mainDaemon.servers.getSortedNodeList():
             sql = "insert into " + self.Log.__tablename__ + " values (?,?,?,?)"
             variables = (None,server.getName(),json.dumps(mergeDicts(server.getOutletsDataDict(),server.getControlsDataDict())),str(time.time()))
             
             connection.execute(sql,variables)
 
         connection.close()
     except:
         traceback.print_exc(file=sys.stdout)
         self.mainDaemon.debug("Failed to append to log, reason in stdout")
     return