Ejemplo n.º 1
0
    def test_disable_apt_run(self):
        apt_run = AptRun()
        apt_run.set_folder(AptRunTests.TEST_FOLDER)

        os.makedirs(AptRunTests.TEST_FOLDER)
        apt_run.disable()
        result = apt_run.is_enable()

        self.assertFalse(result)
Ejemplo n.º 2
0
    def test_dont_disable_apt_run_if_already_disabled(self):
        apt_run = AptRun()
        apt_run.set_folder(AptRunTests.TEST_FOLDER)

        result = apt_run.disable()

        self.assertFalse(result)
Ejemplo n.º 3
0
def run(args):
    if args['update']:
        init_result = run_initialize()

        if init_result != SUCCESS:
            return init_result

        train_result = run_train()

        if train_result != SUCCESS:
            return train_result

        return SUCCESS
    elif args['init']:
        return run_initialize()
    elif args['train']:
        return run_train()
    elif args['contribute']:
        collect_user_data.main()
    elif args['show_classifications']:
        show_classifications.main()
    elif args['enable_apt']:
        try:
            apt_run = AptRun()
            if apt_run.enable():
                print 'AppRecommender now makes recommendations when you ' \
                      ' install new packages with apt'
            else:
                print 'This is already enabled'

            return SUCCESS
        except OSError:
            return PERMISSION_DENIED
    elif args['disable_apt']:
        try:
            apt_run = AptRun()
            if apt_run.disable():
                print 'AppRecommender now dont makes recommendations when' \
                      'you install new packages with apt'
            else:
                print 'This is already disabled'

            return SUCCESS
        except OSError:
            return PERMISSION_DENIED
    else:
        config = Config()
        parse_options(args, config)
        reference_pkgs = args['packages']
        return run_apprecommender(reference_pkgs)