def start_app(app_name = 'backintime'): """ Start the requested command or return config if there was no command in arguments. app_name: string representing the current application """ create_parsers(app_name) #open log logger.APP_NAME = app_name logger.openlog() #parse args args = arg_parse(None) #add source path to $PATH environ if running from source if tools.running_from_source(): tools.add_source_to_path_environ() #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 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'])
def start_app(app_name='backintime'): """ Start the requested command or return config if there was no command in arguments. app_name: string representing the current application """ create_parsers(app_name) #open log logger.APP_NAME = app_name logger.openlog() #parse args args = arg_parse(None) #add source path to $PATH environ if running from source if tools.running_from_source(): tools.add_source_to_path_environ() #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)