Beispiel #1
0
    def __check_post_install_update(self, settings, fast_mode, update=False):
        """
        Post-install/update checks
        :param settings: Settings instance
        :param fast_mode: Boolean indicating whether prompts must be displayed or not
        :return: Boolean indicating status
        """
        mode = ('update', 'updated') if update else ('install', 'installed')
        status = True

        if not fast_mode:
            if not self.check_command:
                logger.info('No check_command defined in settings for {tool}, will assume it is ' \
                'correctly {mode}'.format(tool=self.name_display, mode=mode[1]))
            else:
                logger.info(
                    'Now, checking if {tool} has been {mode} correctly. Hit any key to run test...'
                    .format(tool=self.name_display, mode=mode[1]))
                CLIUtils.getch()
                status = self.__run_check_command()

        # Change install status in configuration file
        if status:
            try:
                if settings.change_installed_status(self.target_service,
                                                    self.name_clean,
                                                    install_status=True):
                    logger.success(
                        'Tool {tool} has been marked as successfully {mode}'.
                        format(tool=self.name_display, mode=mode[1]))
                    return True
                else:
                    logger.error(
                        'Error when updating configuration file "{filename}{ext}"'
                        .format(filename=INSTALL_STATUS_CONF_FILE,
                                ext=CONF_EXT))
                    return False
            except SettingsException as e:
                logger.error('An unexpected error occured when trying to mark the tool as {mode}: ' \
                    '{exception}'.format(exception=e, mode=mode[1]))
                if not update:
                    self.remove(settings)
                return False
        else:
            logger.warning('Tool {tool} has not been marked as {mode}'.format(
                tool=self.name_display, mode=mode[1]))
            if not update:
                self.remove(settings)
            else:
                if not fast_mode and Output.prompt_confirm(
                        'Do you want to try to re-install ?', default=True):
                    return self.__reinstall(settings, fast_mode)
            return False
Beispiel #2
0
    def checkInstall(self, output, referencing_tool=None):
        """
		Check if the tool is correctly installed.
		Basically, it runs the installed tool without any option

		@Args		output: 	CLIOutput instance
		@Returns	Boolean indicating status
		"""

        output.printInfo('Trying to run the tool {0} with no option...'.format(
            self.name))
        if referencing_tool:
            cmd, cmd_short = referencing_tool.command.getParsedCmdline(
                remove_args=True)
        elif self.command:
            cmd, cmd_short = self.command.getParsedCmdline(remove_args=True)
        else:
            raise Exception

        output.printBeginCmd(cmd_short)
        process = ProcessLauncher(cmd, output, None)
        process.start()
        output.printEndCmd()

        output.printPrompt(
            'Does the tool {0} seem to be running correctly ? [Y/n]'.format(
                self.name))
        return CLIUtils.promptYesNo(output, default='Y')
Beispiel #3
0
    def checkInstall(self, output):
        """
		Check if the tool is correctly installed.
		Basically, it runs the installed tool without any option
		@Args		output: 	CLIOutput instance
		@Returns	Boolean indicating status
		"""

        # Directory where the tool should be installed
        if not FileUtils.is_dir(self.tool_dir):
            output.printFail(
                'Directory where the tool should be installed (\'{0}\') does not exist !'
                .self.tool_dir)
            return False

        # Try to run the tool
        output.printInfo('Trying to run the tool {0}...'.format(self.name))
        splitted = self.command.strip().split(' ')

        cmd = ''
        if splitted[0].lower() == 'sudo' and len(splitted) > 1:
            cmd = 'sudo '
            splitted = splitted[1:]
        cmd += splitted[0]

        if splitted[0].lower() in ('python', 'python3', 'perl',
                                   'ruby') and len(splitted) > 1:
            if splitted[1] != '-m':
                cmd += ' {0}'.format(splitted[1])
            elif len(splitted) > 2:
                cmd += ' -m {0}'.format(splitted[2])

        elif splitted[0].lower() == 'java' and len(splitted) > 2:
            if splitted[1].lower() == '-jar':
                cmd += ' -jar {0}'.format(splitted[2])

        c = Command(self.tool_dir, cmd, None, self.toolbox_dir, None, None,
                    None, None)
        cmd_check = c.getStandardCommandLine()
        cmd_check_print = cmd_check[cmd_check.index(';') + 1:].strip()

        output.printBeginCmd(cmd_check_print)
        process = ProcessLauncher(cmd_check, output, None)
        process.start()
        output.printEndCmd()

        # Prompt
        output.printPrompt(
            'Does the tool {0} seem to be running correctly ? [Y/n]'.format(
                self.name))
        return CLIUtils.promptYesNo(output, default='Y')
