Пример #1
0
def uninstall(package_name):
    """uninstalls a package"""

    ask_bit = 0

    try:
        ask_bit = ask_again_uninstall(package_name, 0)
    except ValueError:
        ask_again_uninstall(package_name, 1)

    if ask_bit == 1:
        clear()
    elif ask_bit == 2:
        cprint("ABORTING UNINSTALL!", 'red', attr=['underline'])

    uninstall_script_path = scripts_path + parser(package_name, 6)

    which_cmd = 'which ' + parser(package_name, 8)

    cprint("Uninstalling " + package_name + " Standby...", 'yellow')

    subprocess.call(uninstall_script_path)

    if subprocess.getoutput(which_cmd) == parser(package_name, 7):
        cprint(
            "UNINSTALLATION FAILED! PLEASE NOTIFY THE DEVS BY SUBMITTING A ISSUE AT https://github.com/343GuiltySpark-04/PackageArbiter/issues AND REINSTALL THE PACKAGE TO PREVENT ERRORS!",
            'red',
            attrs=['bold', 'underline'])
    else:
        cprint("Uninstallation Successful!", 'cyan', attrs=['underline'])

    call_main_menu()
def parser_cache(package_name, flip_bit):
    """Parses the Cache For a package"""

    full_package_name = '**/' + parser(package_name, 1) + '.tar*'

    cross_ref_name = parser(package_name, 1)

    cross_ref_cache_name = parser(package_name, 9)

    print(cross_ref_cache_name)

    if cross_ref_name != package_name and flip_bit == 1:
        return "ERROR: NO SUCH PACKAGE ON FILE!"
    elif cross_ref_name != package_name and flip_bit == 2:
        return 2

    path = pathlib.Path(cache_path)

    package_list = list(path.glob(full_package_name))

    index = 0

    return_name = ""

    index_max = len(package_list)

    for _ in package_list:

        return_name = package_list[index]

        index += 1

        if index == index_max or index > index_max:
            break
        else:
            continue

    print(return_name)

    if flip_bit == 1 and cross_ref_cache_name == return_name:
        return return_name
    elif flip_bit == 2 and cross_ref_cache_name == return_name:
        return 1
    elif cross_ref_cache_name != return_name:
        return 2
def dep_lister(package_name):
    dep_list = parser(package_name, 10)

    index = 0

    for _ in dep_list:
        cprint(dep_list[index], 'yellow', attrs=['underline'])

        index += 1
def opt_dep_lister(package_name):
    opt_dep_list = parser(package_name, 11)

    index = 0

    for _ in opt_dep_list:
        cprint(opt_dep_list[index], 'yellow')

        index += 1
Пример #5
0
def install(package_name):
    """installs a package"""

    ask_bit = 0

    try:
        ask_bit = ask_again_install(package_name, 0)
    except ValueError:
        ask_again_install(package_name, 1)

    if ask_bit == 1:
        clear()
    elif ask_bit == 2:
        cprint("ABORTING INSTALL!", 'red', attrs=['underline'])
        call_main_menu()

    install_script_path = scripts_path + parser(package_name, 5)

    which_cmd = 'which ' + parser(package_name, 8)

    cprint("Installing " + package_name + " Please Standby....", 'yellow')

    # if check_for_package(package_name) == 2:
    #     cprint("ERROR: Package Not Found In Cache Please Make Sure To Place It In The Cache Directory!", 'red',
    #            attrs=['underline'])
    #     call_main_menu()

    # ^ currently not working right

    subprocess.call(install_script_path)

    if subprocess.getoutput(which_cmd) == parser(package_name, 7):
        cprint("Installation Successful!", 'cyan', attrs=['underline'])
    else:
        cprint(
            "INSTALLATION FAILED PLEASE NOTIFY THE THE DEVS BY SUBMITTING A ISSUE AT https://github.com/343GuiltySpark-04/PackageArbiter/issues",
            'red',
            attrs=['bold', 'underline'])

    call_main_menu()
Пример #6
0
def uninstall_menu():
    """asks what package to uninstall then makes sure its installed then calls the package handler"""

    cprint("What Package Do You Want Uninstalled?", 'cyan')

    user_input = input("#>")

    if user_input != parser(user_input, 1):
        cprint(
            "ERROR: No Such Package In The Database! (you can request a package to be made PackageArbiter compatible at https://github.com/343GuiltySpark-04/PackageArbiter/issues)",
            'red',
            attrs=['underline'])
        main_menu_handler()

    which_cmd = 'which ' + parser(user_input, 8)

    if getoutput(which_cmd) != parser(user_input, 7):
        cprint("Package Not Installed Aborting!",
               'yellow',
               attrs=['underline'])
        main_menu_handler()
    else:
        uninstall(user_input)
Пример #7
0
def package_search():
    """Searches for a package in the db.yaml (using database_parser.py file then checks for its presence in the Cache
        Directory (using cache_parser.py)"""

    cprint("So what are we looking for?", 'cyan')

    user_input = input("#>")

    exists_in_db = parser(user_input, 1)

    exists_in_cache = parser_cache(user_input, 2)

    if exists_in_db == user_input:
        clear()
        out_name = "Name: " + parser(user_input, 1)
        out_version = "Version: " + str(parser(user_input, 2))
        out_config_dir = "Config Dir: " + parser(user_input, 3)
        cprint(out_name, 'yellow')
        cprint(out_version, 'yellow')
        cprint(out_config_dir, 'yellow')
    elif exists_in_db != user_input:
        clear()
        cprint("Sorry Package Search Failed (Package Not Found in Database)",
               'red',
               attrs=['underline'])
        main_menu_handler()

    cprint("Making Sure It's Present in The Cache....", 'cyan')

    if exists_in_cache == 1:
        cprint("Package Located!", 'yellow')
        main_menu_handler()
    elif exists_in_cache != 2:
        cprint("Sorry Package Search Failed (Package Not Found in Cache)",
               'red',
               attrs=['underline'])
        main_menu_handler()
 def test_database_parser(self):
     self.assertEqual(
         database_parser.parser("foolib", 12), "foolib",
         cprint("Database Parser Test Complete",
                'yellow',
                attrs=['underline']))