Ejemplo n.º 1
0
 def print_query_information(query_info):
     """
     Print the query classification result retrieved for Taste Dive api.
     """
     name = query_info[0].get('Name')
     predicted_type = query_info[0].get('Type')
     print(clr.bold('Name          : '), clr.yellow(name))
     print(clr.bold('Predicted Type: '), clr.yellow(predicted_type))
Ejemplo n.º 2
0
def ftpexit():
    """
    Exits the Hub, closing any (if existant) ftp connection
    """
    clr.yellow("[#] Exiting...")
    try:
        ftp.quit()
    except Exception as e:
        pass
    sleep(2)
    sys.exit()
Ejemplo n.º 3
0
def menu():
    """
    Creates the Main Menu, we should be at the FTP Root Folder.
    Functions in this menu are prefixed mm_
    """
    mm_checkpwd()
    sleep(1)
    os.system("CLS")
    print("######################################")
    print("# {0:<35}#".format("       FTPhub - Main Menue"))
    print("# {0:<35}#".format(""))
    print("# {0:<15} {1:<12}    #".format("   Current Status:", status))
    print("# {0:<35}#".format(""))
    print("# {0:<35}#".format("Available commands:"))
    print("# {0:<35}#".format(""))
    print("# {0:<35}#".format("[ 0] Connect to Server"))
    print("# {0:<35}#".format("[ 1] Disconnect from Server"))
    print("# {0:<35}#".format("[ 2] Browse Root"))
    print("# {0:<35}#".format("[ 3] Browse Dumps"))
    print("# {0:<35}#".format("[ 4] Rotate Dumps"))
    print("# {0:<35}#".format("[ 5] Upload Dump"))
    print("# {0:<35}#".format("[ 6] Exit"))
    print("######################################")

    print("\n[*] Please select what you want to do:")
    action = input("	-> ")
    try:
        action = int(action)
    except ValueError:
        clr.red("\n[X] Wrong Input")
        return menu()
        pass
    print("")

    if action == 0:
        clr.yellow("[#] Connecting...")
        mm_connect()
    elif action == 1:
        mm_disconnect()
    elif action == 2:
        mm_browse("root")
    elif action == 3:
        mm_browse("dumps")
    elif action == 4:
        mm_rotate()
    elif action == 5:
        mm_upload()
    elif action == 6:
        ftpexit()
    else:
        clr.red("\n[X] Wrong Input")
        return menu()
Ejemplo n.º 4
0
def mm_disconnect():
    """
    Disconnects you from a currently connected FTP-Server
    """
    global status
    if status != colored("{0:12}".format("Connected"), "green"):
        clr.red("[X] Not Connected to a Server")
        return menu()
    clr.yellow("[#] Disconnecting...")
    ftp.quit()
    clr.green("[*] Successfully disconnected")
    status = colored("{0:12}".format("Disconnected"), "red")
    sleep(1)
    if not qu and not qd:
        return menu()
Ejemplo n.º 5
0
def playAgain(playerTotal=0,
              dealerTotal=0,
              won=True,
              DoubleWin=False):  ## Finish the game with a winner and a looser
    global saldo, theBet, automatic

    if (won):  ## If the player won
        if (playerTotal == dealerTotal):  ## Player and dealer has same score
            print(
                clr.italic.yellow(
                    "=== Push! I ender på samme værdi. Spiller får indsatsen retur."
                ))
            saldo = (int(saldo))  ## Saldo remains unchanced, no actual winner
        else:
            if (automatic == False):  ## Player win from player-perspective
                print(
                    clr.bold.green(
                        "\n=== Tillykke! Du har vundet runden! :-D ==="))
            else:  ## Player win from dealer-perspective
                print(
                    clr.bold.red(
                        "\n=== Desværre! Du har tabt runden! :-( ==="))

            if (DoubleWin):  ## If player has DoubleWin
                print(
                    clr.bold.green(
                        "Spiller vinder på begge hænder! Dobbelt op på dobbelt op!"
                    ))
                saldo = (
                    int(saldo) + int(theBet) + (int(theBet) * 2)
                )  ## Double of the winning amount (which is already twofold)
            else:  ## Player wins the bet twofold
                saldo = (int(saldo) + int(theBet) + int(theBet))
    else:  ## If the dealer won
        if (automatic == True):  ## Dealer win from dealer-perspective
            print(
                clr.bold.green(
                    "\n=== Tillykke! Du har vundet runden! :-D ==="))
        else:  ## Dealer win from player-perspective
            print(clr.bold.red("\n=== Desværre! Du har tabt runden! :-( ==="))

        if (insurance
            ):  ## If the player has bought insurance, the bet will be returned
            print(
                clr.italic.red(
                    "Men der er købt forsikring! Indskud kommer derfor retur.")
            )
            saldo = (int(saldo) + int(theBet))
        else:  ## Without insurance, the player loses the bet
            saldo = (int(saldo) - int(theBet))

    print(clr.yellow("Spillersaldo: " + str(saldo)))  ## Current saldo in game
    playAgain = input("Spil igen? (Y/N): ")  ## Play again? (Y/N)
    if (playAgain == "Y"):
        ## subprocess.run(["clear"])
        if (automatic):
            dealerGame(True)  ## Play again dealer perspective
        else:
            playerGame(True)  ## Play again player perspective
