def cleanUp( configParameters, currentTime, daysOfPicklesToKeep ): """ @summary: Based on current time and frequencies contained within the time parameters, we will run the cleaners that need to be run. @param configParameters: StatsConfigParameters instance. @param currenTime: currentTime in seconds since epoch format. """ paths = StatsPaths() paths.setPaths() updateManager = AutomaticUpdatesManager(configParameters.nbAutoUpdatesLogsToKeep, "picklecleaner") if updateManager.updateIsRequired(currentTime) : output = commands.getoutput( paths.STATSTOOLS + "pickleCleaner.py %s" %int(daysOfPicklesToKeep) ) print paths.STATSTOOLS + "pickleCleaner.py" + " " + str( daysOfPicklesToKeep ) updateManager.addAutomaticUpdateToLogs( currentTime ) updateManager = AutomaticUpdatesManager(configParameters.nbAutoUpdatesLogsToKeep, "generalCleaner") if updateManager.updateIsRequired(currentTime) : commands.getstatusoutput( paths.STATSTOOLS + "clean_dir.plx" + " " + paths.STATSETC + "clean_dir.conf" ) print paths.STATSTOOLS + "clean_dir.plx" + " " + paths.STATSETC + "clean_dir.conf" updateManager.addAutomaticUpdateToLogs( currentTime )
def backupRRDDatabases(configParameters, currentTime, nbBackupsToKeep): """ @summary: Based on current time and frequencies contained within the time parameters, we will backup the databases only if necessary. @param configParameters: StatsConfigParameters instance. @param currenTime: currentTime in seconds since epoch format. """ paths = StatsPaths() paths.setPaths() updateManager = AutomaticUpdatesManager( configParameters.nbAutoUpdatesLogsToKeep, "dbBackups") if updateManager.updateIsRequired(currentTime): commands.getstatusoutput(paths.STATSTOOLS + "backupRRDDatabases.py" + " " + str(int(nbBackupsToKeep))) print paths.STATSTOOLS + "backupRRDDatabases.py" + " " + str( nbBackupsToKeep) updateManager.addAutomaticUpdateToLogs(currentTime)
def cleanUp(configParameters, currentTime, daysOfPicklesToKeep): """ @summary: Based on current time and frequencies contained within the time parameters, we will run the cleaners that need to be run. @param configParameters: StatsConfigParameters instance. @param currenTime: currentTime in seconds since epoch format. """ paths = StatsPaths() paths.setPaths() updateManager = AutomaticUpdatesManager( configParameters.nbAutoUpdatesLogsToKeep, "picklecleaner") if updateManager.updateIsRequired(currentTime): output = commands.getoutput(paths.STATSTOOLS + "pickleCleaner.py %s" % int(daysOfPicklesToKeep)) print paths.STATSTOOLS + "pickleCleaner.py" + " " + str( daysOfPicklesToKeep) updateManager.addAutomaticUpdateToLogs(currentTime) updateManager = AutomaticUpdatesManager( configParameters.nbAutoUpdatesLogsToKeep, "generalCleaner") if updateManager.updateIsRequired(currentTime): commands.getstatusoutput(paths.STATSTOOLS + "clean_dir.plx" + " " + paths.STATSETC + "clean_dir.conf") print paths.STATSTOOLS + "clean_dir.plx" + " " + paths.STATSETC + "clean_dir.conf" updateManager.addAutomaticUpdateToLogs(currentTime)
def backupRRDDatabases( configParameters, currentTime, nbBackupsToKeep ): """ @summary: Based on current time and frequencies contained within the time parameters, we will backup the databases only if necessary. @param configParameters: StatsConfigParameters instance. @param currenTime: currentTime in seconds since epoch format. """ paths = StatsPaths() paths.setPaths() updateManager = AutomaticUpdatesManager(configParameters.nbAutoUpdatesLogsToKeep, "dbBackups" ) if updateManager.updateIsRequired( currentTime ) : commands.getstatusoutput( paths.STATSTOOLS + "backupRRDDatabases.py" + " " + str( int(nbBackupsToKeep)) ) print paths.STATSTOOLS + "backupRRDDatabases.py" + " " + str(nbBackupsToKeep) updateManager.addAutomaticUpdateToLogs( currentTime )
def monitorActivities( configParameters, currentTime ): """ @summary: Monitors all the activities that occured during the course of this program. Report is sent out by mail to recipients specified in the config file. @param configParameters: StatsConfigParameters instance. @param currenTime: currentTime in seconds since epoch format. """ paths = StatsPaths() paths.setPaths() updateManager = AutomaticUpdatesManager( configParameters.nbAutoUpdatesLogsToKeep, "monitoring") if updateManager.updateIsRequired(currentTime) : output = commands.getoutput( paths.STATSBIN + "statsMonitor.py '%s'" %( currentTime ) ) print paths.STATSBIN + "statsMonitor.py" print output updateManager.addAutomaticUpdateToLogs( currentTime )
def monitorActivities(configParameters, currentTime): """ @summary: Monitors all the activities that occured during the course of this program. Report is sent out by mail to recipients specified in the config file. @param configParameters: StatsConfigParameters instance. @param currenTime: currentTime in seconds since epoch format. """ paths = StatsPaths() paths.setPaths() updateManager = AutomaticUpdatesManager( configParameters.nbAutoUpdatesLogsToKeep, "monitoring") if updateManager.updateIsRequired(currentTime): output = commands.getoutput(paths.STATSBIN + "statsMonitor.py '%s'" % (currentTime)) print paths.STATSBIN + "statsMonitor.py" print output updateManager.addAutomaticUpdateToLogs(currentTime)
def main(): """ @summary : Gets all the parameters from config file. Updates pickle files. Generates all the required graphics. Generates therwuired csv files. Updates the different web pages. Updates the desired databases. Uploads graphics to the required machines. Monitors the result of all the activities. """ if GeneralStatsLibraryMethods.processIsAlreadyRunning( "pxStatsStartup" ) == False: setGlobalLanguageParameters() GeneralStatsLibraryMethods.createLockFile( "pxStatsStartup" ) currentTime = time.time() currentTimeInIsoFormat = StatsDateLib.getIsoFromEpoch( currentTime ) generalParameters = StatsConfigParameters() generalParameters.getAllParameters() machineParameters = MachineConfigParameters() machineParameters.getParametersFromMachineConfigurationFile() validateParameters( generalParameters, machineParameters, None ) tagsNeedingUpdates = getMachinesTagsNeedingUpdates( generalParameters, machineParameters ) if tagsNeedingUpdates == None : #no previous parameter found saveCurrentMachineParameters( machineParameters ) elif tagsNeedingUpdates != [] : updateFilesAssociatedWithMachineTags( tagsNeedingUpdates, machineParameters ) saveCurrentMachineParameters( machineParameters ) updatePickles( generalParameters, machineParameters, currentTimeInIsoFormat ) updateDatabases( generalParameters, machineParameters, currentTimeInIsoFormat ) backupRRDDatabases( generalParameters, currentTimeInIsoFormat, generalParameters.nbDbBackupsToKeep ) #updateCsvFiles( ) getGraphicsForWebPages( generalParameters, currentTimeInIsoFormat ) updateWebPages( generalParameters ) #uploadGraphicFiles( generalParameters, machineParameters ) cleanUp( generalParameters , currentTimeInIsoFormat, generalParameters.daysOfPicklesToKeep ) monitorActivities( generalParameters, currentTimeInIsoFormat ) updateManager = AutomaticUpdatesManager( generalParameters.nbAutoUpdatesLogsToKeep, "pxStatsStartup" ) updateManager.addAutomaticUpdateToLogs( currentTimeInIsoFormat ) GeneralStatsLibraryMethods.deleteLockFile( "pxStatsStartup" ) print _( "Finished." ) else: print _( "Error. An other instance of pxStatsStartup is allready running." ) print _( "Only one instance of this software can be run at once." ) print _( "Please terminate the other instance or wait for it to end it's execution" ) print _( "before running this program again." ) print _( "Program terminated." ) sys.exit()
def main(): """ @summary : Gets all the parameters from config file. Updates pickle files. Generates all the required graphics. Generates therwuired csv files. Updates the different web pages. Updates the desired databases. Uploads graphics to the required machines. Monitors the result of all the activities. """ if GeneralStatsLibraryMethods.processIsAlreadyRunning( "pxStatsStartup") == False: setGlobalLanguageParameters() GeneralStatsLibraryMethods.createLockFile("pxStatsStartup") currentTime = time.time() currentTimeInIsoFormat = StatsDateLib.getIsoFromEpoch(currentTime) generalParameters = StatsConfigParameters() generalParameters.getAllParameters() machineParameters = MachineConfigParameters() machineParameters.getParametersFromMachineConfigurationFile() validateParameters(generalParameters, machineParameters, None) tagsNeedingUpdates = getMachinesTagsNeedingUpdates( generalParameters, machineParameters) if tagsNeedingUpdates == None: #no previous parameter found saveCurrentMachineParameters(machineParameters) elif tagsNeedingUpdates != []: updateFilesAssociatedWithMachineTags(tagsNeedingUpdates, machineParameters) saveCurrentMachineParameters(machineParameters) updatePickles(generalParameters, machineParameters, currentTimeInIsoFormat) updateDatabases(generalParameters, machineParameters, currentTimeInIsoFormat) backupRRDDatabases(generalParameters, currentTimeInIsoFormat, generalParameters.nbDbBackupsToKeep) #updateCsvFiles( ) getGraphicsForWebPages(generalParameters, currentTimeInIsoFormat) updateWebPages(generalParameters) #uploadGraphicFiles( generalParameters, machineParameters ) cleanUp(generalParameters, currentTimeInIsoFormat, generalParameters.daysOfPicklesToKeep) monitorActivities(generalParameters, currentTimeInIsoFormat) updateManager = AutomaticUpdatesManager( generalParameters.nbAutoUpdatesLogsToKeep, "pxStatsStartup") updateManager.addAutomaticUpdateToLogs(currentTimeInIsoFormat) GeneralStatsLibraryMethods.deleteLockFile("pxStatsStartup") print _("Finished.") else: print _( "Error. An other instance of pxStatsStartup is allready running.") print _("Only one instance of this software can be run at once.") print _( "Please terminate the other instance or wait for it to end it's execution" ) print _("before running this program again.") print _("Program terminated.") sys.exit()