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'])
def startApp(app_name='backintime'): """ Start the requested command or return config if there was no command in arguments. Args: app_name (str): string representing the current application Returns: config.Config: current config if no command was given in arguments """ createParsers(app_name) #open log logger.APP_NAME = app_name logger.openlog() #parse args args = argParse(None) #add source path to $PATH environ if running from source if tools.runningFromSource(): tools.addSourceToPathEnviron() #warn about sudo if tools.usingSudo() and os.getenv('BIT_SUDO_WARNING_PRINTED', 'false') == 'false': os.putenv('BIT_SUDO_WARNING_PRINTED', 'true') logger.warning( "It looks like you're using 'sudo' to start %(app)s. " "This will cause some troubles. Please use either 'sudo -i %(app_name)s' " "or 'pkexec %(app_name)s'." % { 'app_name': app_name, 'app': config.Config.APP_NAME }) #call commands if 'func' in dir(args): args.func(args) else: setQuiet(args) printHeader() return getConfig(args, False)
def startApp(app_name = 'backintime'): """ Start the requested command or return config if there was no command in arguments. Args: app_name (str): string representing the current application Returns: config.Config: current config if no command was given in arguments """ createParsers(app_name) #open log logger.APP_NAME = app_name logger.openlog() #parse args args = argParse(None) #add source path to $PATH environ if running from source if tools.runningFromSource(): tools.addSourceToPathEnviron() #warn about sudo if tools.usingSudo() and os.getenv('BIT_SUDO_WARNING_PRINTED', 'false') == 'false': os.putenv('BIT_SUDO_WARNING_PRINTED', 'true') logger.warning("It looks like you're using 'sudo' to start %(app)s. " "This will cause some troubles. Please use either 'sudo -i %(app_name)s' " "or 'pkexec %(app_name)s'." %{'app_name': app_name, 'app': config.Config.APP_NAME}) #call commands if 'func' in dir(args): args.func(args) else: setQuiet(args) printHeader() return getConfig(args, False)