Beispiel #4
0
    def runToolboxAgainstService(self):
        """
		Run the tools from the toolbox that target the service chosen by the user.
		Categories selection is taken into account.
		"""
        service = self.arguments.args.service
        for cat in self.arguments.selected_tools_categories:
            print
            self.output.printTitle0('Tools Category - {0}'.format(cat))
            if not self.settings.toolbox.tools[service][cat]:
                self.output.printInfo('No tool to run in this category')
                continue

            if not self.arguments.args.auto_yes:
                self.output.printPrompt('Run tools in this category ? [Y/n]')
                if not CLIUtils.promptYesNo(self.output, default='Y'):
                    self.output.printWarning('Category skipped.')
                    continue

            output_dir = FileUtils.concat_path(self.arguments.args.output_dir,
                                               cat)
            if not FileUtils.create_directory(output_dir):
                self.output.printFail(
                    'Impossible to create output subdir "{0}"'.format(subdir))
                sys.exit(0)
            self.output.printInfo(
                'Output subdir "{0}" created'.format(output_dir))
            for tool in self.settings.toolbox.tools[service][cat]:
                print
                self.output.printTitle1('   ' + tool.name)

                try:
                    tool.runTool(
                        self.settings,
                        self.output,
                        output_dir,
                        self.arguments.target,
                        self.arguments.specific,
                        ignore_specific=self.arguments.args.ignore_specific,
                        auto_yes=self.arguments.args.auto_yes)
                except KeyboardInterrupt, SystemExit:
                    print
                    self.output.printError('Tool execution aborted')
                print
Beispiel #5
0
    def runTool(self,
                settings,
                output,
                output_file,
                output_dir,
                target,
                specific_args,
                ignore_specific=False,
                auto_yes=False):
        """
		Run the tool 
		@Args		settings: 		instance of Settings
					output: 		instance of CLIOutput
					output_file:	file where tool execution output will be saved
					output_dir:		some tools (e.g. skipfish) require an output dir where results are saved
					target:			instance of Target
					specific_args:	specific arguments
					always_run: 	boolean indicating if tool should be always run (ignoring context specific options)
					auto_yes: 		boolean indicating if prompt should be displayed or not before running
		@Returns	Boolean indicating status
		"""
        # Tool not installed yet
        if not self.installed:
            output.printInfo(
                '{0} is not installed yet (according to config), skipped.'.
                format(self.name))
            return False

        # If context specific
        if self.specific_options:
            for opt in self.specific_options.keys():
                # Boolean option
                if self.specific_options[opt][0] == bool:
                    if self.specific_options[opt][1] == True and (
                            opt not in specific_args.keys()
                            or specific_args[opt] == False):
                        output.printInfo(
                            'Tool skipped. Specific to: {0} = True'.format(
                                opt))
                        return False
                    #elif self.specific_options[opt][1] == False and opt in specific_args.keys() and specific_args[opt] == True:
                    #	output.printInfo('Tool skipped. Specific to: {0} = False'.format(opt))
                    #	return False

                # List option
                elif self.specific_options[opt][
                        0] == list and self.specific_options[opt][1]:
                    if opt not in specific_args.keys() or \
                       specific_args[opt] != 'all' and specific_args[opt] not in self.specific_options[opt][1]:
                        output.printInfo(
                            'Tool skipped. Specific to: {0} = {1}'.format(
                                opt, ', '.join(self.specific_options[opt][1])))
                        return False

        # Run command parsing
        cmd_run = self.getRunCmd(target, output_file, output_dir,
                                 specific_args)
        cmd_run_print = self.getSimplifiedRunCmd(cmd_run)
        output.printInfo('Command:')
        output.printInfo(cmd_run_print)
        if not auto_yes:
            output.printPrompt('Run tool ? [Y/n/t/w/q]'.format(
                self.category, self.name))
            # Prompt
            to_run = CLIUtils.promptRunMode(output, default='Y')

        # Run update command if wanted
        if auto_yes or to_run == 'Yes':
            output.printBeginCmd(cmd_run_print)
            process = ProcessLauncher(cmd_run, output, None)
            process.start()
            output.printEndCmd()
        elif to_run == 'Tab':
            #TODO
            pass
        elif to_run == 'Window':
            output.printBeginCmd(cmd_run_print)
            process = ProcessLauncher(cmd_run, output, None)
            process.startInNewWindow()
            print
            output.printInfo('Started in another window.')
            output.printEndCmd()
        elif to_run == 'Quit':
            print
            output.printWarning('Exit !')
            sys.exit(0)

        print
