コード例 #1
0
 def test_exception(self, mock_console):
     check_for_updates()
     exception_message: str = (
         "Following error occured when checking for updates\n"
         "<class 'json.decoder.JSONDecodeError'>, Expecting property name enclosed in double quotes: line 1 column 2 (char 1)"
     )
     mock_console.return_value.log.assert_called_with(exception_message)
コード例 #2
0
 def test_update(self, mock_markdown, mock_console):
     check_for_updates()
     name: str = "v0.0.0 2022-03-02"
     html_url: str = "https://github.com/Dineshkarthik/telegram_media_downloader/releases/tag/v0.0.0"
     expected_message: str = (
         f"## New version of Telegram-Media-Downloader is available - {name}\n"
         "You are using an outdated version v0.0.1 please pull in the changes using `git pull` or download the latest release.\n\n"
         f"Find more details about the latest release here - {html_url}")
     mock_markdown.assert_called_with(expected_message)
     mock_console.return_value.print.assert_called_once()
コード例 #3
0
def main():
    """Main function of the downloader."""
    with open(os.path.join(THIS_DIR, "config.yaml")) as f:
        config = yaml.safe_load(f)
    updated_config = asyncio.get_event_loop().run_until_complete(
        begin_import(config, pagination_limit=100))
    if FAILED_IDS:
        logger.info(
            "Downloading of %d files failed. "
            "Failed message ids are added to config file.\n"
            "These files will be downloaded on the next run.",
            len(set(FAILED_IDS)),
        )
    update_config(updated_config)
    check_for_updates()
コード例 #4
0
ファイル: socie.py プロジェクト: archvillain/socie
def main():
    # start the client coroutine
    TOKEN=""
    try:
        if sys.argv[1] == "--help" or sys.argv[1] == "-h":
            from utils.print_utils.help import print_help
            print_help()
            quit()
        elif sys.argv[1] == "--token" or sys.argv[1] == "--store-token":
            store_token()
            quit()
        elif sys.argv[1] == "--skeleton" or sys.argv[1] == "--copy-skeleton":
            # ---- now handled in utils.settings.py ---- #
            pass
        elif sys.argv[1] == "--config":
            # --- now handled in utils.settings.py ---- #
            pass
        else:
            print(gc.term.red("E̸̗͚̰̜͎̫̿̐̊̔͆̾̉̊̅̚͝RRƠ̸̳̙̙̯̌͒̓̽͒̒̄̓͒̽͒͊̅̍̐̇̋̽̅̎̿͒̈́̈͒̈́͝͝͠͝͝R: Unknown command."))
            print(gc.term.yellow("オプションについては 「 --help 」 を参照してください。\nSee --help for options."))
            quit()
    except IndexError: 
        pass

    check_for_updates()
    token = get_token()
    init_input()

    print(gc.term.yellow("S̷̨̻͗̋͒ociet̸̼̯̣͑̈́͝t̶̲̺̰́̌e   🗲  「 ソシエット 」を参ります。お待ちください。\n\nSociette (Erune): Scarlet Vane\n"))
    print(gc.term.yellow("作成... Alabaster Dance Tenka..."))
    print(gc.term.yellow("作成... First Dance Kagura..."))
    print(gc.term.yellow("作成... Sixth Dance Bizen..."))
    print(gc.term.yellow("作成... Closing Dance Tokiyomi..."))
    print(gc.term.yellow("作成とYuel... Sapphire Dance: Gentiana...\n"))
    print(gc.term.yellow("Setting up Societte (socie)...\n"))


    # start the client
    try: gc.client.run(token, bot=False)
    except KeyboardInterrupt: pass
    except SystemExit: pass

    # if we are here, the client's loop was cancelled or errored, or user exited
    try: kill()
    except:
        # if our cleanly-exit kill function failed for whatever reason,
        # make sure we at least exit uncleanly
        quit()
コード例 #5
0
ファイル: Discline.py プロジェクト: theriddleywalker/Discline
def main():
    # start the client coroutine
    TOKEN = ""
    try:
        if sys.argv[1] == "--help" or sys.argv[1] == "-h":
            from utils.print_utils.help import print_help
            print_help()
            quit()
        elif sys.argv[1] == "--token" or sys.argv[1] == "--store-token":
            store_token()
            quit()
        elif sys.argv[1] == "--skeleton" or sys.argv[1] == "--copy-skeleton":
            # ---- now handled in utils.settings.py ---- #
            pass
        elif sys.argv[1] == "--config":
            # --- now handled in utils.settings.py ---- #
            pass
        else:
            print(gc.term.red("Error: Unknown command."))
            print(gc.term.yellow("See --help for options."))
            quit()
    except IndexError:
        pass

    check_for_updates()
    token = get_token()
    init_input()

    print(gc.term.yellow("Starting..."))

    # start the client
    try:
        gc.client.run(token, bot=False)
    except KeyboardInterrupt:
        pass
    except SystemExit:
        pass

    # if we are here, the client's loop was cancelled or errored, or user exited
    try:
        kill()
    except:
        # if our cleanly-exit kill function failed for whatever reason,
        # make sure we at least exit uncleanly
        quit()
