예제 #1
0
def main(operation, pack_name, pack_version, install_folder, cache_folder, share_code, dry_run):
    """A tool for installing and updating Minecraft servers based on ATLauncher mod packs.
    Example invocations:

    cat_herder.py list_packs

    Installing with share code:
    cat_herder.py install-from-share-code -s QtDNnlfZ

    As above, but manually specifying the download cache and server install folders:
    cat_herder.py install-from-share-code -s QtDNnlfZ -c /home/mc/cache -i /home/mc/install/

    Installing with manually specified pack name and pack version:
    cat_herder.py install -p BevosTechPack -v BTP-11-Full -c /home/mc/cache -i /home/mc/install/
    """

    if install_folder:
        install_folder = os.path.realpath(install_folder)
    else:
        install_folder = os.path.realpath('./install/{pn}/{pv}'.format(pn=pack_name,pv=pack_version))

    if cache_folder:
        cache_folder = os.path.realpath(cache_folder)
    else:
        cache_folder = os.path.realpath('./cache/')

    mkdir (cache_folder)
    os.chdir(cache_folder)
    packs_json = get_pack_json()

    pack_names = [p['name'] for p in packs_json]

    if operation == 'list_packs':
        list_packs(packs_json)

    if operation == 'update':
        print "Update not implemented yet."

    if operation == 'install':
        if not pack_version:
            pack_version = get_latest_pack_version (packs_json, pack_name)

        mp = atlauncher_to_catherder(pack_name, pack_version, cache_folder, install_folder)
        if dry_run:
            mp.print_mod_files_list()
        else:
            mp.install_server()

    if operation == 'install-from-share-code':
        if not share_code:
            print ("install-from-share-code option requires a share code to be specified using the -s option.")
        if not re.match("[A-Za-z0-9]{8}",share_code):
            print ("install-from-share-code requires an 8-character alphanumeric share code.")

        mp = get_mod_pack_with_share_code(share_code, cache_folder, install_folder)
        if dry_run:
            mp.print_mod_files_list()
        else:
            mp.install_server()
예제 #2
0
def get_mod_pack_with_share_code (share_code, download_cache_folder, install_folder):
    # Returns a Mod_Pack object.
    #
    # The pack name and pack version are implied by the share code, so these
    # don't have to be provided externally.
    #
    # The 'install_optional?' flag is set on each of the Mod_Pack's
    # optional mods, based on the 'selected' mods in the share code data.
    sc_json_str = get_share_code_json (share_code)
    r = process_share_code_json (sc_json_str)

    mp = atlauncher_to_catherder(pack_name = r['pack'],
                                 pack_version = r['pack_version'],
                                 download_cache_folder=download_cache_folder,
                                 install_folder=install_folder)

    for m in mp.mod_files:
        if m['optional?']:
            m['install_optional?'] = m['name'] in r['selected_mods']
    return mp
예제 #3
0
def get_mod_pack_with_share_code (share_code, download_cache_folder, install_folder):
    # Returns a Mod_Pack object.
    #
    # The pack name and pack version are implied by the share code, so these
    # don't have to be provided externally.
    #
    # The 'install_optional?' flag is set on each of the Mod_Pack's
    # optional mods, based on the 'selected' mods in the share code data.
    sc_json_str = get_share_code_json (share_code)
    r = process_share_code_json (sc_json_str)

    mp = atlauncher_to_catherder(pack_name = r['pack'],
                                 pack_version = r['pack_version'],
                                 download_cache_folder=download_cache_folder,
                                 install_folder=install_folder)

    for m in mp.mod_files:
        if m['optional?']:
            m['install_optional?'] = m['name'] in r['selected_mods']
    return mp
예제 #4
0
def main(operation, pack_name, pack_version, install_folder, cache_folder,
         share_code, dry_run):
    """A tool for installing and updating Minecraft servers based on ATLauncher mod packs.
    Example invocations:

    cat_herder.py list_packs

    Installing with share code:
    cat_herder.py install-from-share-code -s QtDNnlfZ

    As above, but manually specifying the download cache and server install folders:
    cat_herder.py install-from-share-code -s QtDNnlfZ -c /home/mc/cache -i /home/mc/install/

    Installing with manually specified pack name and pack version:
    cat_herder.py install -p BevosTechPack -v BTP-11-Full -c /home/mc/cache -i /home/mc/install/
    """

    if install_folder:
        install_folder = os.path.realpath(install_folder)
    else:
        install_folder = os.path.realpath('./install/{pn}/{pv}'.format(
            pn=pack_name, pv=pack_version))

    if cache_folder:
        cache_folder = os.path.realpath(cache_folder)
    else:
        cache_folder = os.path.realpath('./cache/')

    mkdir(cache_folder)
    os.chdir(cache_folder)
    packs_json = get_pack_json()

    pack_names = [p['name'] for p in packs_json]

    if operation == 'list_packs':
        list_packs(packs_json)

    if operation == 'update':
        print "Update not implemented yet."

    if operation == 'install':
        if not pack_version:
            pack_version = get_latest_pack_version(packs_json, pack_name)

        mp = atlauncher_to_catherder(pack_name, pack_version, cache_folder,
                                     install_folder)
        if dry_run:
            mp.print_mod_files_list()
        else:
            mp.install_server()

    if operation == 'install-from-share-code':
        if not share_code:
            print(
                "install-from-share-code option requires a share code to be specified using the -s option."
            )
        if not re.match("[A-Za-z0-9]{8}", share_code):
            print(
                "install-from-share-code requires an 8-character alphanumeric share code."
            )

        mp = get_mod_pack_with_share_code(share_code, cache_folder,
                                          install_folder)
        if dry_run:
            mp.print_mod_files_list()
        else:
            mp.install_server()