Commit graph

47 commits

Author SHA1 Message Date
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
Anders Kaseorg 396ef1d11a Update zulipchat.com emails to zulip.com.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 21:06:58 -07:00
Anders Kaseorg 5f81eb3a70 Update zulipchat.com links to zulip.com.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 21:06:58 -07:00
Anders Kaseorg 17cf26aa1f cleanup: Move line breaks before binary operators.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 20:31:14 -07:00
Anders Kaseorg 2f6623bbc4 cleanup: Remove unused imports.
Generated by autoflake.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 20:31:14 -07:00
Anders Kaseorg 5428c5f296 typing: Convert function type annotations to Python 3 style.
Generated by com2ann (slightly patched to avoid also converting
assignment type annotations, which require Python 3.6), followed by
some manual whitespace adjustment, and two fixes for use-before-define
issues:

-    def set_zulip_client(self, zulipToJabberClient: ZulipToJabberBot) -> None:
+    def set_zulip_client(self, zulipToJabberClient: 'ZulipToJabberBot') -> None:

-def init_from_options(options: Any, client: Optional[str] = None) -> Client:
+def init_from_options(options: Any, client: Optional[str] = None) -> 'Client':

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 20:31:14 -07:00
Anders Kaseorg fe72f3b131 typing: Remove ‘if False’ guard for typing imports.
typing is in the Python 3.5 standard library.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 20:31:14 -07:00
Anders Kaseorg e30b3b094b Modernize legacy Python 2 syntax with pyupgrade.
Generated by `pyupgrade --py3-plus --keep-percent-format` followed by
manual indentation fixes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 15:04:36 -07:00
rht 46c78ce7b5 integrations: Remove usage of six. 2020-04-02 13:02:28 -04:00
rht 1412403037 integrations: Remove from __future__ imports. 2020-04-02 13:02:28 -04:00
rht a465467388 integrations: Switch to python3. 2020-04-02 13:02:28 -04:00
neiljp (Neil Pilgrim) 60984ab2fa mypy: Add type ignores for mixing of str & bytes in zephyr mirror.
In principle these should be fixed properly, but the zephyr code is
difficult to test except in a production setting and is unlikely to be
heavily developed in future.
2020-03-24 21:25:45 -07:00
neiljp (Neil Pilgrim) f81843f189 mypy: Clarify type hints in zulip/integrations/. 2020-03-24 21:25:45 -07:00
rht 8a74f576a3 python: Remove per-file copyright notices.
These notices are redundant and obscure what are often very short
example scripts.
2020-03-23 12:52:52 -07:00
XavierCooney 68ec3a5ef0 zephyr_mirror_backend.py: Remove duplicate import. 2018-01-16 08:07:09 -05:00
neiljp (Neil Pilgrim) aa718da3e1 Zephyr: For correctness & mypy, res.get('result') -> res['result'].
Also correct nearby error message (subscribing to -> receiving).
2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 02d9ba8edd mypy: Add cast for zephyr_mirror_backend logger variable. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 466f5a7167 mypy: Amend zephyr mirror annotations for strict-optional. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 33ccc04a32 mypy: Amend code & typing of integrations, to pass with strict-optional. 2018-01-02 14:05:33 -05:00
neiljp (Neil Pilgrim) 28687f18ca mypy: Add --disallow-any=generics & extend typing accordingly.
Also reset typing of ExternalBotHandler to Any after discussion.
2017-12-11 20:14:00 -06:00
Alena Volkova 671a078137 mypy: zulip: Fix errors in integrations/zephyr/process_ccache. 2017-10-27 00:56:06 -04:00
Tim Abbott dc2132e629 zephyr_mirror: Eliminate --root-path arguments.
These were quite messy code, and now that almost nobody is running
their own zephyr mirroring script (vs. using webathena), making the
zephyr mirroring script deployable outside the package isn't super
valuable.
2017-10-05 13:24:59 -07:00
Tim Abbott 963e6d0ad8 zephyr_mirror: Always run backend script from current directory.
While this technically removes functionality, it's rare that it would
be useful to do this.
2017-10-05 13:17:10 -07:00
Tim Abbott 96f2100974 zephyr: Remove root-path import nonsense from check-mirroring.
We no longer need this in order to access the script's dependencies,
since it now is part of a proper package.
2017-10-05 13:02:58 -07:00
Tim Abbott bc4e54a35d zephyr_mirror: Restart self using __file__, not root-path.
This should do the same thing, but with less complexity.
2017-10-05 12:46:01 -07:00
Tim Abbott 7e5a320343 zephyr_mirror: Move stamp_path to not be based on root_path. 2017-10-05 12:37:49 -07:00
Tim Abbott 6395dc1a45 zephyr_mirror: Update process_cache for repository move.
This also has the side effect of stopping using the --root-path
argument, which should no longer be required.
2017-10-05 12:21:11 -07:00
Tim Abbott 807afd2032 zephyr: Use add_default_arguments in sync_public_streams. 2017-09-29 16:21:18 -07:00
derAnfaenger 631c64ca6c zulip: Move from simplejson to json.
This removes the simplejson dependency.
2017-09-14 02:26:56 -07:00
derAnfaenger 50d8c5f7fe zulip package: Add requirements.txt for each integration. 2017-09-12 01:39:21 -07:00
Eeshan Garg 3d0f7955b6 api: Move the API package to a dedicated subdirectory.
In order to keep all three packages (zulip, zulip_bots,
zulip_botserver) in the same repo, all package files must now
be nested one level deeper.

For instance, python-zulip-api/zulip_bots/zulip_bots/bots/, instead
of python-zulip-api/zulip_bots/bots/.
2017-07-18 02:20:32 -02:30