예제 #1
0
    def execute(self):
        """ Method that implements snapshoting of the project into a folder. """        
        _logger.info("=== Stage=snapshot = %s" % self._config.name)
        _logger.info("++ Started at %s" % time.strftime("%H:%M:%S", time.localtime()))
        session = self.get_session()
        project = session.create(self._config.name)

        target_dir = os.path.normpath(os.path.join(self._config['dir'], project.name))
        _logger.info("Looking for snapshot under %s." % target_dir)
        if not self._check_version(project, target_dir):
            if not os.path.exists(target_dir):
                _logger.info("Creating '%s'." % target_dir)
                os.makedirs(target_dir)
            else:
                _logger.info("Project needs to be updated, so deleting '%s'." % target_dir)
                fileutils.rmtree(target_dir)
            
            try:
                _logger.info("Snapshotting project.")                
                if self.get_threads() == 1:                    
                    _logger.info(project.snapshot(target_dir, True))
                else:
                    _logger.info(ccm.extra.FastSnapshot(project, target_dir, self.get_threads()))
                                    
                # writing version file                
                _logger.info("Saving project version information.")
                versionfile = open(os.path.join(self._config['dir'], project.name, 'project.version'), "w+")
                versionfile.write(str(project))
                versionfile.close()                
            except Exception, exc:
                if isinstance(exc, ccm.extra.CCMExtraException):
                    for sexc in exc.subexceptions:
                        _logger.info(sexc)
                _logger.info("ERROR: snapshotting %s" % self._config.name)
                _logger.info(exc)
                raise exc
예제 #2
0
 def __find_project(self, project):
     """ Private method. """
     if (os.path.exists(os.path.join(self._config['dir'], project.name, "project.version"))):
         _logger.info("Snapshot to checkout deleting '%s'." % os.path.join(self._config['dir'], project.name))
         fileutils.rmtree(os.path.join(self._config['dir'], project.name))
         return None
     
     path = os.path.join(self._config['dir'], project.name, project.name)
     try:
         result = project.session.get_workarea_info(path)
         if(result == None):
             fileutils.rmtree(path)
             return result
         return result['project']
     except ccm.CCMException:
         # Delete the project dir if found
         if os.path.exists(os.path.dirname(path)):
             fileutils.rmtree(os.path.dirname(path))
         return None
예제 #3
0
 def test_rmtree_long_path(self):
     fileutils.rmtree(root_test_dir)
     assert not os.path.exists(self.long_path)
     assert not os.path.exists(root_test_dir)
예제 #4
0
 def test_rmtree_long_path_unc_format(self):
     if sys.platform == "win32":
         fileutils.rmtree(u"\\\\?\\" + os.path.join(os.path.abspath('.'), root_test_dir))
         assert not os.path.exists(self.long_path)
         assert not os.path.exists(root_test_dir)
예제 #5
0
def teardown_module():
    """ Teardown test config. """
    if os.path.exists(root_test_dir):
        fileutils.rmtree(root_test_dir)