def __init__(self, zipFilename, location): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.zipFilename = zipFilename
     self.location = location
     
     Action.__init__(self)                
Exemplo n.º 2
0
 def __init__(self, scriptFilename, connectionString): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.scriptFilename = scriptFilename
     self.connectionString = connectionString
     
     Action.__init__(self)
 def __init__(self, filename): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.filename = filename
     self.reportText = None
     
     Action.__init__(self)                
 def __init__(self, src, dst): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.src = src
     self.dst = dst
     
     Action.__init__(self)
    def __init__(self, doCommand, undoCommand):
        log.debug(self.__class__.__name__ + " initialized")
        
        self.doCommand = doCommand
        self.undoCommand = undoCommand

        
        Action.__init__(self)
 def __init__(self, compressedFilename, compressionType, location): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.compressedFilename = compressedFilename
     self.compressionType = compressionType
     self.location = location
     
     Action.__init__(self)                
    def __init__(self, path): 
        log.debug(self.__class__.__name__ + " initialized")
        
        self.path = path
        self.tempLocation = generateRandomDirectoryUnderPath(scriptGlobals.workingDir)
        createDirectoriesRecursively(self.tempLocation)

        Action.__init__(self)    
def getCleanVersionNumber(version):
    m = re.match('(\d+\.)+\d+', version)
    if(m): 
        log.debug('getCleanVersionNumber for "'+version+'" results to "'+m.group(0)+'"')
        return m.group(0)
    else: 
        log.debug('getCleanVersionNumber unable to detect version for "'+version+'"')
        return "0"
def deleteFile(fileName):
    log.info("Attempting to remove " + fileName + "...")
    if glob.glob(fileName):        
        for name in glob.glob(fileName):
            log.debug("Removing " + name + "...")
            DeleteDirOrFile(name)
    else:
        log.info("Path does not exist: " + fileName)
 def __init__(self, moduleName, valueFilename, templateFilename): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.moduleName = moduleName
     self.valueFilename = valueFilename
     self.templateFilename = templateFilename
     
     Action.__init__(self)                
 def __init__(self, doReport, undoReport): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.doReport = doReport
     self.undoReport = undoReport
     self.reportTxt = ""
     
     Action.__init__(self)                
Exemplo n.º 12
0
 def __init__(self, scriptText, connectionString, doCommit, headersOff): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.scriptText = scriptText
     self.connectionString = connectionString
     self.doCommit = doCommit
     self.headersOff = headersOff
     
     Action.__init__(self)
Exemplo n.º 13
0
    def __init__(self, path, uid, gid): 
        log.debug(self.__class__.__name__ + " initialized")

        self.path = path          
        self.uid = uid
        self.gid = gid
        self.undoStatObject = os.stat(path)
        
        Action.__init__(self)
Exemplo n.º 14
0
    def __init__(self, path, mode): 
        log.debug(self.__class__.__name__ + " initialized")

        self.path = path          
        self.doMode = mode
        self.undoMode = getPathPermissions(path)
     
        
        Action.__init__(self)
Exemplo n.º 15
0
 def __init__(self, script, username, password, connectionString): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.script = script
     self.username = username
     self.password = password
     self.connectionString = connectionString
     
     Action.__init__(self)
 def __init__(self, lineToFind, lineToAppend, fileName, tmpFilename, appendStyle): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.lineToFind = lineToFind
     self.lineToAppend = lineToAppend
     self.fileName = fileName
     self.tmpFilename = tmpFilename
     self.appendStyle = appendStyle
     
     Action.__init__(self)                
Exemplo n.º 17
0
 def __init__(self, sender, receivers, subject, message, smtpServer, smtpPort): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.sender = sender
     self.receivers = receivers
     self.subject = subject
     self.message = message
     self.smtpServer = smtpServer
     self.smtpPort = smtpPort
     
     Action.__init__(self)
 def __init__(self, src, dst): 
     log.debug(self.__class__.__name__ + " initialized")
     self.src = src
     self.dst = dst
     self.srcDirname = os.path.dirname(src)
     self.dstDirname = os.path.dirname(dst)
     self.srcBasename = os.path.basename(src)
     self.dstBasename = os.path.basename(dst)
     self.isSrcDir = os.path.isdir(src)
     self.isDstDir = os.path.isdir(dst)
     self.isSrcExistent = os.path.exists(src)
     self.isDstExistent = os.path.exists(dst)
     Action.__init__(self)        
