diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2024-06-02 21:56:40 +0200 |
---|---|---|
committer | Bryan Gardiner <bog@khumba.net> | 2024-07-19 20:30:20 -0700 |
commit | 32759f3bc1f2b806460a9713d99bfd375f263435 (patch) | |
tree | 8382e7bbf1abe25c859f58ba7c0c2ce5694bac69 | |
parent | 827b2b4cd09ce4ff87549b21a68a8c4dee140f69 (diff) | |
download | lazygl2srht-32759f3bc1f2b806460a9713d99bfd375f263435.tar.gz |
refactor: it is a general delay, not just the SMTP one.
-rwxr-xr-x | import_issues.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/import_issues.py b/import_issues.py index 2f02a6d..e695b8a 100755 --- a/import_issues.py +++ b/import_issues.py @@ -105,7 +105,7 @@ # specified either via parameters --smtp-{host,port,user,password} or the # equivalent SMTP_{HOST,PORT,USER,PASSWORD} environment variables. Pass # --smtp-ssl to enable SSL. Also by default there is a five-second delay -# between sending emails, that you may wish to change with --smtp-delay. +# between sending emails, that you may wish to change with --delay. # # ./import_issues.py \ # --srht-owner=MY_SRHT_USER \ @@ -174,7 +174,7 @@ def read_id_map_file(file_path: Path) -> Dict[int, str]: def do_mail( *, smtp, - smtp_delay: float, + delay: float, mode: str, frm: str, to: str, @@ -226,7 +226,7 @@ def do_mail( smtp.send_message(msg) - time.sleep(smtp_delay) + time.sleep(delay) else: raise RuntimeError(f"Unknown mode: {mode!r}") @@ -235,7 +235,7 @@ def do_mail( def open_ticket( *, smtp, - smtp_delay: float, + delay: float, mode: str, srht_owner: str, srht_tracker: str, @@ -282,7 +282,7 @@ def open_ticket( do_mail( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, frm=frm, to=f"~{srht_owner}/{srht_tracker}@todo.sr.ht", @@ -297,7 +297,7 @@ def open_ticket( def file_missing_ticket( *, smtp, - smtp_delay: float, + delay: float, mode: str, srht_owner: str, srht_tracker: str, @@ -308,7 +308,7 @@ def file_missing_ticket( do_mail( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, frm=frm, to=f"~{srht_owner}/{srht_tracker}@todo.sr.ht", @@ -322,7 +322,7 @@ def file_missing_ticket( # previous issue to be processed promptly. close_ticket( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, srht_owner=srht_owner, srht_tracker=srht_tracker, @@ -336,7 +336,7 @@ def file_missing_ticket( def send_comment( *, smtp, - smtp_delay: float, + delay: float, mode: str, srht_owner: str, srht_tracker: str, @@ -375,7 +375,7 @@ def send_comment( do_mail( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, frm=frm, to=f"~{srht_owner}/{srht_tracker}/{issue_id}@todo.sr.ht", @@ -386,7 +386,7 @@ def send_comment( def close_ticket( *, smtp, - smtp_delay: float, + delay: float, mode: str, srht_owner: str, srht_tracker: str, @@ -408,7 +408,7 @@ def close_ticket( do_mail( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, frm=frm, to=f"~{srht_owner}/{srht_tracker}/{issue_id}@todo.sr.ht", @@ -419,7 +419,7 @@ def close_ticket( def run( *, smtp, - smtp_delay: float, + delay: float, mode: str, srht_owner: str, srht_tracker: str, @@ -523,7 +523,7 @@ def run( if create_missing_issues: file_missing_ticket( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, srht_owner=srht_owner, srht_tracker=srht_tracker, @@ -555,7 +555,7 @@ def run( srht_issue_id = open_ticket( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, srht_owner=srht_owner, srht_tracker=srht_tracker, @@ -624,7 +624,7 @@ def run( send_comment( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, srht_owner=srht_owner, srht_tracker=srht_tracker, @@ -644,7 +644,7 @@ def run( if issue_json["state"] == "closed": close_ticket( smtp=smtp, - smtp_delay=smtp_delay, + delay=delay, mode=mode, srht_owner=srht_owner, srht_tracker=srht_tracker, @@ -724,9 +724,9 @@ def main(): ) parser.add_argument( - "--smtp-delay", + "--delay", default=5, - help="Decimal number of seconds to wait after sending each email.", + help="Decimal number of seconds to wait between accessing the server.", ) parser.add_argument( @@ -863,7 +863,7 @@ def main(): run( smtp=smtp, - smtp_delay=float(args["smtp_delay"]), + delay=float(args["delay"]), mode=mode, srht_owner=args["srht_owner"], srht_tracker=args["srht_tracker"], |