2020-11-29 15:27

[V3 Launcher] add launcher


  • [ ] Bugfix
  • [ ] Enhancement
  • [x] New feature

Description of the changes

Supersedes #1006

Current summary of what the launcher has:

  • Running Red (with or without autorestart)
  • Updating Red (either from PyPI or Github)
  • Instance creation (via redbot-setup)
  • Debug info (Python version, Red version, OS version/arch, user who ran the launcher)
  • CLI flags for all of the above except instance creation

Things that could probably still be added: * support for selecting/providing (depending on whether the user is in interactive mode or not) cli flags to be passed to redbot


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • weixin_39639381 weixin_39639381 5月前

    So this introduces a dependency on distro but only if on Linux (this is used for determining the distribution and version). Also the cli flag selecting thing has been finished, with an interactive walkthrough being done if running the launcher in interactive mode and a cli flag to pass in a file name containing a list of cli flags to be passed in (one per line) for non-interactive mode

    点赞 评论 复制链接分享
  • weixin_39915081 weixin_39915081 5月前

    Recommend using parser.parse_known_args() and/or supporting the use case of adding CLI flags after a positional escape (--) by capturing extra positionals with nargs='+'

    点赞 评论 复制链接分享
  • weixin_39639381 weixin_39639381 5月前

    Ok, this is now using parser.parse_known_args as well as setting argparse.ArgumentParser's allow_abbrev kwarg to False. Thus to run the launcher in non-interactive mode with some flags being passed on to redbot (for example, --dev and --debug), one could do python3 redbot/launcher.py <instance_name> -s --dev --debug which would result in running redbot <instance_name> --dev --debug

    点赞 评论 复制链接分享
  • weixin_39640008 weixin_39640008 5月前

    Can you catch KeyboardInterrupt?

    点赞 评论 复制链接分享
  • weixin_39759155 weixin_39759155 5月前

    of course you can catch KeyboardInterupt.

    import time
        while True:
    except KeyboardInterrupt:
        print('\ndo cleanup')

    results in:

    do cleanup

    when interrupted

    点赞 评论 复制链接分享
  • weixin_39639381 weixin_39639381 5月前

    ok, KeyboardInterrupt is now being handled for the launcher itself

    点赞 评论 复制链接分享
  • weixin_39622587 weixin_39622587 5月前

    looks good to go. 👍 from me unless you guys want to hide those 2 flags before merging

    点赞 评论 复制链接分享