Commit graph

80 commits

Author SHA1 Message Date
Alex Vandiver
43a4900e1f zephyr: Delete DMs after they are received. 2024-08-13 10:39:27 -07:00
Anders Kaseorg
6aedfe6457 python: Fix PAR002 Dont use parentheses for unpacking.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-11 16:41:53 -08:00
Anders Kaseorg
059458b4ca python: Fix PAR001 Redundant parentheses.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-11 16:41:52 -08:00
Anders Kaseorg
aeb89bcae5 ruff: Enable lots of rules.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-11 16:16:17 -08:00
Anders Kaseorg
188d459ab1 ruff: Fix S108 Probable insecure usage of temporary file or directory.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-09 20:26:03 -08:00
Anders Kaseorg
a2ddac75f3 ruff: Fix TRY002 Create your own exception.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-01 20:29:34 -07:00
Anders Kaseorg
3e2f839946 ruff: Fix TRY300 Consider moving this statement to an else block.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-01 20:27:51 -07:00
Anders Kaseorg
6a7fe98eef ruff: Fix S110 try-except-pass detected, consider logging the exception.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-01 19:22:59 -07:00
Anders Kaseorg
f26b861f51 ruff: Fix RUF012 Mutable class attributes should be annotated with typing.ClassVar.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-01 19:22:53 -07:00
Anders Kaseorg
43a9263114 ruff: Fix SIM115 Use context handler for opening files.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-11-01 16:58:19 -07:00
Anders Kaseorg
03d132e99e ruff: Fix B007 Loop control variable not used within loop body.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-30 11:44:10 -07:00
Anders Kaseorg
347490c647 ruff: Fix RUF015 Prefer next(iter(…)) over single element slice.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-30 11:44:10 -07:00
Anders Kaseorg
610683ea41 ruff: Fix RUF005 Consider unpacking instead of concatenation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-30 11:44:10 -07:00
Anders Kaseorg
12e63f493f ruff: Fix PLW2901 for loop variable overwritten by assignment target.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-30 11:44:10 -07:00
Anders Kaseorg
93bb7eb61e ruff: Fix PLR1714 Consider merging multiple comparisons.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-30 11:44:10 -07:00
Anders Kaseorg
7aeb8f2619 ruff: Fix PIE810 Call startswith once with a tuple.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 18:17:39 -07:00
Anders Kaseorg
008efed12b ruff: Fix SIM300 Yoda conditions are discouraged.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 18:17:39 -07:00
Anders Kaseorg
93156d994a ruff: Fix SIM118 Use key in dict instead of key in dict.keys().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 18:17:39 -07:00
Anders Kaseorg
58a3026f37 ruff: Fix SIM102 Use a single if statement instead of nested if statements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 18:17:39 -07:00
Anders Kaseorg
774edb434e ruff: Fix C400 Unnecessary generator (rewrite as a list comprehension).
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-29 17:36:51 -07:00
Anders Kaseorg
6b2861c3ec ruff: Fix G004 Logging statement uses f-string.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:18:11 -07:00
Anders Kaseorg
d85ace8e7e ruff: Fix G003 Logging statement uses +.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:17:21 -07:00
Anders Kaseorg
02e0555e0d ruff: Fix G002 Logging statement uses %.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:17:21 -07:00
Anders Kaseorg
e537bbefdf ruff: Fix G001 Logging statement uses str.format.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-28 16:17:21 -07:00
Anders Kaseorg
63246e4369 ruff: Fix RUF010 Use explicit conversion flag.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:41:04 -07:00
Anders Kaseorg
fcd4fe330d ruff: Fix UP031 Use format specifiers instead of percent format.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:04:41 -07:00
Anders Kaseorg
ddccf0eda3 ruff: Fix UP032 Use f-string instead of format call.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-27 22:01:58 -07:00
Anders Kaseorg
6cb1d5f775 mypy: Enable explicit-override error.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-26 14:03:17 -07:00
Anders Kaseorg
2ecabb3260 Fix signal handler types.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-25 13:23:51 -07:00
Anders Kaseorg
a9607dfdf9 Convert type comments to Python ≥ 3.6 variable annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-18 01:04:47 -07:00
Zixuan James Li
1b8f1d6e51 lint: Pin black to avoid inconsistent formatting.
This also runs black to reformat the affected files, which had been
causing failures because of upstream updates.

