Exemplo n.º 1
0
    def _setup_config(cls):
        default_conf = ConfigParser()
        default_conf._sections = _DEFAULT_CONFIG
        try:
            if not path.exists(_USER_CONF_PATH):
                ConfigWriter.write_config(_DEFAULT_CONFIG, _USER_CONF_PATH)
                user_conf = ConfigParser()
                user_conf._sections = _DEFAULT_CONFIG
            else:
                user_conf = cls._read_config(_USER_CONF_PATH)
                ConfigChecker.check_config('user configuration',
                                           _USER_CONF_PATH,
                                           user_conf._sections)
        except MissingSection as e:
            solution = ('falling back to default configuration.'
                        '\nDelete configuration file to restore defaults')
            ConfigChecker.warn_user(e, solution)
            user_conf = ConfigParser()
            user_conf.add_section('Settings')
        except MissingSetting as e:
            solution = ('falling back to default configuration.'
                        '\nSpecify setting to avoid using defaults')
            ConfigChecker.warn_user(e, solution)

        cls._config = cls._compose_config(default_conf, user_conf)

        try:
            if platform == 'win32':
                maxima_path_list = PathFinder.find_path_to(
                    cls._config['maxima_path'])
                if not len(maxima_path_list) > 0:
                    raise IOError(2,
                                  'No valid path to specified file',
                                  cls._config['maxima_path'])

                maxima_path = sorted(maxima_path_list)[-1]
                cls._config['maxima_path'] = maxima_path
            else:
                maxima_path = PathFinder.which('maxima')
                if not maxima_path:
                    raise IOError(2,
                                  'Maxima not installed',
                                  'command not found')
                cls._config['maxima_path'] = 'maxima'
        except IOError as e:
            solution = ('Please check that configuration file specifies '
                        'the correct path for Maxima and '
                        'that Maxima is installed correctly before '
                        'attempting to generate new results with SymCA '
                        '(see documentation for details).')
            ConfigChecker.warn_user(e, solution)
            cls._config['maxima_path'] = None

        cls._config['platform'] = platform
        cls._config['stdout'] = stdout
Exemplo n.º 2
0
    def _setup_config(cls):
        default_conf = ConfigParser()
        default_conf._sections = _DEFAULT_CONFIG
        try:
            if not path.exists(_USER_CONF_PATH):
                ConfigWriter.write_config(_DEFAULT_CONFIG, _USER_CONF_PATH)
                user_conf = ConfigParser()
                user_conf._sections = _DEFAULT_CONFIG
            else:
                user_conf = cls._read_config(_USER_CONF_PATH)
                ConfigChecker.check_config('user configuration',
                                           _USER_CONF_PATH,
                                           user_conf._sections)
        except MissingSection as e:
            solution = ('falling back to default configuration.'
                        '\nDelete configuration file to restore defaults')
            ConfigChecker.warn_user(e, solution)
            user_conf = ConfigParser()
            user_conf.add_section('Settings')
        except MissingSetting as e:
            solution = ('falling back to default configuration.'
                        '\nSpecify setting to avoid using defaults')
            ConfigChecker.warn_user(e, solution)

        cls._config = cls._compose_config(default_conf, user_conf)

        try:
            if platform == 'win32':
                maxima_path_list = PathFinder.find_path_to(
                    cls._config['maxima_path'])
                if not len(maxima_path_list) > 0:
                    raise IOError(2, 'No valid path to specified file',
                                  cls._config['maxima_path'])

                maxima_path = sorted(maxima_path_list)[-1]
                cls._config['maxima_path'] = maxima_path
            else:
                maxima_path = PathFinder.which('maxima')
                if not maxima_path:
                    raise IOError(2, 'Maxima not installed',
                                  'command not found')
                cls._config['maxima_path'] = 'maxima'
        except IOError as e:
            solution = ('Please check that configuration file specifies '
                        'the correct path for Maxima and '
                        'that Maxima is installed correctly before '
                        'attempting to generate new results with SymCA '
                        '(see documentation for details).')
            ConfigChecker.warn_user(e, solution)
            cls._config['maxima_path'] = None

        cls._config['platform'] = platform
        cls._config['stdout'] = stdout
Exemplo n.º 3
0
 def makeParser(fileName):
     parser = ConfigParser()
     # Default behaviour transforms to lower case: we want case-sensitive
     parser.optionxform = str
     # There isn't a nice way to change the behaviour on getting a duplicate section
     # so we use a nasty way :)
     parser._sections = ParserSectionDict(fileName)
     try:
         parser.read(fileName)
         parser._sections.readingFile = None
         return parser
     except Exception:
         plugins.printWarning("Bug file at " + fileName + " not understood, ignoring")
Exemplo n.º 4
0
 def makeParser(fileName):
     parser = ConfigParser()
     # Default behaviour transforms to lower case: we want case-sensitive
     parser.optionxform = str
     # There isn't a nice way to change the behaviour on getting a duplicate section
     # so we use a nasty way :)
     parser._sections = ParserSectionDict(fileName)
     try:
         parser.read(fileName)
         parser._sections.readingFile = None
         return parser
     except Exception:
         plugins.printWarning("Bug file at " + fileName + " not understood, ignoring")
Exemplo n.º 5
0
 def makeParser(self, fileName):
     parser = ConfigParser()
     # Default behaviour transforms to lower case: we want case-sensitive
     parser.optionxform = str
     parser._sections = seqdict()
     # There isn't a nice way to change the behaviour on getting a duplicate section
     # so we use a nasty way :)
     realLookup = parser._sections.__getitem__
     parser._sections.__getitem__ = plugins.Callable(self.lookupSection, fileName, realLookup)
     try:
         parser.read(fileName)
         parser._sections.__getitem__ = realLookup
         return parser
     except:
         plugins.printWarning("Bug file at " + fileName + " not understood, ignoring", stderr=True, stdout=False)