コード例 #1
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def mod_update(args):
    KerbalStuff.login(args.username, args.password)

    if KerbalStuff.current_json is None:
        sys.stderr.write("Login response was not valid JSON; aborting.")
        sys.exit(1)

    if KerbalStuff.current_json['error']:
        sys.stderr.write("Error during login: {0}".format(KerbalStuff.current_json['reason']))
        sys.exit(1)

    file_path = args.file

    if os.path.isfile(file_path):
        if not is_zipfile(file_path):
            sys.stderr.write("Not a valid zip file: '{0}'\n".format(file_path))
            sys.exit(1)
        file_name = os.path.basename(file_path)
    else:
        sys.stderr.write("File does not exist: '{0}'\n".format(file_path))
        sys.exit(1)

    if 'changelog' in args and args.changelog is not None and len(args.changelog) > 0:
        ver = ModVersion(args.version, args.ksp, args.changelog)
    else:
        ver = ModVersion(args.version, args.ksp)

    try:
        KerbalStuff.mod_update(args.mod_id, ver, args.notify, file_name, file_path)
        if KerbalStuff.current_json["error"]:
            sys.stderr.write("Error updating mod #{0}: {1}".format(args.mod_id, KerbalStuff.current_json["reason"]))
            sys.exit(1)
        else:
            sys.stdout.write("Mod updated!  New version id is {0}.  You can view the new mod version at {1}{2}".format(
                KerbalStuff.current_json["id"],
                KerbalStuff.constants.RootUri,
                KerbalStuff.current_json["url"]
            ))
    except TypeError as x:
        sys.stderr.write(x)
        sys.exit(1)
コード例 #2
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def mod_create(args):
    KerbalStuff.login(args.username, args.password)

    if KerbalStuff.current_json is None:
        sys.stderr.write("Login response was not valid JSON; aborting.")
        sys.exit(1)

    if KerbalStuff.current_json['error']:
        sys.stderr.write("Error during login: {0}".format(KerbalStuff.current_json['reason']))
        sys.exit(1)

    file_path = args.file

    if os.path.isfile(file_path):
        if not is_zipfile(file_path):
            sys.stderr.write("Not a valid zip file: '{0}'\n".format(file_path))
            sys.exit(1)
        file_name = os.path.basename(file_path)
    else:
        sys.stderr.write("File does not exist: '{0}'\n".format(file_path))
        sys.exit(1)

    mod = Mod(args.name, args.desc, args.version, args.ksp, args.license)

    try:
        KerbalStuff.mod_create(mod, file_name, file_path)
        if KerbalStuff.current_json["error"]:
            sys.stderr.write("Error creating mod '{0}': {1}".format(args.name, KerbalStuff.current_json["reason"]))
            sys.exit(1)
        else:
            sys.stdout.write("Mod created!  New mod id is {0}.  You can view the new mod at {1}{2}".format(
                KerbalStuff.current_json["id"],
                KerbalStuff.constants.RootUri,
                KerbalStuff.current_json["url"]
            ))
    except TypeError as x:
        sys.stderr.write(x)
        sys.exit(1)
コード例 #3
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def mod_latest(args):
    print(KerbalStuff.mod_latest(args.mod_id))
コード例 #4
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def mod_info(args):
    print(KerbalStuff.mod_info(args.mod_id))
コード例 #5
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def browse_top(args):
    for m in KerbalStuff.browse_top(args.page_id):
        print(m)
コード例 #6
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def browse_featured(args):
    for m in KerbalStuff.browse_featured(args.page_id):
        print(m)
コード例 #7
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def user_info(args):
    print(KerbalStuff.user_info(args.username))
コード例 #8
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def search_user(args):
    for u in KerbalStuff.search_user(args.query):
        print(u)
コード例 #9
0
ファイル: PyKStuff.py プロジェクト: toadicus/PyKStuff
def search_mod(args):
    for m in KerbalStuff.search_mod(args.query):
        print(m)