Esempio n. 1
0
    def setUp(self):
        stopAgentGlobals()
        startAgentGlobals()
        self.threadMgr = pylons.config['pylons.app_globals'].threadMgr

        path = os.path.realpath(__file__)
        self.scriptDir = os.path.join(os.path.dirname(path), 'scripts')
Esempio n. 2
0
    def setUp(self):
        stopAgentGlobals()
        startAgentGlobals()
        self.threadMgr = pylons.config['pylons.app_globals'].threadMgr

        path = os.path.realpath(__file__)
        self.scriptDir = os.path.join(os.path.dirname(path), 'scripts')
Esempio n. 3
0
def commonSetup():
    stopAgentGlobals()

    if removeAgentRoot() and not os.path.exists(pylons.config['agent_root']):
        os.mkdir(pylons.config['agent_root'])

    assert os.path.exists(pylons.config['agent_root'])
    startAgentGlobals(startAgentMonitor = False, startPackageMgr = False)
Esempio n. 4
0
def commonSetup():
    stopAgentGlobals()

    if removeAgentRoot() and not os.path.exists(pylons.config['agent_root']):
        os.mkdir(pylons.config['agent_root'])

    assert os.path.exists(pylons.config['agent_root'])
    startAgentGlobals(startAgentMonitor=False, startPackageMgr=False)
Esempio n. 5
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    config = PylonsConfig()

    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='agent', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)

    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8',
        default_filters=['escape'],
        imports=['from webhelpers.html import escape'])

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    pylons.config.update(config)

    # create the base directory for the agent
    path = os.path.join(config['agent_root'], 'service_nodes')
    if not os.path.exists(path):
        os.makedirs(path)

    path = os.path.join(config['agent_root'], 'packages')
    if not os.path.exists(path):
        os.makedirs(path)

    # create directories for distribution client
    # If repo_root is not specified, assume it is same as agent_root
    if config['repo_root'] is None or config['repo_root'] == '':
        config['repo_root'] = config['agent_root']
    path = config['repo_root']
    if not os.path.exists(path):
        os.makedirs(path)

    # start the agent globals
    startAgentGlobals()

    return config
Esempio n. 6
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    config = PylonsConfig()

    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='agent', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)

    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8', default_filters=['escape'],
        imports=['from webhelpers.html import escape'])

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    pylons.config.update(config)

    # create the base directory for the agent
    path = os.path.join(config['agent_root'], 'service_nodes')
    if not os.path.exists(path):
        os.makedirs(path)

    path = os.path.join(config['agent_root'], 'packages')
    if not os.path.exists(path):
        os.makedirs(path)

    # create directories for distribution client
    # If repo_root is not specified, assume it is same as agent_root
    if config['repo_root'] is None or config['repo_root'] == '':
        config['repo_root'] = config['agent_root']
    path = config['repo_root']
    if not os.path.exists(path):
        os.makedirs(path)

    # start the agent globals
    startAgentGlobals()

    return config
Esempio n. 7
0
    def test_init(self):
        # test the init routine

        # make sure that the initial path is cleared out of IN Progress nodes
        tmpFile = os.path.join(PackageMgr.packagePath(), 'foo.inprogress')
        open(tmpFile, 'w').close()

        tmpFile2 = os.path.join(PackageMgr.packagePath(), 'foo2.inprogress')
        open(tmpFile2, 'w').close()

        stopAgentGlobals()
        startAgentGlobals()
Esempio n. 8
0
    def test_init(self):
        # test the init routine

        # make sure that the initial path is cleared out of IN Progress nodes
        tmpFile = os.path.join(PackageMgr.packagePath(), 'foo.inprogress')
        open(tmpFile, 'w').close()

        tmpFile2 = os.path.join(PackageMgr.packagePath(), 'foo2.inprogress')
        open(tmpFile2, 'w').close()

        stopAgentGlobals()
        startAgentGlobals()
Esempio n. 9
0
    def test_cleanupPackages(self):
        stopAgentGlobals()

        # ok now let's create the directory structure of a bad service and packages
        packagePath = PackageMgr.packagePath()
        inProgPackage2 = os.path.join(packagePath, 'bar.inprogress')
        inProgPackage1 = os.path.join(packagePath, 'foo.inprogress')
        goodPackage1 = os.path.join(packagePath, 'baz')
        goodPackage2 = os.path.join(packagePath, 'baz')

        open(inProgPackage1, 'w').close()
        open(inProgPackage2, 'w').close()
        open(goodPackage1, 'w').close()
        open(goodPackage2, 'w').close()

        startAgentGlobals()
        # we remove logic of inprogress file cleanup from packagemgr
        #        assert not os.path.exists(inProgPackage1)
        #        assert not os.path.exists(inProgPackage2)

        assert os.path.exists(goodPackage1)
        assert os.path.exists(goodPackage2)
Esempio n. 10
0
    def test_cleanupPackages(self):
        stopAgentGlobals()

        # ok now let's create the directory structure of a bad service and packages
        packagePath = PackageMgr.packagePath()
        inProgPackage2 = os.path.join(packagePath, 'bar.inprogress')
        inProgPackage1 = os.path.join(packagePath, 'foo.inprogress')
        goodPackage1 = os.path.join(packagePath, 'baz')
        goodPackage2 = os.path.join(packagePath, 'baz')

        open(inProgPackage1, 'w').close()
        open(inProgPackage2, 'w').close()
        open(goodPackage1, 'w').close()
        open(goodPackage2, 'w').close()

        startAgentGlobals()
        # we remove logic of inprogress file cleanup from packagemgr
#        assert not os.path.exists(inProgPackage1)
#        assert not os.path.exists(inProgPackage2)

        assert os.path.exists(goodPackage1)
        assert os.path.exists(goodPackage2)
Esempio n. 11
0
 def setUp(self):
     stopAgentGlobals()
     startAgentGlobals()