Ideally, we need a more sophisticated toolchain for managing the
versions of the dependencies instead of just requirements.txt. This
should be due in a possible future cleanup.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-05-29 10:53:22 -07:00
Zixuan James Li
63f46f4bbb zephyr: Add missing return type annotation.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
2023-05-29 10:53:22 -07:00
Anders Kaseorg
02586f1d34 zephyr_mirror: Port sharding wrapper to asyncio.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-25 16:53:09 -08:00
Anders Kaseorg
7831d979c9 zephyr: Free received notices with ZFreeNotice.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-24 12:23:44 -08:00
Anders Kaseorg
92120914f8 process_ccache: Adjust supervisor_path to avoid Puppet purging.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Anders Kaseorg
a534446315 zephyr: Remove python-zephyr in favor of ctypes.
Our custom patched version of python-zephyr only worked on Python 2.
Now we don’t need python-zephyr at all.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Anders Kaseorg
56f805a5d7 zephyr_mirror_backend: Fix thread safety problems.
As of commit 5eaac7bfba (#18),
zulip.Client is not thread-safe and especially not fork-safe due to
connections held open by requests.Session.

Delay construction of the Client until after forking off
zulip_to_zephyr.  Replace the fork for each message sent by
zephyr_to_zulip with a threaded queue worker.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-13 16:43:40 -07:00
Anders Kaseorg
5da0857d51 zephyr_mirror_backend: Add missing parens for calling lower().
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-08-28 08:32:07 -07:00
PIG208
9ce7c52a10 pyupgrade: Reformat with --py36-plus.
This includes mainly fixes of string literals using f-strings or
.format(...), as well as unpacking of list comprehensions.
2021-06-02 18:45:57 -07:00
PIG208
6f3f9bf7e4 black: Reformat without skipping string normalization. 2021-06-02 18:45:57 -07:00
PIG208
fba21bb00d black: Reformat skipping string normalization. 2021-06-02 18:45:57 -07:00
PIG208
5580c68ae5 isort: Reformat using isort. 2021-06-02 18:45:57 -07:00
Anders Kaseorg
83d4a0c217 sync-public-streams: Rewrite using an event queue.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-06 23:36:35 -07:00
Anders Kaseorg
15c46dce46 sync-public-streams: Fix for Python 3.
bytes are not JSON serializable.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-06 23:36:35 -07:00
Tim Abbott
4627b07396 zephyr: Decrease update frequency of sync-public-streams. 2021-04-06 15:15:42 -07:00
Anders Kaseorg
503e8ed82d zephyr: Attempt to fix types.
The mirror has some chance of running on Python 3 now, once the
python-zephyr patch is rebased on 0.2.1, though it’s untested.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 23:59:15 -08:00
Anders Kaseorg
34012a4015 mypy: Add stubs for zephyr.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-10 23:59:15 -08:00
Tim Abbott
59a0a912a8 process_ccache: Update path to Zulip supervisord files. 2020-12-20 11:46:24 -08:00
Alex Vandiver
7a7cfe637e zephyr: Mark the infinite loops as NoReturn. 2020-08-10 15:07:01 -07:00
Alex Vandiver
a20c9cc6d7 zephyr: Use exponential backoffs in retry loops.
This reduces the number of retries that might spam APIs.

There is some complexity here which is left un-managed -- for
instance, maybe_restart_mirroring_script does a number of restart
attempts, and then fails, but will be retried every 15s by the
surrounding `process_loop`.  Previously, it would merely have looped
forever inside maybe_restart_mirroring_script.

Three loops are intentionally left as infinite `while True` loops,
that merely cap their backoff at the default 90s.  Their callers do
not expect, or have any way to handle more gracefully, a failure of
the expected-infinite-loop in `process_loop` or `zulip_to_zephyr`.
They maintain their previous behavior of retrying forever, albeit more
slowly.
2020-08-10 15:07:01 -07:00