コード例 #1
0
def main():
    try:

        ascii_art = """\
          ____            _     _           _
         |  _ \          | |   | |         | |
         | |_) | __ _ ___| |__ | |__  _   _| |__   ___ ___  _ __ ___
         |  _ < / _` / __| '_ \| '_ \| | | | '_ \ / __/ _ \| '_ ` _  \\
         | |_) | (_| \__ \ | | | | | | |_| | |_) | (_| (_) | | | | | |
         |____/ \__,_|___/_| |_|_| |_|\__,_|_.__(_)___\___/|_| |_| |_|

        """
        print(ascii_art)
        print("Welcome to bashhub setup!")
        is_new_user = query_yes_no("Are you a new user?")
        user_id = None
        if is_new_user:
            register_user = get_new_user_information()
            user_id = rest_client.register_user(register_user)
            if user_id != None:
                print("Registered new user {0}\n".format(
                    register_user.username))
            else:
                print("Sorry, registering a new user failed.")
        else:
            user_id = get_existing_user_information()
            if user_id == None:
                print("\nSorry looks like logging in failed.")
                print(
                    "If you forgot your password please reset it. "
                    "https://bashhub.com/password-reset")

        if user_id == None:
            print(
                "You can rerun setup using 'bashhub setup' in a new "
                "terminal window.\n")
            sys.exit(0)

        system_id = handle_system_information(user_id)

        if system_id == None:
            print("Sorry looks like getting your info failed.\
                    Exiting...")
            sys.exit(0)

        write_config_file(user_id, system_id)
        sys.exit(0)

    except Exception, err:
        sys.stderr.write('Setup Error:\n%s\n' % str(err))
        traceback.print_exc()
        sys.exit(1)
コード例 #2
0
def main():
    try:

        ascii_art = """\
          ____            _     _           _
         |  _ \          | |   | |         | |
         | |_) | __ _ ___| |__ | |__  _   _| |__   ___ ___  _ __ ___
         |  _ < / _` / __| '_ \| '_ \| | | | '_ \ / __/ _ \| '_ ` _  \\
         | |_) | (_| \__ \ | | | | | | |_| | |_) | (_| (_) | | | | | |
         |____/ \__,_|___/_| |_|_| |_|\__,_|_.__(_)___\___/|_| |_| |_|

        """
        print(ascii_art)
        print("Welcome to bashhub setup!")
        is_new_user = query_yes_no("Are you a new user?")
        user_id = None
        if is_new_user:
            register_user = get_new_user_information()
            user_id = rest_client.register_user(register_user)
            if user_id != None:
                print("Registered new user {0}\n".format(register_user.username))
            else:
                print("Sorry, registering a new user failed.")
        else:
            user_id = get_existing_user_information()
            if user_id == None:
                print("\nSorry looks like logging in failed.")
                print("If you forgot your password please reset it. "
                      "https://bashhub.com/password-reset")

        if user_id == None:
            print("You can rerun setup using 'bashhub setup' in a new "
                  "terminal window.\n")
            sys.exit(0)

        system_id = handle_system_information(user_id)

        if system_id == None:
            print("Sorry looks like getting your info failed.\
                    Exiting...")
            sys.exit(0)

        write_config_file(user_id, system_id)
        sys.exit(0)

    except Exception, err:
        sys.stderr.write('Setup Error:\n%s\n' % str(err))
        traceback.print_exc()
        sys.exit(1)
コード例 #3
0
def main():
    try:

        ascii_art = """\
          ____            _     _           _
         |  _ \          | |   | |         | |
         | |_) | __ _ ___| |__ | |__  _   _| |__   ___ ___  _ __ ___
         |  _ < / _` / __| '_ \| '_ \| | | | '_ \ / __/ _ \| '_ ` _  \\
         | |_) | (_| \__ \ | | | | | | |_| | |_) | (_| (_) | | | | | |
         |____/ \__,_|___/_| |_|_| |_|\__,_|_.__(_)___\___/|_| |_| |_|

        """
        print ascii_art
        print "Welcome to bashhub setup!"
        is_new_user = query_yes_no("Are you a new user?")
        user_id = None
        if is_new_user:
            register_user = get_new_user_information()
            user_id = rest_client.register_user(register_user)
            if user_id != None:
                print("Registered new user {0}\n".format(
                    register_user.username))
        else:
            user_id = get_existing_user_information()

        if user_id == None:
            print "Sorry looks like getting your info failed.\
                    Exiting..."

            sys.exit(0)

        system_id = handle_system_information(user_id)
        write_config_file(user_id, system_id)
        sys.exit(0)

    except Exception, err:
        sys.stderr.write('Setup Error:\n%s\n' % str(err))
        traceback.print_exc()
        sys.exit(1)
