예제 #1
0
def main():

    parser = argparse.ArgumentParser(prog='client',
                                     usage='python3 client.py [options]')
    parser.add_argument('--user', help='The username to use for the client')
    parser.add_argument('--server',
                        choices=['prod', 'dev', 'local'],
                        default='local',
                        help="Which server should the client connect to")
    args = parser.parse_args()

    setSettings(args.server)
    sessionToken = str(authREST(args.user))
    client.connect((settings["url"], settings["socket"]))
    client.setblocking(True)

    commands.load(client)

    receiver = threading.Thread(target=socketReceive)
    receiver.start()

    # Authentification
    sendMessage(0, sessionToken.encode("utf-8"))

    while True:
        input()
        importlib.reload(commands)
        commands.load(sendMessage)
        commands.execute()
    receiver.join()
    client.close()
예제 #2
0
def main(key):
    global LAST_UPDATE_ID

    logging.basicConfig(filename='log/screaming.log', level=logging.WARNING,
                        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    bot = telegram.Bot(key)

    try:
        LAST_UPDATE_ID = bot.getUpdates()[-1].update_id
    except Exception:
        LAST_UPDATE_ID = None

    default, other = load('config.json')
    replier = Replier(bot, default, *other)

    while True:
        for update in bot.getUpdates(offset=LAST_UPDATE_ID, timeout=10):
            LAST_UPDATE_ID = replier.reply(update)
예제 #3
0
def user_input():
    try:
        user_input = int(input("\033[34m" + "Please choose: " + "\033[39m"))
        if user_input == 1:
            commands.list_item(commands.load())
        elif user_input == 2:
            commands.add_item(commands.load())
        elif user_input == 3:
            commands.list_item(commands.load())
            commands.change_status_item(commands.load())
        elif user_input == 4:
            commands.list_item(commands.load())
            commands.remove_item(commands.load())
        elif user_input == 5:
            commands.remove_completed_items(commands.load())
        elif user_input == 6:
            exit()
        else:
            print("Please choose a number from the menu!")
    except ValueError:
        print("Please enter a number!")
예제 #4
0
        yield from level.top(message=message, client=client)


def save():
    global timer
    if time.time() - timer > 3600:
        level.save()
        commands.save()
        timer = time.time()
        logging.debug("Saving...")


if __name__ == "__main__":
    logging.basicConfig(filename=config.LOG_PATH,
                        filemode='w',
                        level=logging.DEBUG)
    timer = time.time()
    commands.load()
    level.load()
    permission.load()
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(client.start(config.BOT_TOKEN))
    except (KeyboardInterrupt, Exception):
        loop.close()
        client.logout()
        running = False
    finally:
        level.save()
        commands.save()
예제 #5
0
파일: seqmak.py 프로젝트: jfkimberly/SEQMAK
def main():
    """ Main function to determine what command to enter """

    segment_list = []

    while True:

        command = raw_input("Enter a command (type 'help' or 'h' for help):\n")

        if command == 'exit':
            break

        # 'help' command
        # prints a list of possible commands
        elif command == 'help' or command == 'h':
            commands.help()

        # 'newarm (na)' command
        # creates newarms and their corresponding segment sequences in a
        # dictionary 'arms'
        elif command == 'newarms' or command == 'na':
            arms = commands.newarms()

        # 'show (s)' command
        # prints out the created arms
        elif command == 'show' or command == 's':
            try:
                commands.show(arms)
            except UnboundLocalError:
                print "Generate your arms first!"

        # 'link (l)' command
        elif command == 'link' or command == 'l':
            linker_list = commands.linker()

        # 'crunch (c)' command
        # produces random sequences of
        elif command == 'crunch' or command == 'c':
            try:
                strands
            except UnboundLocalError:
                print "Maybe you should generate your strands first ('strandgen')?"
            else:
                try:
                    arms, strands, segment_list =\
                        commands.crunch(arms, strands, linker_list, segment_list)
                    print segment_list
                except TypeError:
                    print "Something's not right. Try 'crunch' again."

        # 'strandgen (sg)' command
        elif command == 'strandgen' or command == 'sg':
            try:
                strands = commands.strandgen(arms, linker_list)
            except UnboundLocalError:
                print "Something's wrong. Maybe you missed a step?"

        # 'repeatcheck (rp) command
        elif command == 'repeatcheck' or command == 'rp':
            try:
                commands.repeatcheck(strands)
            except UnboundLocalError:
                print "Something's wrong. Maybe you missed a step?"

        # 'dyadcheck (dc) command
        elif command == 'dyadcheck' or command == 'dc':
            try:
                commands.dyadcheck(strands)
            except UnboundLocalError:
                print "Something's wrong. Maybe you missed a step?"

        # 'save (sv)' command
        elif command == 'save' or command == 'sv':
            try:
                commands.save(arms, strands)
            except UnboundLocalError:
                print "Something's wrong. Maybe you missed a step?"

        elif command == 'load' or command == 'ld':
            try:
                strands = commands.load()
            except (UnboundLocalError, TypeError):
                print "Try again?"

        else:
            print "What? Retype command!"

    return None