How to use the watchmaker.SystemFatal function in watchmaker

To help you get started, we’ve selected a few watchmaker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plus3it / watchmaker / src / watchmaker / __init__.py View on Github external
def _get_system_params(self):
        """
        Private method for handling the setup of the workspace and environment for the appropriate operating system.
        This method also creates the appropriate directories necessary for installation.

        """

        if 'Linux' in self.system:
            self.system_drive = '/'
            self._linux_paths()
        elif 'Windows' in self.system:
            self.system_drive = os.environ['SYSTEMDRIVE']
            self._windows_paths()
        else:
            self.logger.fatal('System, {0}, is not recognized?'.format(self.system))
            exceptionhandler('The scripts do not recognize this system type: {0}'.format(self.system))

        # Create watchmaker directories
        try:
            if not os.path.exists(self.system_params['logdir']):
                os.makedirs(self.system_params['logdir'])
            if not os.path.exists(self.system_params['workingdir']):
                os.makedirs(self.system_params['workingdir'])
        except Exception as exc:
            self.logger.fatal('Could not create a directory in {0}.\n'
                              'Exception: {1}'.format(self.system_params['prepdir'], exc))
            exceptionhandler(exc)
github plus3it / watchmaker / src / watchmaker / __init__.py View on Github external
self.logger.info(self.system_params)

        self._get_scripts_to_execute()
        self.logger.info('Got scripts to execute.')

        if 'Linux' in self.system:
            workers_manager = LinuxWorkersManager(self.s3, self.system_params, self.execution_scripts)
        elif 'Windows' in self.system:
            workers_manager = WindowsWorkersManager(self.s3, self.system_params, self.execution_scripts)
        else:
            exceptionhandler('There is no known System!')

        try:
            workers_manager.worker_cadence()
        except Exception as e:
            exceptionhandler('Execution of the workers cadence has failed. {0}'.format(e))

        if self.noreboot:
            self.logger.info('Detected `noreboot` switch. System will not be rebooted.')
        else:
            self.logger.info('Reboot scheduled. System will reboot after the script exits.')
            subprocess.call(self.system_params['restart'], shell=True)

        self.logger.info('-' * 80)
github plus3it / watchmaker / src / watchmaker / __init__.py View on Github external
self.system_drive = os.environ['SYSTEMDRIVE']
            self._windows_paths()
        else:
            self.logger.fatal('System, {0}, is not recognized?'.format(self.system))
            exceptionhandler('The scripts do not recognize this system type: {0}'.format(self.system))

        # Create watchmaker directories
        try:
            if not os.path.exists(self.system_params['logdir']):
                os.makedirs(self.system_params['logdir'])
            if not os.path.exists(self.system_params['workingdir']):
                os.makedirs(self.system_params['workingdir'])
        except Exception as exc:
            self.logger.fatal('Could not create a directory in {0}.\n'
                              'Exception: {1}'.format(self.system_params['prepdir'], exc))
            exceptionhandler(exc)
github plus3it / watchmaker / src / watchmaker / __init__.py View on Github external
"""

        self.logger.info('+' * 80)

        self._get_system_params()
        self.logger.info(self.system_params)

        self._get_scripts_to_execute()
        self.logger.info('Got scripts to execute.')

        if 'Linux' in self.system:
            workers_manager = LinuxWorkersManager(self.s3, self.system_params, self.execution_scripts)
        elif 'Windows' in self.system:
            workers_manager = WindowsWorkersManager(self.s3, self.system_params, self.execution_scripts)
        else:
            exceptionhandler('There is no known System!')

        try:
            workers_manager.worker_cadence()
        except Exception as e:
            exceptionhandler('Execution of the workers cadence has failed. {0}'.format(e))

        if self.noreboot:
            self.logger.info('Detected `noreboot` switch. System will not be rebooted.')
        else:
            self.logger.info('Reboot scheduled. System will reboot after the script exits.')
            subprocess.call(self.system_params['restart'], shell=True)

        self.logger.info('-' * 80)
github plus3it / watchmaker / src / watchmaker / __init__.py View on Github external
:return self.execution_scripts: Sets attribute with prepared configuration data for the target system.
        """

        self._get_config_data()

        scriptstoexecute = self.config[self.system]
        for item in self.config[self.system]:
            try:
                self.config[self.system][item]['Parameters'].update(self.kwargs)
            except Exception as exc:
                self.logger.fatal('For {0} in {1} the parameters could not be merged'.format(
                    item,
                    self.config_path
                ))
                exceptionhandler(exc)

        self.execution_scripts = scriptstoexecute