Exemplo n.º 19
0
    def __init__(self, src, dst): 
        log.debug(self.__class__.__name__ + " initialized")

        self.src = src
        self.dst = dst
        
        self.srcDirname = os.path.dirname(src)
        self.dstDirname = os.path.dirname(dst)

        self.srcBasename = os.path.basename(src)
        self.dstBasename = os.path.basename(dst)

        self.isSrcFile = os.path.isfile(src)
        self.isDstFile = os.path.isfile(dst)

        Action.__init__(self)        
Exemplo n.º 20
0
    def __init__(self):       
        '''
        Appends this Action to Rollback queue
        '''

        # If script runs in attended mode then ask
        if not lib.OptParser.options.unattended:
            a = getAnswerFromUser("Action '" + self.__class__.__name__ + "' " + str(self.__dict__) + " is ready to execute.\n\n Action Documentation:\n" + self.__doc__ +"\n\nSelect your action:\n\n(U) Execute action and continue unattended \n(X) Don't execute current action \n(<any other key>) Execute current action")
            if (re.compile('^u$', re.I)).match(a): lib.OptParser.options.unattended = True
            if (re.compile('^x$', re.I)).match(a):
                log.warn("Skipping current action '" + self.__class__.__name__ + "' " + str(self.__dict__) + "'")
                return
        
        # Run subclass __call__ function
        self()
        
        # Append this action to rollback queue
        log.debug("Appending action '" + self.__class__.__name__ + "' " + str(self.__dict__) + " to rollback queue" )
        scriptGlobals.executedActionList.append(self)
Exemplo n.º 21
0
 def acquire(self):
     '''Acquire a lock, returning self if successful, False otherwise'''
     if self.islocked():
         if self.debug:
             lock = self._readlock()
             log.critical('Previous lock detected: %s' % self.pddr(lock))
         return False
     try:
         fh = open(self.path, 'w')
         fh.write(self.addr())
         fh.close()
         if self.debug:
             log.debug('Acquired lock: %s' % self.fddr())
     except:
         if os.path.isfile(self.path):
             try:
                 os.unlink(self.path)
             except:
                 pass
         raise (self.FileLockAcquisitionError,
                'Error acquiring lock: %s' % self.fddr())
     return self
Exemplo n.º 22
0
    def __init__(self, module):
        '''
        Constructor
        '''
        log.debug(self.__class__.__name__ + " initialized")
        
        # Check if the current python version is correct
        checkPythonVersion(scriptGlobals.pythonMajorVersion, scriptGlobals.pythonMinorVersion)

        # Check for required executables
        checkRequiredExecutablesExist(scriptGlobals.requiredExecutables)

        # Check user isn't root
        if checkUserIsRoot(getpass.getuser()):
            die("User is '" + getpass.getuser() + "'. The script shouldn't run with superuser permissions.")

        # Check action validity according to current module
        if (not lib.OptParser.options.action in module.actionBundleGroupClasses):
            die("Unrecognized action '" + lib.OptParser.options.action + "'")

        # Make Oracle tool executable
        if getPathPermissions(scriptGlobals.sqlplusLocation) != 0755 :
            log.debug("SQLPlus file" + scriptGlobals.sqlplusLocation + " isn't executable. Changing its permissions to executable.")
            changePathPermissions(scriptGlobals.sqlplusLocation, 0755)
def installDefaultPlugins(staticFolder, unzippedPackagePath, module):
    # create InstalledModules folder
    pluginInstalledModules = staticFolder + scriptGlobals.osDirSeparator + module.subModule.pluginInstalledModulesFolder
    if not (os.access(pluginInstalledModules, os.F_OK)):
        log.debug("Creating plugin installed modules folder: " + pluginInstalledModules)
        CreateDirectoriesRecursively(pluginInstalledModules)
        
    # create Plugin_Installation folder    
    pluginInstallationFolder = staticFolder + scriptGlobals.osDirSeparator + module.subModule.pluginInstallationFolder
    if not (os.access(pluginInstallationFolder, os.F_OK)):
        log.debug("Creating plugin installation folder: " + pluginInstallationFolder)
        CreateDirectoriesRecursively(pluginInstallationFolder)
           
    # remove any existing default plugins
    for pluginName in module.subModule.pluginList:
        pluginName = pluginName + "*"
        log.debug("Uninstalling " + pluginName + "...")        
        pluginPath = pluginInstallationFolder + scriptGlobals.osDirSeparator + pluginName
        markPluginForRemoval(pluginPath)
        
    # install plugins    
    pluginBinariesFolder = unzippedPackagePath + scriptGlobals.osDirSeparator + module.subModule.pluginBinaries
    log.debug("Installing default plugins from " + pluginBinariesFolder + " to " + pluginInstallationFolder + "...")
    copyPlugins(pluginBinariesFolder, pluginInstallationFolder)
