Commit graph libervia-backend/sat/tools
Author SHA1 Message Date
Goffi
1d0a1b66d9 core (bridge): action_new now use serialised dict for extra data. 2023-05-15 16:20:45 +02:00
Goffi
6a6f15707a massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a
pre-PEP8 code, to use the same coding style as in Twisted.

However, snake_case is more readable and it's better to follow PEP8 best practices, so it
has been decided to move on full snake_case. Because Libervia has a huge codebase, this
ended with a ugly mix of camelCase and snake_case.

To fix that, this patch does a big refactoring by renaming every function and method
(including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case.

This is a massive change, and may result in some bugs.
2023-04-08 13:54:42 +02:00
Goffi
9b47e8c890 core (plugins): implementation of XEP-0215 "External Service Discovery":
rel 418
2023-04-07 15:16:39 +02:00
Goffi
ef70ccaedb tools (xml_tools): add fields's values when converting data form to dict 2023-04-07 14:59:01 +02:00
Goffi
f3dd4b8ddc tools (common/template): add 2 new filters: timestamp_to_hour and delta_to_human:
`timestamp_to_hour` give the hour corresponding to a timestamp, it will be used to display
calendar for this time window.
`delta_to_human` convert a delta of 2 timestamp to human readable time using
`tools.common.date_utils` corresponding function.
2023-03-30 16:57:11 +02:00
Goffi
92f669ca8b tools (common/template): let specify timezone name in date_fmt filter 2023-03-30 16:53:41 +02:00
Goffi
4a8635d4a2 tools (common/date_utils): new get_timezone_name to retrieve it from a tzinfo and a timestamp 2023-03-30 16:52:18 +02:00
Goffi
63d62f66f0 tools (common/date_utils): let use a timezone name as str in date_fmt 2023-03-30 16:51:09 +02:00
Goffi
108c41bf73 tools (xml_tools): accept several namespaces in findAncestor 2023-03-16 16:43:08 +01:00
Goffi
a53ab322f3 tools (strem): fix mode + add pre_close_cb callback:
rel 378
2022-10-31 04:04:32 +01:00
Syndace
e062c2f0e5 plugin XEP-0384: Implementation of Automatic Trust Management:
- Implementation of Trust Messages (XEP-0434)
- Implementation of Automatic Trust Management (XEP-0450)
- Implementations directly as part of the OMEMO plugin, since omemo:2 is the only protocol supported by ATM at the moment
- Trust system selection updated to allow choice between manual trust with ATM and BTBV
- dev-requirements.txt updated to include additional requirements for the e2e tests

fix 376
2022-10-28 18:50:06 +02:00
Goffi
6255985262 tools (xml_tools): domish_elt_2_et_elt and et_elt_2_domish_elt now handle lxml.etree 2022-10-28 18:47:17 +02:00
Goffi
f7fdde6dce tools (utils): fix parse_xmpp_date timezone:
rel 381
2022-10-28 18:47:17 +02:00
Goffi
7f0e230af4 tools (common/async_utils): set default maxsize to 50 in async_lru 2022-10-15 20:37:00 +02:00
Syndace
6d1e942f43 plugin XEP-0373 and XEP-0374: Implementation of OX and OXIM:
GPGME is used as the GPG provider.

rel 374
2022-09-20 16:22:18 +02:00
Goffi
0f20af88f1 tools (stream): log error when a SatFile is closed:
error where only sent on `ProgressError`, but it is necessary to log the error as it may
happen before any progression is started.
2022-10-06 16:02:05 +02:00
Goffi
8444115262 plugin XEP-0384, xml_tools: avoid getItems timeout + fix empty node crash + parsing:
- use `max_items` in `getItems` calls for bundles, as otherwise some pubsub service may
  return full nodes, which may be huge is `max_items=1` is not set on the node, possibly
  resulting in timeouts.

- the plugin was crashing when TWOMEMO devices list node has no items at all. This is not
  the case anymore.

- a naive parsing method has been implemented in `xml_tools` to replace the
  serialisation/deserialisation method. This should be more efficient and will avoid
  annoying `ns0:` prefixes in XML logs.
2022-09-24 16:37:46 +02:00
Syndace
75ae8160ae plugin XEP-0384: Fully reworked to adjust to the reworked python-omemo:
- support for both (modern) OMEMO under the `urn:xmpp:omemo:2` namespace and (legacy) OMEMO under the `eu.siacs.conversations.axolotl` namespace
- maintains one identity across both versions of OMEMO
- migrates data from the old plugin
- includes more features for protocol stability
- uses SCE for modern OMEMO
- fully type-checked, linted and format-checked
- added type hints to various pieces of backend code used by the plugin
- added stubs for some Twisted APIs used by the plugin under stubs/ (use `export MYPYPATH=stubs/` before running mypy)
- core (xmpp): enabled `send` trigger and made it an asyncPoint

fix 375
2022-08-23 21:06:24 +02:00
Goffi
093b9d83bc tools (common/date_utils) handle timestamp and in + delta2human:
regex used to parse datetimes has been improved to handle a unix time (which can be used
with `+ <delta>` or `- <delta>`), and the `in <delta>` (e.g. `in 6 days`).

`DEFAULT_DATETIME` has been removed as dateutil use current date by default, which is the
expected behaviour.

Add `delta2human` method which convert the difference of 2 unix times to a human friendly
approximate text.

rel 372
2022-09-22 00:01:48 +02:00
Goffi
97c0d6a0e5 tools (xml_tools): handle required field in dataDict2dataForm:
rel 372
2022-09-21 22:43:55 +02:00
Goffi
1e4fc213f6 tools (utils): helper parse_xmpp_date method:
This method converts an XMPP date(time) to a unix time

rel 372
2022-09-21 22:29:54 +02:00
Goffi
a74f9327f2 core, CLI (base), tools (common/data_format): typing/core readability 2022-09-21 22:20:43 +02:00
Goffi
672174fb23 tools: renamed module sat.tools.datetime to date.tools.xmpp_datetime to avoid conflict with Python's standard lib 2022-08-31 13:18:56 +02:00
Goffi
ed3660c4a7 tools (datetime, utils): fix incorrect use of naive object:
`tools.datetime.format_datetime` was expecting aware datetime objects while
`tools.utils.xmpp_date` was returning naive datetime objects. A check has been added to
the former one, and latter one has been modified to return aware datetime objects.
2022-08-31 13:11:26 +02:00
Syndace
d1b5ff0c41 plugin XEP-0420: Implementation of Stanza Content Encryption:
Includes implementation of XEP-0082 (XMPP date and time profiles) and tests for both new plugins.
Everything is type checked, linted, format checked and unit tested.
Adds new dependency xmlschema.

fix 377
2022-08-23 12:04:11 +02:00
Goffi
6c170ef8cc plugin XEP-0060, tools (utils): doc/type hints 2022-07-20 17:18:17 +02:00
Goffi
70cfacfe1a tools (common/uri): accept URIs without type:
URIs without type are used to link JIDs.

rel 369
2022-07-09 16:30:37 +02:00
Goffi
1e1da8a7ae core (tools/web): helped method to download files:
this method is for internal file download, progression mechanism is not used.

rel 368
2022-06-29 12:07:45 +02:00
Goffi
8946b6fb4e tools (common/email): use from_email is specified, always set email_sender_domain 2022-05-16 13:03:53 +02:00
Goffi
7d6c2eb6f2 tools (async_trigger): fix return value in asyncReturnPoint + typing hints 2022-05-13 18:19:56 +02:00
Goffi
d3b81a7fa9 tools (common/template): fix setting of css_files_noscript when css_file is specified 2022-03-22 17:00:42 +01:00
Goffi
3ee5e1bbba tools (utils): fix getRepositoryData crash:
- use `hg_path` to be sure to use the right executable
- better exception handling
2022-03-22 17:00:42 +01:00
Goffi
e393c908b0 tools (xml_tools): fix widget_args modification in _dataFormField2XMLUIData:
in `textbox` widget, the first arg was modified with all values, lettings other ones
unchanger, resulting in invalid number of arguments. This has been fixed by replacing all
args with the new value.
2022-01-31 18:35:52 +01:00
Goffi
9b5d3ea17d tools (common): new async_utils module with an async version of lru_cache 2022-01-25 17:25:10 +01:00
Goffi
03ca0037f3 tools (xml_tools): implement list-multi in _dataFormField2XMLUIData:
`list-multi` was missing and thus these data form field type was not supported, resulting
in those fields shown as a text field.

Due to legacy, current implementation use a hack to split values, this should be fixed
later by using proper serialisation.
2021-12-08 15:45:57 +01:00
Goffi
7b05d97229 merge bookmark 0.9 2021-12-01 16:13:31 +01:00
Goffi
9eecdc184c tools (common/async_process): use parent environment by default 2021-11-30 17:28:42 +01:00
Goffi
50d7cb2a51 merge bookmark @ 2021-09-08 11:20:37 +02:00
Goffi
adad4494c3 tools (common/uri): fix uri parsing for Python 3.9+ 2021-09-08 11:14:47 +02:00
Goffi
fe502fc0fc merge branche "@" 2021-08-28 15:32:58 +02:00
Goffi
547eb9feba bridge: bridge can now be set using environment variable:
The `LIBERVIA_BRIDGE_NAME` environment variable can now be used to specify the bridge to
use. If set and different from empty string, the environment has precedence over config
file value.

For `pb` bridge, the following environment variable can also be used:

- LIBERVIA_BRIDGE_PB_CONNECTION_TYPE
- LIBERVIA_BRIDGE_PB_HOST
- LIBERVIA_BRIDGE_PB_PORT
2021-08-28 15:26:02 +02:00
Goffi
436696f28c merge branche "@" 2021-08-27 14:51:40 +02:00
Goffi
506368275a tools (common/date_utils): parse now alone (when used without relative delta) 2021-08-27 14:48:38 +02:00
Goffi
cb62511fa7 tools (common/async_process): remove useless encoding + use full path for command:
- arguments don't need to be encoded anymore, `spawnProcess` handles str directly now
- use full path even for first argument: even if first argument should be only executable
  name, it appears that using full path only in `command` is not enough (seen with Python
  where system installation is used instead of the VirtualEnv one when full path is not
  used as first argument).
(grafted from 25cbaf04772855cd8aead18771465a4f00f5fa03)
2021-07-29 22:51:01 +02:00
Goffi
60fe49f883 tools (common/async_process): remove useless encoding + use full path for command:
- arguments don't need to be encoded anymore, `spawnProcess` handles str directly now
- use full path even for first argument: even if first argument should be only executable
  name, it appears that using full path only in `command` is not enough (seen with Python
  where system installation is used instead of the VirtualEnv one when full path is not
  used as first argument).
2021-07-29 22:51:01 +02:00
Goffi
aab8a38836 tools (common/date_utils): accept more units (shortcuts) + fix timezone when date with relative delta is used 2021-07-29 22:51:01 +02:00
Goffi
4421eefbf3 merge changes from main branch 2021-06-17 13:05:58 +02:00
Goffi
7adbf3ead8 core, frontends: fix invalid translatable strings.
Some f-strings where used in translatable text, this has been fixed by using explicit
`format()` call (using a script based on `tokenize`).

As tokenize messes with spaces, a reformating tool (`black`) has been applied to some
files afterwards.
2021-06-14 18:35:12 +02:00
Goffi
80ee158daa tools (common/template_xmlui: add multi and value propertied to OptionsWidget 2021-06-04 14:44:33 +02:00
Goffi
893e8e7a96 tools (utils): new ensure_deferred decorator 2021-06-03 15:21:43 +02:00