Ejemplo n.º 6
0
def init():
    """
    Creates a little Header with Information about the Script
    """

    header = {
        "Name": "FTPhub.py",
        "Author": __author__,
        "Copyright": __copyright__,
        "Version": __version__,
        "VDate": __date__
    }

    os.system("CLS")
    clr.cyan("######################################")
    for key in header:
        clr.cyan("{0:<5}{1:<10}{2:<2}{3:<20}#".format("#", key, ":",
                                                      header[key]))
    clr.cyan("######################################")
    clr.yellow("\n[#] Loading...")
    sleep(1)
Ejemplo n.º 7
0
    def print(classname, commands):
        command_list = []
        for command, description in commands.items():
            command_list.append(
                [' ' + clr.green(command), ' ' + clr.yellow(description)])

        usage = columnar(command_list,
                         headers=[
                             clr.green.bold(' Command'),
                             clr.yellow.bold(' Description')
                         ])

        return f"{classname} Usage:\n" + usage
Ejemplo n.º 8
0
def makeAMove(test=""):  ## Next move in the game
    global saldo, theBet, prefixMove, insurance, split, automatic
    title = "Du"  ## Title from player-perspective
    if (automatic == False):  ## If we play as player, we choose the move
        if (prefixMove == ""):  ## Player choose move
            print(clr.yellow("\nHvad vil du gøre nu?:"))
            theMove = input(" ")
            subprocess.run(["clear"])
        else:  ## If a previous move has prefixed this move
            theMove = prefixMove
    elif (automatic and theBet > 0):  ## If we play as dealer
        title = "Spiller"  ## Title from dealer-perspective
        if (prefixMove == ""
            ):  # An Intelligent function will choose next player-move
            theMove = player_intelligence()
        else:  ## If a previous move has prefixed this move
            theMove = prefixMove
    else:
        theMove = test

    ## SEE DESCRIPTIONS IN THE chooseFirstMove() FUNCTION
    if (theMove == "H"):
        givePlayerCard()
    elif (theMove == "ST"):
        dealerTakeCard()
        prefixMove = "ST"
    elif (theMove == "D"):
        theBet = (int(theBet) * int(2))  ## The given bet will be doubled
        print(title + " får et kort mere og fordobler indsatsen til: " +
              str(theBet))
        prefixMove = "ST"
        givePlayerCard()
    elif (theMove == "R"):
        saldo = (int(saldo) - int(theBet) / 2
                 )  ## Player gives up, loses half of the bet
        print(
            title +
            " giver op! Det koster halvdelen af satset. Trækkes fra saldoen.")
        playAgain(0, 0, False)
    elif (theMove == "I"):
        print("\n" + title +
              " køber forsikring mod at tabe, nuværende saldo: " + str(saldo))
        saldo = (
            int(saldo) - (int(theBet) / 2)
        )  ## Player buys insurance from losing, costing half the bet, but insures to get the bet back
        print("Det koster halvdelen af satset (" + str(theBet) + "), saldo: " +
              str(saldo))
        insurance = True
        chooseNextMove()
    elif (theMove == "SP"):  ## Player will split two first given cards
        if 2 == len(playerCards):
            if (playerCards[0] == playerCards[1]
                ):  ## Split can only happen with identical cards
                playerCards2.append(playerCards.pop(0))
                split = True
                cardStatus()  ## Overview of hands and points
            else:
                print(badChoise + " " + title +
                      " skal have to ens kort på hånden.")
                chooseNextMove()
        else:
            print(badChoise + " " + title +
                  " må kun have to kort på hånden, når " + title + " splitter")
            chooseNextMove()
    elif (theMove == "HELP"):
        chooseFirstMove()
    else:  ## Invalid Move
        print(badChoise + " Det træk findes ikke.")
        chooseNextMove()
Ejemplo n.º 9
0
    endings = [
        ".zip", ".pdf", ".exe", ".txt", ".docx", ".7z", ".rar", ".py", ".xlsx",
        ".doc", ".xls", ".ppt", ".png", ".jpg", ".jpeg", ".inf", ".bin",
        ".reg", ".bat", ".log", ".ps1", ".bmp", ".ico", ".css", ".html",
        ".xml", ".sh", ".bak", ".ini", ".dmp", ".csv", ".sql", ".mp3", ".mp4",
        ".js", ".php", ".xls", ".pptx", ".config", ".cfg"
    ]

    root = os.path.dirname(os.path.abspath(__file__))
    status = colored("{0:12}".format("Disconnected"), "red")
    selected = colored("{0:20}".format("None"), "yellow")

    init()

    if qu:
        mm_connect()
        mm_upload()
        mm_disconnect()
        ftpexit()

    if qd:
        mm_connect()
        fm_download(qd=True)
        mm_disconnect()
        ftpexit()

    menu()

    clr.yellow("\n[#] Finished Execution, exiting...")
    sleep(2)