Beispiel #6
0
    def runUpdate(self, settings, output):
        """
		Run the update for the tool 
		@Args		settings: 	Settings instance
					output: 	CLIOutput instance
		@Returns	Boolean indicating status
		"""
        # Tool not installed yet
        if not self.installed:
            output.printInfo(
                '{0} is not installed yet (according to config), skipped.'.
                format(self.name))
            print
            return False

        # Not installed, but no update command specified
        elif not self.update:
            output.printWarning(
                'No tool update command specified in config file, skipped.')
            print
            return False

        # Create directory for the tool if necessary (should not be necessary because only update)
        if not FileUtils.is_dir(self.tool_dir):
            output.printFail(
                'Tool directory does not exist but tool marked as installed. Trying to re-install it...'
            )
            return self.runInstall(settings, output)

        # Update command parsing
        cmd_update = self.getUpdateCmd()
        cmd_update_print = cmd_update[cmd_update.index(';') + 1:].strip()
        output.printInfo('Update Command:')
        output.printInfo(cmd_update_print)
        output.printPrompt('{0} > {1} - Update ? [Y/n]'.format(
            self.category, self.name))
        # Prompt
        to_update = CLIUtils.promptYesNo(output, default='Y')

        # Run update command if wanted
        if to_update:
            output.printBeginCmd(cmd_update_print)
            process = ProcessLauncher(cmd_update, output, None)
            process.start()
            output.printEndCmd()

            output.printSuccess('Tool update has finished')

            output.printInfo('Now, checking if {0} has been updated correctly. '.format(self.name) + \
             'Hit any key to run test...')
            CLIUtils.getch()

            # Check update, update config options
            if self.checkInstall(output):
                if not settings.changeLastUpdateOption(self.service_name,
                                                       self.section_name):
                    output.printWarning(
                        'An unexpected error occured when trying to last update date.'
                    )
                else:
                    output.printSuccess(
                        'Tool {0} has been marked as successfully updated.'.
                        format(self.name))
            else:
                # If test fails, ask user if re-install ?
                output.printFail(
                    'Tool {0} has not been marked as updated.'.format(
                        self.name))
                output.printPrompt(
                    'Do you want to try to re-install {0} ? [Y/n]'.format(
                        self.name))

                # Prompt
                to_reinstall = CLIUtils.promptYesNo(output, default='Y')

                # Re-Install
                if to_reinstall:
                    self.reinstallTool(settings, output)
        else:
            output.printFail('Tool has not been updated')

        print