コード例 #4
0
def main():
    try:

        ascii_art = """\
          ____            _     _           _
         |  _ \          | |   | |         | |
         | |_) | __ _ ___| |__ | |__  _   _| |__   ___ ___  _ __ ___
         |  _ < / _` / __| '_ \| '_ \| | | | '_ \ / __/ _ \| '_ ` _  \\
         | |_) | (_| \__ \ | | | | | | |_| | |_) | (_| (_) | | | | | |
         |____/ \__,_|___/_| |_|_| |_|\__,_|_.__(_)___\___/|_| |_| |_|

        """
        print ascii_art
        print "Welcome to bashhub setup!"
        is_new_user = query_yes_no("Are you a new user?")
        user_id = None
        if is_new_user:
            register_user = get_new_user_information()
            user_id = rest_client.register_user(register_user)
            if user_id != None:
                print("Registered new user {0}\n".format(register_user.username))
        else:
            user_id = get_existing_user_information()

        if user_id == None:
            print "Sorry looks like getting your info failed.\
                    Exiting..."
            sys.exit(0)

        system_id = handle_system_information(user_id)
        write_config_file(user_id, system_id)
        sys.exit(0)

    except Exception, err:
        sys.stderr.write('Setup Error:\n%s\n' % str(err))
        traceback.print_exc()
        sys.exit(1)
コード例 #5
0
def main():
    try:

        ascii_art = """\
          ____            _     _           _
         |  _ \          | |   | |         | |
         | |_) | __ _ ___| |__ | |__  _   _| |__   ___ ___  _ __ ___
         |  _ < / _` / __| '_ \| '_ \| | | | '_ \ / __/ _ \| '_ ` _  \\
         | |_) | (_| \__ \ | | | | | | |_| | |_) | (_| (_) | | | | | |
         |____/ \__,_|___/_| |_|_| |_|\__,_|_.__(_)___\___/|_| |_| |_|

        """

        print(ascii_art)
        print("Welcome to bashhub setup!")
        is_new_user = query_yes_no("Are you a new user?")

        # Initialize variaous Credentials for logging in.
        username = None
        password = None
        access_token = None

        # If this is a new user walk them through the registration flow
        if is_new_user:
            register_user = get_new_user_information()
            register_result = rest_client.register_user(register_user)
            if register_result:
                print("Registered new user {0}\n".format(
                    register_user.username))
                # Set our credentials to login later
                username = register_user.username
                password = register_user.password
            else:
                print("Sorry, registering a new user failed.")
                print("You can rerun setup using 'bashhub setup' in a new "
                  "terminal window.\n")
                sys.exit(0)

        (username, password, access_token) = get_user_information_and_login(
            username, password)
        if access_token == None:
            print("\nSorry looks like logging in failed.")
            print("If you forgot your password please reset it. "
                  "https://bashhub.com/password-reset")
            print("You can rerun setup using 'bashhub setup' in a new "
                  "terminal window.\n")
            sys.exit(0)

        # write out our user scoped access token
        config_write_result = write_to_config_file("access_token", access_token)
        if not config_write_result:
            print("Writing your config file failed.")
            sys.exit(1)

        (access_token, system_name) = handle_system_information(username, password)

        if access_token == None:
            print("Sorry looks like getting your info failed.\
                    Exiting...")
            sys.exit(0)

        # write out our system scoped token and the system name
        write_to_config_file("access_token", access_token)
        write_to_config_file("system_name", system_name)
        update_system_info()

        sys.exit(0)

    except Exception, err:
        sys.stderr.write('Setup Error:\n%s\n' % str(err))
        traceback.print_exc()
        sys.exit(1)