Ejemplo n.º 1
0
 def __getRemoteFile(self, sourceFilePath, targetFilePath, gatewayHosts,
                     sftp):
     """
     Send local file to remote machine
     sourceFilePath -- Source file path (/file path/...).
     targetFilePath -- Target file path (/file path/...).
     sftp -- sftp connection.
     """
     log.info("Getting " + sourceFilePath + " to " + targetFilePath)
     # Check if file already existsFilePath and it is up to date
     existsFilePath = False
     if exists(targetFilePath):
         if self.__getRemoteSHA1(
                 sourceFilePath,
                 self.ssh) == self.__getLocalSHA1(targetFilePath):
             existsFilePath = True
             log.info(targetFilePath + " already existed")
     if not existsFilePath:
         makeFilePath(targetFilePath)
         try:
             sftp.get(sourceFilePath, targetFilePath)
         except IOError as err:
             log.error("Fail getting remote file " + sourceFilePath +
                       " to local file " + targetFilePath + " - " +
                       str(err))
             raise
Ejemplo n.º 2
0
    def __init__(self, filePath=''):
        """ If filePath is empty string, the general logger is used. """
        self._filePath = filePath
        makeFilePath(self._filePath)

        if self._filePath not in config['loggers']:
            config['handlers'][self._filePath] = {
                'level': 'NOTSET',
                'class': 'logging.handlers.RotatingFileHandler',
                'formatter': 'fileFormat',
                'filename': self._filePath,
                'maxBytes': 100000
            }

            config['loggers'][self._filePath] = {
                'handlers': [self._filePath],
                'level': 'NOTSET',
                'propagate': False
            }
            # Note: if we want to see in the console what we also have in
            # run.log, add 'consoleHandler' to the list of 'handlers'.

            logging.config.dictConfig(config)

        self._log = logging.getLogger(self._filePath)
Ejemplo n.º 3
0
    def _writeDoneList(self, micList):
        """ Write to a text file the items that have been done. """
        doneFile = self._getAllDone()

        if not exists(doneFile):
            makeFilePath(doneFile)

        with open(doneFile, 'a') as f:
            for mic in micList:
                f.write('%d\n' % mic.getObjId())
Ejemplo n.º 4
0
    def _writeDoneList(self, micList):
        """ Write to a text file the items that have been done. """
        doneFile = self._getAllDone()

        if not exists(doneFile):
            makeFilePath(doneFile)

        with open(doneFile, 'a') as f:
            for mic in micList:
                f.write('%d\n' % mic.getObjId())
Ejemplo n.º 5
0
 def __copyLocalFile(self, sourceFilePath, targetFilePath):
     """
     Send local file to remote machine
     sourceFilePath -- Source file path (/file path/...).
     targetFilePath -- Target file path (/file path/...).
     """
     log.info("Copying " + sourceFilePath + " to " + targetFilePath)
     # Check if file already existsFilePath and it is up to date
     existsFilePath = False
     if (exists(targetFilePath)):
         if ( self.__getLocalSHA1(sourceFilePath) ==  self.__getLocalSHA1(targetFilePath)):
             existsFilePath = True
             log.info(targetFilePath + " already existed")
     if (not existsFilePath):                    
         makeFilePath(targetFilePath)
         shutil.copy2(sourceFilePath, targetFilePath)
Ejemplo n.º 6
0
 def __copyLocalFile(self, sourceFilePath, targetFilePath):
     """
     Send local file to remote machine
     sourceFilePath -- Source file path (/file path/...).
     targetFilePath -- Target file path (/file path/...).
     """
     log.info("Copying " + sourceFilePath + " to " + targetFilePath)
     # Check if file already existsFilePath and it is up to date
     existsFilePath = False
     if exists(targetFilePath):
         if self.__getLocalSHA1(sourceFilePath) == self.__getLocalSHA1(
                 targetFilePath):
             existsFilePath = True
             log.info(targetFilePath + " already existed")
     if not existsFilePath:
         makeFilePath(targetFilePath)
         shutil.copy2(sourceFilePath, targetFilePath)
Ejemplo n.º 7
0
 def __getRemoteFile(self, sourceFilePath, targetFilePath, gatewayHosts, sftp):
     """
     Send local file to remote machine
     sourceFilePath -- Source file path (/file path/...).
     targetFilePath -- Target file path (/file path/...).
     sftp -- sftp connection.
     """
     log.info("Getting " + sourceFilePath + " to " + targetFilePath)
     # Check if file already existsFilePath and it is up to date
     existsFilePath = False
     if (exists(targetFilePath)):
         if ( self.__getRemoteSHA1(sourceFilePath, self.ssh) ==  self.__getLocalSHA1(targetFilePath)):
             existsFilePath = True
             log.info(targetFilePath + " already existed")
     if (not existsFilePath):        
         makeFilePath(targetFilePath)
         try:
             sftp.get(sourceFilePath, targetFilePath)
         except IOError as err:
             log.error("Fail getting remote file " + sourceFilePath + " to local file " + targetFilePath + " - " + str(err))
             raise
Ejemplo n.º 8
0
Archivo: log.py Proyecto: I2PC/scipion
    def __init__(self, filePath=''):
        """ If filePath is empty string, the general logger is used. """
        self._filePath = filePath
        makeFilePath(self._filePath)

        if self._filePath not in config['loggers']:
            config['handlers'][self._filePath] = {
                'level': 'NOTSET',
                'class': 'logging.handlers.RotatingFileHandler',
                'formatter': 'fileFormat',
                'filename': self._filePath,
                'maxBytes': 100000}

            config['loggers'][self._filePath] = {
                'handlers': [self._filePath],
                'level': 'NOTSET',
                'propagate': False}
            # Note: if we want to see in the console what we also have in
            # run.log, add 'consoleHandler' to the list of 'handlers'.

            logging.config.dictConfig(config)
            
        self._log = logging.getLogger(self._filePath) 
Ejemplo n.º 9
0
 def getFile(self, remoteFile, localFile):
     """ Wrapper around sftp.get that ensures
     path exists for localFile.
     """
     makeFilePath(localFile)
     self.sftp.get(remoteFile, localFile)
Ejemplo n.º 10
0
 def getFile(self, remoteFile, localFile):
     """ Wrapper around sftp.get that ensures
     path exists for localFile.
     """
     makeFilePath(localFile)
     self.sftp.get(remoteFile, localFile)