Beispiel #7
0
    def runInstall(self, settings, output):
        """
		Install the tool
		@Args		settings: 	Settings instance
					output: 	CLIOutput instance
		@Returns	Boolean indicating status
		"""

        # Tool already marked as installed
        if self.installed:
            #if not FileUtils.is_dir(self.tool_dir):
            #	output.printInfo('{0} marked as installed in config, but directory does not exist. Will try to install it'.format(self.name))
            # elif FileUtils.is_directory_empty(self.tool_dir):
            # 	output.printInfo('{0} marked as installed in config, but directory empty. Will try to install it'.format(self.name))
            #else:
            output.printInfo(
                '{0} is already installed (according to config), skipped.'.
                format(self.name))
            print
            return False

        # Not installed, but no install command specified
        elif not self.install:
            output.printWarning(
                'No tool install command specified in config file, skipped.')
            output.printPrompt(
                'Do you want to mark this tool as installed ? [y/N]')
            to_mark = CLIUtils.promptYesNo(output, default='N')
            if to_mark:
                if not settings.changeInstalledOption(
                        self.service_name, self.section_name, 'True'):
                    output.printError(
                        'An unexpected error occured when trying to mark the tool as installed !'
                    )
                else:
                    output.printSuccess(
                        'Tool {0} has been marked as installed. '.format(
                            self.name))
            else:
                output.printInfo('Tool is still not marked as installed')
            print
            return False

        # Create directory for the tool if necessary
        if not self.createToolDirectory(output):
            output.printFail('Tool install skipped.')
            print
            return False

        # Install command parsing
        cmd_install = self.getInstallCmd()
        cmd_install_print = cmd_install[cmd_install.index(';') + 1:].strip()
        output.printInfo('Install Command:')
        output.printInfo(cmd_install_print)
        output.printPrompt('{0} > {1} - Install ? [Y/n]'.format(
            self.category, self.name))

        # Prompt
        to_install = CLIUtils.promptYesNo(output, default='Y')

        # Run install command if wanted
        if to_install:
            output.printBeginCmd(cmd_install)
            process = ProcessLauncher(cmd_install, output, None)
            process.start()
            output.printEndCmd()

            output.printSuccess('Tool installation has finished')
            output.printInfo('Now, checking if {0} has been installed correctly. '.format(self.name) + \
             'Hit any key to run test...')
            CLIUtils.getch()

            # Check install, update config options
            if self.checkInstall(output):
                if not settings.changeInstalledOption(
                        self.service_name, self.section_name, 'True'):
                    output.printError(
                        'An unexpected error occured when trying to mark the tool as installed !'
                    )
                else:
                    output.printSuccess(
                        'Tool {0} has been marked as installed. '.format(
                            self.name))
                    if not settings.changeLastUpdateOption(
                            self.service_name, self.section_name):
                        output.printWarning(
                            'An unexpected error occured when trying to change last update date'
                        )
            else:
                output.printFail(
                    'Tool {0} is still not marked as installed.'.format(
                        self.name))
                self.removeTool(settings, output)
        else:
            output.printFail('Tool has not been installed')

        print
Beispiel #8
0
    def __check_post_install_update(self, settings, fast_mode=False, update=False):
        """
        Perform some operation after install/update:
            - Check if correctly installed by running "check_command" and prompting,
            - Update install status in configuration file.

        :param Settings settings: Settings from config files
        :param bool fast_mode: Set to true to disable prompts
        :param update: Mode selector, True for update | False for install (default)
        :return: Status of operations
        :rtype: bool
        """
        mode = ('update','updated') if update else ('install','installed')
        status = True

        # Check install/update
        if not fast_mode:
            if not self.check_command:
                logger.info('No check_command defined in settings for {tool}, will ' \
                    'assume it is correctly {mode}'.format(tool=self.name, mode=mode[1]))
            else:
                logger.info('Now, checking if {tool} has been {mode} correctly. ' \
                    'Hit any key to run test...'.format(tool=self.name, mode=mode[1]))
                CLIUtils.getch()
                status = self.__run_check_command()

        # Change install status in configuration file
        if status:
            try:

                if settings.change_installed_status(self.target_service, 
                                                    self.name, 
                                                    install_status=True):

                    logger.success('Tool {tool} has been marked as successfully ' \
                        '{mode}'.format(tool=self.name, mode=mode[1]))
                    return True
                else:
                    logger.error('Error when updating configuration file ' \
                        '"{filename}{ext}"'.format(
                            filename=INSTALL_STATUS_CONF_FILE, ext=CONF_EXT))
                    return False

            except SettingsException as e:
                logger.error('An unexpected error occured when trying to mark the '\
                    'tool as {mode}: {exc}'.format(mode=mode[1], exc=e))

                if not update:
                    self.remove(settings)
                return False
        else:
            logger.warning('Tool {tool} has not been marked as {mode}'.format(
                tool=self.name, mode=mode[1]))
            if not update:
                self.remove(settings)
            else:
                if not fast_mode \
                   and Output.prompt_confirm('Do you want to try to re-install ?', 
                                             default=True):

                    return self.__reinstall(settings, fast_mode)

            return False
