ruff: Fix PLR1722 Use sys.exit()
instead of exit
.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
93bb7eb61e
commit
5c934e544d
5 changed files with 9 additions and 7 deletions
|
@ -1,4 +1,5 @@
|
|||
import multiprocessing as mp
|
||||
import sys
|
||||
from typing import Any, Dict
|
||||
|
||||
import irc.bot
|
||||
|
@ -47,13 +48,13 @@ class IRCBot(irc.bot.SingleServerIRCBot):
|
|||
resp = self.zulip_client.get_subscriptions()
|
||||
if resp["result"] != "success":
|
||||
print("ERROR: {}".format(resp["msg"]))
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
subs = [s["name"] for s in resp["subscriptions"]]
|
||||
if self.stream not in subs:
|
||||
print(
|
||||
f"The bot is not yet subscribed to stream '{self.stream}'. Please subscribe the bot to the stream first."
|
||||
)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
def on_nicknameinuse(self, c: ServerConnection, e: Event) -> None:
|
||||
c.nick(c.get_nickname().replace("_zulip", "__zulip"))
|
||||
|
|
|
@ -143,7 +143,7 @@ if __name__ == "__main__":
|
|||
'The key "channel_mapping" is not found in bridge_with_slack_config.py.\n'
|
||||
"Your config file may be outdated."
|
||||
)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
print("Starting slack mirroring bot")
|
||||
print("MAKE SURE THE BOT IS SUBSCRIBED TO THE RELEVANT ZULIP STREAM(S) & SLACK CHANNEL(S)!")
|
||||
|
|
|
@ -22,7 +22,7 @@ try:
|
|||
except ImportError as e:
|
||||
print(e, file=sys.stderr)
|
||||
print("Please install the python-dateutil package.", file=sys.stderr)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
import zulip_codebase_config as config
|
||||
|
|
|
@ -112,7 +112,7 @@ try:
|
|||
except OSError:
|
||||
# We can't write to the logfile, so just print and give up.
|
||||
print(f"Unable to store RSS data at {opts.data_dir}.", file=sys.stderr)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
log_file = os.path.join(opts.data_dir, "rss-bot.log")
|
||||
log_format = "%(asctime)s: %(message)s"
|
||||
|
@ -130,7 +130,7 @@ logger.addHandler(file_handler)
|
|||
def log_error_and_exit(error: str) -> None:
|
||||
logger.error(error)
|
||||
logger.error(usage)
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class MLStripper(HTMLParser):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import zulip
|
||||
|
@ -56,7 +57,7 @@ while not found_newest:
|
|||
# Might occur when the request is not returned with a success status
|
||||
print("Error occured: Payload was:")
|
||||
print(result)
|
||||
quit()
|
||||
sys.exit()
|
||||
|
||||
with open(options.filename, "w+") as f:
|
||||
print("Writing %d messages..." % len(all_messages))
|
||||
|
|
Loading…
Add table
Reference in a new issue