示例#1
0
    def execute(self, pool):
        
        # Test if git local repo exists
        if not os.path.isdir(os.path.join(os.getcwdu(), DevToolsConfigFile.Path)):
            prompt.error(DevToolsMessage.GitRepoNotExist.format(''))
            return

        error = False
        current_path = os.getcwdu()        
        try:
            log.info(u'Running Dev Tools initialization script.')
            if misc.is_os_windows():
                path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.WindowsClimbUpDepth)
                #TODO: replace current workaround for WindowsModuleScript
                current_path = os.getcwdu()
                script_path = os.path.join(path, OSSpecific.WindowsModuleScriptPath)
                log.debug(u'Changing path to {0}.'.format(script_path))
                os.chdir(script_path)

                log.info(u'Running script "{0}".'.format(OSSpecific.WindowsModuleScriptName))
                shell_utils.call([OSSpecific.WindowsModuleScriptName])
                
                log.debug(u'Changing path to {0}.'.format(current_path))
                os.chdir(current_path)
                
                log.info(u'Running script "{0}".'.format(OSSpecific.WindowsRepoScript))
                fullpath = os.path.join(path, OSSpecific.WindowsRepoScript)
                prompt.error(shell_utils.call([fullpath]))
            else:
                path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.LinuxClimbUpDepth)
                log.info(u'Running script "{0}" at {1}.'.format(OSSpecific.LinuxRepoScript,
                                                                path))
                fullpath = os.path.join(path, OSSpecific.LinuxRepoScript)
                prompt.error(shell_utils.call([fullpath]))
            
            location = DevToolsConfigFile.Path + os.path.sep + DevToolsConfigFile.Name        
            config_file.set_access_permission(location, True)

        except subprocess.CalledProcessError as ex:
            # Git returned with an error code
            log.error(u'Dev Tools initialization script report an error, because "{0}".'.format(ex))
            error = True
            prompt.error(DevToolsMessage.InitError.format(ex.message))
        
        except (OSError, IOError) as ex:
            log.error(u'Failed to call Dev Tools initialization script, because "{0}".'.format(ex))
            # Cannot find or run script
            error = True
            if ex.errno == FileErrorConstant.FileNotFoundErrorCode:
                if fullpath:
                    prompt.error(DevToolsMessage.FileMissingError.format(fullpath))
                else:
                    prompt.error(ex)

        finally:
            if error:            
                prompt.error(DevToolsMessage.ExecutionError.format(DevToolsConfigFile.InitHelpUrl))
        
        ret_result = OperationResult(self, None, None, None)
        return ret_result
示例#2
0
    def run_dev_tools_script(self):

        log.info('Running Dev Tools initialization script.')
        current_path = os.getcwd()

        try:
            if misc.is_os_windows():
                path = shell_utils.climb_dir_tree(
                    shell_utils.ori_path(), OSSpecific.WindowsClimbUpDepth)
                #TODO: replace current workaround for WindowsModuleScript
                current_path = os.getcwd()
                script_path = os.path.join(path,
                                           OSSpecific.WindowsModuleScriptPath)
                log.debug('Changing path to {0}.'.format(script_path))
                os.chdir(script_path)

                log.info('Running script "{0}".'.format(
                    OSSpecific.WindowsModuleScriptName))
                shell_utils.call([OSSpecific.WindowsModuleScriptName])

                log.debug('Changing path to {0}.'.format(current_path))
                os.chdir(current_path)

                log.info('Running script "{0}".'.format(
                    OSSpecific.WindowsRepoScript))
                fullpath = os.path.join(path, OSSpecific.WindowsRepoScript)
                shell_utils.call([fullpath])
            else:
                path = shell_utils.climb_dir_tree(shell_utils.ori_path(),
                                                  OSSpecific.LinuxClimbUpDepth)
                log.info('Running script "{0}" at {1}.'.format(
                    OSSpecific.LinuxRepoScript, path))
                fullpath = os.path.join(path, OSSpecific.LinuxRepoScript)
                shell_utils.call([fullpath])

        except subprocess.CalledProcessError as ex:
            # Git returned with an error code
            log.error(
                'Dev Tools initialiation script report an error, because "{0}".'
                .format(ex))
            prompt.error(DevToolsMessage.InitError)
            raise

        except (OSError, IOError) as ex:
            log.error(
                'Failed to call Dev Tools initialiation script, because "{0}".'
                .format(ex))
            # Cannot find or run script
            if ex.errno == FileErrorConstant.FileNotFoundErrorCode:
                prompt.error(DevToolsMessage.FileMissingError.format(fullpath))
            raise
    def run_dev_tools_script(self):

        log.info('Running Dev Tools initialization script.')
        current_path = os.getcwd()
        
        try:
            if misc.is_os_windows():
                path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.WindowsClimbUpDepth)
                #TODO: replace current workaround for WindowsModuleScript
                current_path = os.getcwd()
                script_path = os.path.join(path, OSSpecific.WindowsModuleScriptPath)
                log.debug('Changing path to {0}.'.format(script_path))
                os.chdir(script_path)

                log.info('Running script "{0}".'.format(OSSpecific.WindowsModuleScriptName))
                shell_utils.call([OSSpecific.WindowsModuleScriptName])
                
                log.debug('Changing path to {0}.'.format(current_path))
                os.chdir(current_path)
                
                log.info('Running script "{0}".'.format(OSSpecific.WindowsRepoScript))
                fullpath = os.path.join(path, OSSpecific.WindowsRepoScript)
                shell_utils.call([fullpath])
            else:
                path = shell_utils.climb_dir_tree(shell_utils.ori_path(), OSSpecific.LinuxClimbUpDepth)
                log.info('Running script "{0}" at {1}.'.format(OSSpecific.LinuxRepoScript,
                                                                path))
                fullpath = os.path.join(path, OSSpecific.LinuxRepoScript)
                shell_utils.call([fullpath])
                
        except subprocess.CalledProcessError as ex:
            # Git returned with an error code
            log.error('Dev Tools initialiation script report an error, because "{0}".'.format(ex))
            prompt.error(DevToolsMessage.InitError)
            raise
        
        except (OSError, IOError) as ex:
            log.error('Failed to call Dev Tools initialiation script, because "{0}".'.format(ex))
            # Cannot find or run script
            if ex.errno == FileErrorConstant.FileNotFoundErrorCode:
                prompt.error(DevToolsMessage.FileMissingError.format(fullpath))
            raise