Beispiel #9
0
	def runTool(self, 
				settings, 
				output, 
				output_dir, 
				target, 
				specific_args, 
				ignore_specific=False,
				auto_yes=False):
		"""
		Run the tool

		@Args		settings: 		instance of Settings
					output: 		instance of CLIOutput
					output_dir:		directory where tool execution output will be saved
					target:			instance of Target
					specific_args:	specific arguments
					always_run: 	boolean indicating if tool should be always run (ignoring context specific options)
					auto_yes: 		boolean indicating if prompt should be displayed or not before running
		@Returns	Boolean indicating status
		"""
		# Tool not installed yet
		if not self.installed:
			output.printInfo('{0} is not installed yet (according to config), skipped.'.format(self.name))
			return False

		# If context specific
		if self.specific_options and not ignore_specific:
			for opt in self.specific_options.keys():
				# Boolean option
				if self.specific_options[opt][0] == bool:
					if self.specific_options[opt][1] == True and (opt not in specific_args.keys() or specific_args[opt] == False):
						output.printInfo('Tool skipped. Specific to: {0} = True'.format(opt))
						return False

				# List option
				elif self.specific_options[opt][0] == list and self.specific_options[opt][1]: 
					if opt not in specific_args.keys() or \
					   specific_args[opt] != 'all' and specific_args[opt] not in self.specific_options[opt][1]:
						output.printInfo('Tool skipped. Specific to: {0} = {1}'.format(opt, ', '.join(self.specific_options[opt][1])))
						return False

		# Print basic info and prompt confirmation
		cmd, cmd_short = self.command.getParsedCmdline(output_dir=output_dir, 
													   output_filename=self.name+'.txt',
													   target=target,
													   specific_args=specific_args)
		output.printInfo('Description : {0}'.format(self.description))
		output.printInfo('Run command : {0}'.format(cmd_short))
		if not auto_yes: 
			output.printPrompt('Run tool ? [Y/n/t/w/q]'.format(self.category, self.name))
			to_run = CLIUtils.promptRunMode(output, default='Y')
		else:
			to_run = 'Yes'

		# Run command if wanted
		if to_run == 'Quit':
			print
			output.printWarning('Exit !')
			sys.exit(0)
		elif to_run != 'No':
			output.printBeginCmd(cmd_short)
			process = ProcessLauncher(cmd, output, None)			
			# Normal running
			if auto_yes or to_run == 'Yes':
				process.start()

			# Start in new tab
			elif to_run == 'Tab':
				# TODO
				output.printInfo('Not yet implemented')

			# Start in new window
			elif to_run == 'Window':
				process.startInNewWindow()
				print
				output.printInfo('Started in another window')
			output.printEndCmd()
		print	
