示例#1
0
def copy_fs_sessions(path):
    from odoo.http import OpenERPSession
    from werkzeug.contrib.sessions import FilesystemSessionStore
    werkzeug_session_store = FilesystemSessionStore(
        path, session_class=OpenERPSession)
    session_store = http.Root().session_store
    filename_prefix_len = len('werkzeug_')
    filename_suffix_len = len('.sess')

    for fname in os.listdir(path):
        session_file = fname[filename_prefix_len:filename_suffix_len * -1]
        session = werkzeug_session_store.get(session_file)
        session_store.save(session)
示例#2
0
 def load_drivers(self):
     """
     This method loads local files: 'odoo/addons/hw_drivers/drivers'
     And execute these python drivers
     """
     helpers.download_drivers()
     path = get_resource_path('hw_drivers', 'drivers')
     driversList = os.listdir(path)
     self.devices = {}
     for driver in driversList:
         path_file = os.path.join(path, driver)
         spec = util.spec_from_file_location(driver, path_file)
         if spec:
             module = util.module_from_spec(spec)
             spec.loader.exec_module(module)
     http.root = http.Root()
示例#3
0
文件: helpers.py 项目: yustas147/odoo
def load_iot_handlers():
    """
    This method loads local files: 'odoo/addons/hw_drivers/iot_handlers/drivers' and
    'odoo/addons/hw_drivers/iot_handlers/interfaces'
    And execute these python drivers and interfaces
    """
    for directory in ['interfaces', 'drivers']:
        path = get_resource_path('hw_drivers', 'iot_handlers', directory)
        filesList = os.listdir(path)
        for file in filesList:
            path_file = os.path.join(path, file)
            spec = util.spec_from_file_location(file, path_file)
            if spec:
                module = util.module_from_spec(spec)
                spec.loader.exec_module(module)
    http.root = http.Root()
示例#4
0
 def setUp(self):
     super().setUp()
     self.odoo_root = http.Root()
     self.session = self.odoo_root.session_store.new()