示例#1
0
    def test_env_variable_with_vars_module_import_with_shortcuts(self):
        """testing if the module path has shortcuts like ~ and other env
        variables
        """
        splits = os.path.split(self.temp_config_folder)
        var1 = splits[0]
        var2 = os.path.sep.join(splits[1:])

        os.environ["var1"] = var1
        os.environ["var2"] = var2
        os.environ["OYPROJECTMANAGER_PATH"] = "$var1/$var2"

        test_value = "sqlite3:///.test_value.db"
        config_file = open(self.config_full_path, "w")
        config_file.writelines([
            "#-*- coding: utf-8 -*-\n", 'database_url = "' + test_value + '"\n'
        ])
        config_file.close()

        # now import the config.py and see if it updates the
        # database_file_name variable
        from oyProjectManager import config
        conf = config.Config()

        self.assertEqual(test_value, conf.database_url)
示例#2
0
 def test_non_existing_path_in_environment_variable(self):
     """testing if the non existing path situation will be handled
     gracefully by warning the user
     """
     os.environ["OYPROJECTMANAGER_PATH"] = "/tmp/non_existing_path"
     from oyProjectManager import config
     config.Config()
示例#3
0
    def test_config_variable_updates_with_user_config(self):
        """testing if the database_file_name will be updated by the user
        config
        """
        # now create a config.py file and fill it with the desired values
        # like database_file_name = "test_value.db"
        test_value = ".test_value.db"
        config_file = open(self.config_full_path, "w")
        config_file.writelines([
            "#-*- coding: utf-8 -*-\n", 'database_url = "' + test_value + '"\n'
        ])
        config_file.close()

        # now import the config.py and see if it updates the
        # database_file_name variable
        from oyProjectManager import config
        conf = config.Config()

        self.assertEqual(test_value, conf.database_url)
示例#4
0
    def test_config_variable_doesnt_create_new_variables_with_user_config(
            self):
        """testing if the config will not be updated by the user config by
        adding new variables
        """
        # now create a config.py file and fill it with the desired values
        # like database_file_name = "test_value.db"
        test_value = ".test_value.db"
        config_file = open(self.config_full_path, "w")
        config_file.writelines([
            "#-*- coding: utf-8 -*-\n", 'test_value = "' + test_value + '"\n'
        ])
        config_file.close()

        # now import the config.py and see if it updates the
        # database_file_name variable
        from oyProjectManager import config
        conf = config.Config()

        self.assertRaises(KeyError, getattr, conf, "test_value")
示例#5
0
# This module is part of oyProjectManager and is released under the BSD 2
# License: http://www.opensource.org/licenses/BSD-2-Clause

import os
import logging
from sqlalchemy.sql.expression import distinct

import oyProjectManager
from oyProjectManager import config, db
from oyProjectManager.models.asset import Asset

# create a logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)

conf = config.Config()

qt_module_key = "PREFERRED_QT_MODULE"
qt_module = "PyQt4"

if os.environ.has_key(qt_module_key):
    qt_module = os.environ[qt_module_key]

if qt_module == "PySide":
    from PySide import QtGui, QtCore
    from oyProjectManager.ui import create_asset_dialog_UI_pyside as create_asset_dialog_UI
elif qt_module == "PyQt4":
    import sip
    sip.setapi('QString', 2)
    sip.setapi('QVariant', 2)
    from PyQt4 import QtGui, QtCore