コード例 #6
0
def main():
    # start the client coroutine
    if settings and settings["debug"]:
        startLogging()
    token = None
    try:
        if sys.argv[1] == "--help" or sys.argv[1] == "-h":
            draw_help()
            quit()
        elif sys.argv[1] == "--token" or sys.argv[1] == "--store-token":
            store_token()
            quit()
        elif len(sys.argv) == 3 and sys.argv[1] == "--token-path":
            try:
                with open(sys.argv[2]) as f:
                    token = f.read()
            except:
                print("Error: Cannot read token from path")
                quit()
        elif sys.argv[1] == "--skeleton" or sys.argv[1] == "--copy-skeleton":
            # -- now handled in utils.settings.py --- #
            pass
        elif sys.argv[1] == "--config":
            # -- now handled in utils.settings.py --- #
            pass
        elif sys.argv[1] == "--test":
            if len(sys.argv) < 3:
                print(gc.term.red("Error: Incorrect syntax for --test"))
                print(gc.term.yellow("Syntax: Discline.py --test testName"))
                quit()
            elif sys.argv[2] in ("input", "formatting", "scrolling",
                                 "sendrecv"):
                runTest(sys.argv[2])
                quit()
        else:
            print(gc.term.red("Error: Unknown command."))
            print(gc.term.yellow("See --help for options."))
            quit()
    except IndexError:
        pass

    check_for_updates()
    if token is None:
        token = get_token()

    print(gc.term.yellow("Starting..."))

    # start the client
    try:
        gc.client.run(token, bot=False)
    except KeyboardInterrupt:
        pass
    except SystemExit:
        pass
    try:
        gc.client.close()
    except:
        pass
    try:
        asyncio.get_event_loop().close()
    except:
        pass

    # if we are here, the client's loop was cancelled or errored, or user exited
    curses.nocbreak()
    gc.ui.screen.keypad(False)
    curses.echo()
    curses.endwin()
コード例 #7
0
def main():
    # start the client coroutine
    if settings and settings["debug"]:
        startLogging()
    token = None
    try:
        if sys.argv[1] == "--help" or sys.argv[1] == "-h":
            try:
                asyncio.get_event_loop().run_until_complete(runSimpleHelp())
            except SystemExit:
                pass
            quit()
        elif sys.argv[1] == "--token" or sys.argv[1] == "--store-token":
            store_token()
            quit()
        elif len(sys.argv) == 3 and sys.argv[1] == "--token-path":
            try:
                with open(sys.argv[2]) as f:
                    token = f.read()
            except:
                print("Error: Cannot read token from path")
                quit()
        elif sys.argv[1] == "--skeleton" or sys.argv[1] == "--copy-skeleton":
            # -- now handled in utils.settings.py --- #
            pass
        elif sys.argv[1] == "--config":
            # -- now handled in utils.settings.py --- #
            pass
        elif sys.argv[1] == "--test":
            if len(sys.argv) < 3:
                print(gc.term.red("Error: Incorrect syntax for --test"))
                print(gc.term.yellow("Syntax: Discline.py --test testName"))
                quit()
            elif sys.argv[2] in ("input", "formatting", "scrolling",
                                 "sendrecv"):
                runTest(sys.argv[2])
                quit()
        else:
            print(gc.term.red("Error: Unknown command."))
            print(gc.term.yellow("See --help for options."))
            quit()
    except IndexError:
        pass

    check_for_updates()
    if token is None:
        token = get_token()

    print(gc.term.yellow("Starting..."))

    # start the client
    loop = asyncio.get_event_loop()
    try:
        loop.run_until_complete(gc.client.start(token, bot=False))
    except:
        pass

    # stop the client and close the event loop
    try:
        gc.client.close()
        loop.close()
    except:
        pass

    if gc.ui.isInitialized:
        curses.nocbreak()
        gc.ui.screen.keypad(False)
        curses.echo()
        curses.endwin()