Exemplo n.º 1
0
    def test_add_source_to_path_environ(self):
        source = tools.get_backintime_path('common')
        path = [x for x in os.getenv('PATH').split(':') if x != source]
        os.environ['PATH'] = ':'.join(path)

        tools.add_source_to_path_environ()
        self.assertIn(source, os.environ['PATH'])
Exemplo n.º 2
0
 def on_process_begins(self):
     try:
         path = os.path.join(tools.get_backintime_path('qt4'),
                             'qt4systrayicon.py')
         self.process = subprocess.Popen([
             sys.executable, path,
             self.snapshots.config.get_current_profile()
         ])
     except:
         pass
Exemplo n.º 3
0
    def load_plugins(self, snapshots=None, cfg=None, force=False):
        if self.plugins_loaded and not force:
            return

        if snapshots is None:
            import snapshots as snapshots_
            snapshots = snapshots_.Snapshots(cfg)

        self.plugins_loaded = True
        self.plugins = []
        self.has_gui_plugins_ = False

        loadedPlugins = []
        for path in ('plugins', 'common/plugins', 'qt4/plugins'):
            fullPath = tools.get_backintime_path(path)
            if os.path.isdir(fullPath):
                logger.debug('Register plugin path %s' % fullPath, self)
                tools.register_backintime_path(path)
                for f in os.listdir(fullPath):
                    if f not in loadedPlugins and f.endswith(
                            '.py') and not f.startswith('__'):
                        try:
                            module = __import__(f[:-3])
                            module_dict = module.__dict__

                            for key, value in list(module_dict.items()):
                                if key.startswith('__'):
                                    continue

                                if type(value) is type:
                                    if issubclass(value, Plugin):
                                        plugin = value()
                                        if plugin.init(snapshots):
                                            logger.debug(
                                                'Add plugin %s' % f, self)
                                            if plugin.is_gui():
                                                self.has_gui_plugins_ = True
                                                self.plugins.insert(0, plugin)
                                            else:
                                                self.plugins.append(plugin)
                            loadedPlugins.append(f)
                        except BaseException as e:
                            logger.error(
                                'Failed to load plugin %s: %s' % (f, str(e)),
                                self)
Exemplo n.º 4
0
    def load_plugins(self, snapshots=None, cfg=None, force=False):
        if self.plugins_loaded and not force:
            return

        if snapshots is None:
            import snapshots as snapshots_

            snapshots = snapshots_.Snapshots(cfg)

        self.plugins_loaded = True
        self.plugins = []
        self.has_gui_plugins_ = False

        loadedPlugins = []
        for path in ("plugins", "common/plugins", "qt4/plugins"):
            fullPath = tools.get_backintime_path(path)
            if os.path.isdir(fullPath):
                logger.debug("Register plugin path %s" % fullPath, self)
                tools.register_backintime_path(path)
                for f in os.listdir(fullPath):
                    if f not in loadedPlugins and f.endswith(".py") and not f.startswith("__"):
                        try:
                            module = __import__(f[:-3])
                            module_dict = module.__dict__

                            for key, value in list(module_dict.items()):
                                if key.startswith("__"):
                                    continue

                                if type(value) is type:
                                    if issubclass(value, Plugin):
                                        plugin = value()
                                        if plugin.init(snapshots):
                                            logger.debug("Add plugin %s" % f, self)
                                            if plugin.is_gui():
                                                self.has_gui_plugins_ = True
                                                self.plugins.insert(0, plugin)
                                            else:
                                                self.plugins.append(plugin)
                            loadedPlugins.append(f)
                        except BaseException as e:
                            logger.error("Failed to load plugin %s: %s" % (f, str(e)), self)
Exemplo n.º 5
0
 def test_get_backintime_path(self):
     path = tools.get_backintime_path('common')
     self.assertRegex(path, r'.*/backintime.*/common$')
Exemplo n.º 6
0
 def test_register_backintime_path(self):
     path = tools.get_backintime_path('foo')
     tools.register_backintime_path('foo')
     self.assertIn(path, sys.path)
     sys.path.remove(path)
Exemplo n.º 7
0
 def on_process_begins( self ):
     try:
         path = os.path.join(tools.get_backintime_path('qt4'), 'qt4systrayicon.py')
         self.process = subprocess.Popen( [ sys.executable, path, self.snapshots.config.get_current_profile() ] )
     except:
         pass