Beispiel #10
0
	def runUpdate(self, settings, output, fast_mode=False, referencing_tool=None):
		"""
		Run the update for the tool 

		@Args		settings: 	Settings instance
					output: 	CLIOutput instance
		@Returns	Boolean indicating status
		"""

		# Check for cases where no update will be run
		if not self.installed:
			output.printInfo('{0} is not installed yet (according to config), skipped.'.format(self.name))
			print
			return False

		elif self.tooltype == ToolType.USE_MULTI:
			output.printInfo('This is a reference to the tool "{0}", which is not specific to the service {1}'.format(self.tool_ref_name, self.service_name))
			ref_tool = settings.toolbox.searchInToolboxForService(self.tool_ref_name, Constants.MULTI_SERVICES_CONF_FILE)
			if ref_tool:
				return ref_tool.runUpdate(settings, output, fast_mode=fast_mode, referencing_tool=self)
			else:
				output.printFail('The tool "{0}" has not been found inside the conf file "{1}{2}"'.format(self.tool_ref_name, \
					Constants.MULTI_SERVICES_CONF_FILE, Constants.CONF_EXT))
				return False

		elif not self.update:
			output.printWarning('No tool update command specified in config file, skipped.')
			print
			return False

		# Create directory for the tool if necessary (should not be necessary because only update)
		if not FileUtils.is_dir(self.tool_dir):
			output.printFail('Tool directory does not exist but tool marked as installed. Trying to re-install it...')
			return self.runInstall(settings, output, fast_mode)

		# Print basic info and prompt confirmation
		cmd, cmd_short = self.update.getParsedCmdline()
		output.printInfo('Description     : {0}'.format(self.description))
		output.printInfo('Install command : {0}'.format(cmd_short))
		if not fast_mode: output.printPrompt('Update ? [Y/n]')

		# Run update command if wanted
		if fast_mode or CLIUtils.promptYesNo(output, default='Y'):
			output.printBeginCmd(cmd_short)
			process = ProcessLauncher(cmd, output, None)
			process.start()
			output.printEndCmd()
			output.printSuccess('Tool update has finished')

			# Check install ?
			update_ok = True
			if not (self.tooltype == ToolType.MULTI_SERVICES and not referencing_tool) and not fast_mode:
				output.printInfo('Now, checking if {0} has been updateed correctly. Hit any key to run test...'.format(self.name))
				CLIUtils.getch()
				try:
					update_ok = self.checkInstall(output, referencing_tool=referencing_tool)
				except Exception as e:
					update_ok = False
					output.printError('An unexpected error occured when checking install: {0}'.format(e))

			# Change install status in configuration file
			if update_ok:
				try:
					if settings.changeInstalledOption(self.service_name, self.name, True):
						output.printSuccess('Tool {0} has been marked as successfully updated'.format(self.name))
					else:
						output.printError('Error when saving "{0}{1}" configuration file'.format(Constants.INSTALL_STATUS_CONF_FILE, Constants.CONF_EXT))
				except Exception as e:
					output.printError('An unexpected error occured when trying to change the last update date: {0}'.format(e))
					#self.removeTool(settings, output)
			else:
				output.printFail('Tool {0} has not been marked as updated'.format(self.name))
				#self.removeTool(settings, output)
				output.printPrompt('Do you want to try to re-install {0} ? [Y/n]'.format(self.name))
				if CLIUtils.promptYesNo(output, default='Y'):
					self.reinstallTool(settings, output, referencing_tool=referencing_tool)
		else:
			output.printFail('Tool has not been updated')
		print
