Example #1
0
    def test_addSourceToPathEnviron(self):
        source = tools.backintimePath('common')
        path = [x for x in os.getenv('PATH').split(':') if x != source]
        os.environ['PATH'] = ':'.join(path)

        tools.addSourceToPathEnviron()
        self.assertIn(source, os.environ['PATH'])
Example #2
0
    def test_addSourceToPathEnviron(self):
        source = tools.backintimePath('common')
        path = [x for x in os.getenv('PATH').split(':') if x != source]
        os.environ['PATH'] = ':'.join(path)

        tools.addSourceToPathEnviron()
        self.assertIn(source, os.environ['PATH'])
Example #3
0
 def processBegin(self):
     try:
         path = os.path.join(tools.backintimePath('qt'), 'qtsystrayicon.py')
         self.process = subprocess.Popen(
             [sys.executable, path,
              self.snapshots.config.currentProfile()])
     except:
         pass
Example #4
0
    def load(self, snapshots=None, cfg=None, force=False):
        if self.loaded and not force:
            return

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

        self.loaded = True
        self.plugins = []
        self.hasGuiPlugins = False

        loadedPlugins = []
        for path in ('plugins', 'common/plugins', 'qt/plugins'):
            fullPath = tools.backintimePath(path)
            if os.path.isdir(fullPath):
                logger.debug('Register plugin path %s' % fullPath, self)
                tools.registerBackintimePath(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.isGui():
                                                self.hasGuiPlugins = 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)
Example #5
0
    def load(self, snapshots = None, cfg = None, force = False):
        if self.loaded and not force:
            return

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

        self.loaded = True
        self.plugins = []
        self.hasGuiPlugins = False

        loadedPlugins = []
        for path in ('plugins', 'common/plugins', 'qt/plugins'):
            fullPath = tools.backintimePath(path)
            if os.path.isdir(fullPath):
                logger.debug('Register plugin path %s' %fullPath, self)
                tools.registerBackintimePath(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.isGui():
                                                self.hasGuiPlugins = 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)
Example #6
0
 def test_registerBackintimePath(self):
     path = tools.backintimePath('foo')
     tools.registerBackintimePath('foo')
     self.assertIn(path, sys.path)
     sys.path.remove(path)
Example #7
0
 def test_backintimePath(self):
     path = tools.backintimePath('common')
     self.assertRegex(path, r'.*/backintime.*/common$')
Example #8
0
 def processBegin(self):
     try:
         path = os.path.join(tools.backintimePath('qt'), 'qtsystrayicon.py')
         self.process = subprocess.Popen([sys.executable, path, self.snapshots.config.currentProfile()])
     except:
         pass
Example #9
0
 def test_backintimePath(self):
     path = tools.backintimePath('common')
     self.assertRegex(path, r'.*/backintime.*/common$')
Example #10
0
 def test_registerBackintimePath(self):
     path = tools.backintimePath('foo')
     tools.registerBackintimePath('foo')
     self.assertIn(path, sys.path)
     sys.path.remove(path)