Exemplo n.º 24
0
 def __init__(self, module):
     '''
     Constructor
     '''
     log.debug(self.__class__.__name__ + " initialized")
Exemplo n.º 25
0
    getAnswerFromUser, produceFinalReport, extractFileFromZipToDir, checkPythonVersion,\
    generateGUID, sendEmail, readPropertyFromPropertiesFileWithFallback,\
    getRoundedTimeDifference, getCurrentHostname, serializeListToFile, scriptGlobals, RollbackTriggerException, initClassFromString, printsScriptInformation, createCustomLogger, acquireLock, dictionaryToString, dateToString, die, isRequiredFileEmpty
from modules.Module import Module
from lib.FunStuff import fireworksAsciiHeader
from notifications.GenericNotificationTemplates import detailedExecutionReportTemplate

try:
    # Acquire Lock
    lock = acquireLock(scriptGlobals.lockFile, True)
    
    # Measure execution time
    startTime = time.time()

    # Print Fireworks execution command
    log.debug("Fireworks execution command '" + " ".join(sys.argv) + "'")

    # Print cool header :-)
    log.info(fireworksAsciiHeader(scriptGlobals.version, scriptGlobals.revision, scriptGlobals.buildDate))

    # Print OS information
    printOsInformation()

    # Generate a unique ActionBundle execution id
    guid = generateGUID()
    log.info("Unique Fireworks Execution ID generated: '" + guid + "'")

    # Initialize working dir
    scriptGlobals.workingDir =  scriptGlobals.workingDir % (parser.options.action, guid)
    
    # Create it
 def __init__(self, cronJobLine): 
     log.debug(self.__class__.__name__ + " initialized")
     
     self.cronJobLine = cronJobLine
     
     Action.__init__(self)                
Exemplo n.º 27
0
 def removeActionFromRollbackQueue(self):
     log.debug("Removing action '" + self.__class__.__name__ + "' " + str(self.__dict__) + " from rollback queue" )
     scriptGlobals.executedActionList.remove(self)
Exemplo n.º 28
0
    def __init__(self, path):
        log.debug(self.__class__.__name__ + " initialized")

        self.path = path

        Action.__init__(self)
def getDbUpdateScriptsToRun(version, dbUpdateConfigParser):
    version = getCleanVersionNumber(version)
    log.debug("Retrieving scripts for version " + version)
    scripts = []
    brachesDefault = []
    branches = dbUpdateConfigParser.sections()
    for branch in branches:
        log.debug(" Checking branch section " + branch)
        if isVersionInBranch(version, branch):
            log.debug("  Matches branch section " + branch)
            versionPatterns = dbUpdateConfigParser.options(branch)
            filesStr = None
            defaultFilesStr = None
            for vpat in versionPatterns:
                log.debug("   Checking version pattern " + vpat)
                if vpat.strip().lower() == 'default':
                    defaultFilesStr = dbUpdateConfigParser.get(branch, vpat)
                elif re.match(vpat, version):
                    log.debug("    Matches version pattern " + vpat)
                    filesStr = dbUpdateConfigParser.get(branch, vpat)
                    if filesStr.strip().lower() == 'unsupported' :
                        log.debug("     Version not supported")
                        return False, scripts, brachesDefault
                break
            if filesStr is not None:
                files = filesStr.split(':')
            elif defaultFilesStr is not None:
                log.debug("    Matches default version")
                if defaultFilesStr.strip().lower() == 'unsupported' :
                    log.debug("     Version not supported")
                    return False, scripts, brachesDefault
                log.info("WARNING: Default migration scripts for branch "+branch+" have been added for execution")
                brachesDefault.append(branch)
                files = defaultFilesStr.split(':')
            else:
                return False, scripts, brachesDefault
            for f in files:
                if f[0] == '@':
                    log.debug("     Found reference to version " + f)
                    found, moreScripts, moreDefault = getDbUpdateScriptsToRun(f[1:], dbUpdateConfigParser)
                    if found:
                        scripts.extend(moreScripts)
                        brachesDefault.extend(moreDefault)
                    else:
                        return False, scripts, brachesDefault
                else:
                    log.debug("     Found script " + f)
                    scripts.append(f)
            return True, scripts, brachesDefault
    return False, scripts, brachesDefault