예제 #1
0
파일: config.py 프로젝트: nsi-iff/pyOLS
from pyols.exceptions import PyolsConfigError
from pyols.config.configobj import ConfigObj

from pkg_resources import resource_filename
from os import path

class ConfigManager(ConfigObj):
    @staticmethod
    def default_config():
        """ Return a string containing the default configuration. """
        location = resource_filename('pyols', path.join('config', 'default.ini'))
        f = open(location)
        data = f.read()
        f.close()
        return data

    def load(self, file):
        """ Load config from 'file'. """
        self.filename = file
        self.write_empty_values = True
        self.file_error = True
        self.reload()

config = ConfigManager()

# The __name__ check here is needed to resolve some circular dependencies
if __name__ == '__main__':
    from pyols.tests import run_doctests
    run_doctests()
예제 #2
0
파일: env.py 프로젝트: nsi-iff/pyOLS
            mkdir(self.path())
        except OSError, e:
            raise PyolsValidationError("Cannot create a new environment:\n"\
                                       + str(e))
        mkfile('version', 'PyOLS environment version: %s' % self.version)
        mkfile(
            'README', 'A PyOLS environment.\n'
            'See http://nsi.cefetcampos.br/softwares/pyols/')
        mkfile('config.ini', config.default_config())

        gv_path = find_graphviz()
        if gv_path:
            config['graphviz_path'] = gv_path
        else:
            log.warning("Could not find graphviz binaries. Before PyOLS will "
                        "be able to generate graphs, the 'graphviz_path' "
                        "in pyols.ini will need to be set.")

        self.load(path, c)

        config.write()
        db.create_tables()

        log.info("Environment created at %r" % (path))


env = EnvironmentManager()

from pyols.tests import run_doctests
run_doctests()