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