Beispiel #11
0
	def runInstall(self, settings, output, fast_mode=False, referencing_tool=None):
		"""
		Install the tool

		@Args		settings: 	Settings instance
					output: 	CLIOutput instance
					fast_mode:	Boolean. If True, do not prompt confirm before install and do not check install after
		@Returns	Boolean indicating status
		"""

		# Check for cases where no install will be run
		if self.installed:
			if self.tooltype == ToolType.USE_MULTI:
				output.printInfo('This is a reference to the tool "{0}" which is already installed, skipped.'.format(self.tool_ref_name))
			else:
				output.printInfo('{0} is already installed (according to config), skipped.'.format(self.name))
			print
			return False

		elif self.tooltype == ToolType.USE_MULTI:
			output.printInfo('This is a reference to the tool "{0}", which is not specific to the service {1}'.format(self.tool_ref_name, self.service_name))
			ref_tool = settings.toolbox.searchInToolboxForService(self.tool_ref_name, Constants.MULTI_SERVICES_CONF_FILE)
			if ref_tool:
				return ref_tool.runInstall(settings, output, fast_mode=fast_mode, referencing_tool=self)
			else:
				output.printFail('The tool "{0}" has not been found inside the conf file "{1}{2}"'.format(self.tool_ref_name, \
					Constants.MULTI_SERVICES_CONF_FILE, Constants.CONF_EXT))
				return False

		elif not self.install:
			output.printWarning('No tool install command specified in config file, skipped')
			if not fast_mode: output.printPrompt('Do you want to mark this tool as installed ? [Y/n]')
			if fast_mode or CLIUtils.promptYesNo(output, default='Y'):
				try:
					if settings.changeInstalledOption(self.service_name, self.name, True):
						output.printSuccess('Tool {0} has been marked as installed. '.format(self.name))
					else:
						output.printError('Error when saving "{0}{1}" configuration file'.format(Constants.INSTALL_STATUS_CONF_FILE, Constants.CONF_EXT))
				except Exception as e:
					output.printError('An unexpected error occured when trying to mark the tool as installed')
					self.removeTool(settings, output)
			else:
				output.printInfo('Tool is still not marked as installed')
			print
			return False

		# Create directory for the tool if necessary
		if not self.createToolDirectory(output):
			output.printFail('Tool install skipped.')
			print
			return False

		# Print basic info and prompt confirmation
		cmd, cmd_short = self.install.getParsedCmdline()
		output.printInfo('Description     : {0}'.format(self.description))
		output.printInfo('Install command : {0}'.format(cmd_short))
		if not fast_mode: output.printPrompt('Install ? [Y/n]')

		# Run install command if wanted
		if fast_mode or CLIUtils.promptYesNo(output, default='Y'):
			output.printBeginCmd(cmd_short)
			process = ProcessLauncher(cmd, output, None)
			process.start()
			output.printEndCmd()
			output.printSuccess('Tool installation has finished')

			# Check install ?
			install_ok = True
			if not (self.tooltype == ToolType.MULTI_SERVICES and not referencing_tool) and not fast_mode:
				output.printInfo('Now, checking if {0} has been installed correctly. Hit any key to run test...'.format(self.name))
				CLIUtils.getch()
				try:
					install_ok = self.checkInstall(output, referencing_tool=referencing_tool)
				except Exception as e:
					install_ok = False
					output.printError('An unexpected error occured when checking install: {0}'.format(e))

			# Change install status in configuration file
			if install_ok:
				try:
					if settings.changeInstalledOption(self.service_name, self.name, True):
						output.printSuccess('Tool {0} has been marked as installed. '.format(self.name))
					else:
						output.printError('Error when saving "{0}{1}" configuration file'.format(Constants.INSTALL_STATUS_CONF_FILE, Constants.CONF_EXT))
				except Exception as e:
					output.printError('An unexpected error occured when trying to mark the tool as installed: {0}'.format(e))
					self.removeTool(settings, output)
			else:
				output.printFail('Tool {0} has not been marked as installed'.format(self.name))
				self.removeTool(settings, output)
		else:
			output.printFail('Tool has not been installed')
		print
Beispiel #12
0
            # Print config
            output.printTitle0('Configuration:')
            self.arguments.printSummary(output)

            # Processing
            for cat in self.arguments.selected_tools_categories:
                print
                output.printTitle0('Tools Category - {0}'.format(cat))
                if not self.settings.toolbox.tools[service][cat]:
                    output.printInfo('No tool to run in this category')
                    continue

                if not self.arguments.args.auto_yes:
                    output.printPrompt('Run tools in this category ? [Y/n]')
                    # Prompt
                    to_run = CLIUtils.promptYesNo(output, default='Y')
                    if not to_run:
                        output.printWarning('Category skipped.')
                        continue

                subdir = FileUtils.concat_path(self.arguments.args.output_dir,
                                               cat)
                if not FileUtils.create_directory(subdir):
                    output.printFail(
                        'Impossible to create output subdir "{0}"'.format(
                            subdir))
                    sys.exit(0)
                output.printInfo('Output subdir "{0}" created'.format(subdir))
                for tool in self.settings.toolbox.tools[service][cat]:
                    print
                    output.printTitle1('   ' + tool.name)