Commit graph libervia-backend/sat/tools
Author SHA1 Message Date
Goffi
a1eb68c1e7 core: replaced sat shell script by a python script:
the backend is now launched by `sat.core.launcher`, and the script is generated during
installation with a new entry point in `setup.py`.
2020-05-25 15:50:01 +02:00
Goffi
205bd5cdb4 tools (common/template): new icon_from_client method:
this method is available from template, and returns the name of the icon to use according
to disco client data.
2020-05-18 23:41:36 +02:00
Goffi
9780bd3480 plugin pubsub schema, tools (common/template xmlui): use a JID for publisher:
- a JidWidget is used instead of text for publisher, nothing is set if publisher attribute
  doesn't exist
- added missing JidWidget implementation in tools.common.template_xmlui
2020-05-18 23:37:04 +02:00
Goffi
19a9e38983 tools (common/template): theme settings with possibility to disable default fallback for CSS:
- themes can now have a `settings.json` file at their root to modify the renderer
  behaviour
- the `css_default_fallback` boolean (true by default) can be used to disable the fallback
  mechanism when CSS files are checked. Useful when a theme doesn't follow the CSS naming of
  default theme.
- introduced some type hints
2020-05-03 17:01:39 +02:00
Goffi
2908be8898 tools (common/template): typos 2020-05-03 13:40:04 +02:00
Goffi
3f735d406e tools (common/template): list themes and parse their browser data, available through new getThemesData method 2020-05-01 16:26:39 +02:00
Goffi
794b5be810 tools (common/utils): new recursive_update method for dicts 2020-04-29 13:53:00 +02:00
Goffi
a5aac84c6a tools (common/data_objects): added __iter__ to Identities 2020-04-25 15:54:26 +02:00
Goffi
5b217e1b40 tools (common/data_objects): new avatar_basename property 2020-04-19 22:52:15 +02:00
Goffi
47ec15cc46 core: image convertion + SVG support:
/!\ new optional dependency: CairoSVG (with installed `[SVG]` extra)

- new `convert` method in `tools.image` to save an image in an other format, with support
  for SVG (when CairoSVG is available)
- new `imageConvert` method is available for frontends
2020-04-19 16:53:44 +02:00
Goffi
7fb86a0af4 tools (image): added a guess_type method to guess media type:
media type is guessed first from filename, then if it's not enough, the file is opened to
try to guess type. If it still can be determined, None is returned.
2020-04-14 20:29:37 +02:00
Goffi
ef90f2d3f7 tools (common/files_utils): put extra suffix before file extension 2020-04-01 22:29:43 +02:00
Goffi
067fcbe235 core (tools/utils): fixed return value for non async callbacks 2020-03-30 19:59:14 +02:00
Goffi
56d6613c4d tools (xl_tools): fixed handling of list options labels 2020-03-27 09:50:42 +01:00
Goffi
8a0aba8511 tools (images): methods renaming 2020-03-22 12:52:43 +01:00
Goffi
31e9cc7cbf core (tools/utils): new asDeferred function:
asDeferred is similar to defer.maybeCoroutine, and also handles coroutine.
2020-03-13 17:46:27 +01:00
Goffi
1883dbd3ab plugin download, aesgcm: disable TLS check if check_certificate setting is disabled 2020-03-06 18:19:03 +01:00
Goffi
8777bd07cb tools (images): max_size can now be manually specified in checkImage and dest in resizeImage:
`context` has been removed as it is not used and doesn't seem that useful.
2020-03-01 18:47:05 +01:00
Goffi
c5915d1dcb plugin attach, XEP-0363: progress id can now be specified:
progress id can be specified in options, using the "progress_id" option, this can be
more handy for frontends to keep track of attachments progresses.
2020-02-23 17:48:26 +01:00
Goffi
6a7d247754 core: use serialised dict for extra in messageNew and historyGet 2020-02-18 18:13:17 +01:00
Goffi
bc3abd6920 tools (common/async_process): fixed stderr handling + added global "run" 2020-02-09 23:56:40 +01:00
Goffi
5fae77187a tools (images): fixed type for recommended_size. 2020-02-05 23:59:19 +01:00
Goffi
ec5a51bebb core: log filenames of read config files 2020-01-29 19:42:02 +01:00
Goffi
e1a44cf4e4 fixed shebangs 2020-01-29 10:07:00 +01:00
Goffi
a39349fe64 dates update 2020-01-29 09:50:54 +01:00
Goffi
5ffa208962 tools (common/files_utils): fixed get_unique_name when path is a str and not a Path 2020-01-27 19:53:31 +01:00
Goffi
174f7bec4c tools (common/files_utils): get_unique_name now uses and returns Path instances. 2019-12-20 12:28:04 +01:00
Goffi
edbee4d719 plugin upload, XEP-0363: code modernisation + preparation for extension:
- use of async/await syntax
- fileUpload's options are now serialised, allowing non string values
- (XEP-0363) Slot is now a dataclass, so it can be modified by other plugins
- (XEP-0363) Moved SSL related code to the new tools.web module
- (XEP-0363) added `XEP-0363_upload_size` and `XEP-0363_upload` trigger points
- a Deferred is not used anymore for `progress_id`, the value is directly returned
2019-12-20 12:28:04 +01:00
Goffi
689e43f6d2 tools (stream): data modification on SatFile:
- if `data_cb` is used and if it returns a not None value, it is used instead of the data
  read from the file. This allows data modification on the fly, useful notably for
  encryption
- new `check_size_with_read` argument which check size on `close()` using amount of data
  actually read/written instead of file size. This avoid a warning when file is modified
  on the fly
- added `closed` attribute
2019-12-20 12:28:04 +01:00
Goffi
93a4e488ea core: added imageCheck and imageResize methods:
imageCheck will give a report on image, notably it will tell if it's too big and needs to
be resized before a transfer.

imageResize will create a new image with the requested size and return a path to it.
2019-10-29 20:38:39 +01:00
Goffi
48b13f0aeb core (tools/utils): fixed hex conversion in getRepositoryData following Python 3 port 2019-10-21 23:52:25 +02:00
Goffi
ed73fd8bf8 tools (common/template): removed warning catches, jinja2>=2.10.3 now handles them correctly 2019-10-18 17:51:44 +02:00
Goffi
f7aad247c2 misc: don't import memory in launch script:
launch script was importing a method from memory (fixLocalDir), but memory is importing
twisted.internet.reactor which can result to a ReactorAlreadyInstalledError.

This patch fixes it by moving fixLocalDir to tools/config.

The launch script is now using /usr/bin/env.
2019-10-08 12:10:26 +02:00
Goffi
d4bf063788 tools (common): helping method to calculate luminance:
- a new `utils` module has been added for backend and frontends generic utilities
- per_luminance method calculate the perceived luminance of a colour (is it dark or
  light?). This is useful to automatically select the suitable colour in a theme.
2019-10-01 22:49:10 +02:00
Goffi
76aadbb3fb jp: jp asyncio port:
/!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\

This patch implements the port of jp to asyncio, so it is now correctly using the bridge
asynchronously, and it can be used with bridges like `pb`. This also simplify the code,
notably for things which were previously implemented with many callbacks (like pagination
with RSM).

During the process, some behaviours have been modified/fixed, in jp and backends, check
diff for details.
2019-09-25 08:56:41 +02:00
Goffi
e87c07b200 common (template): suppress jinja2 depreaction warning (to be removed once 2.10.1 is released) 2019-09-25 08:41:36 +02:00
Goffi
a2ce271498 tools (common/email): fixed email sending after python 3 port 2019-08-16 17:06:52 +02:00
Goffi
4b2d53b797 tools (async_process): log command as str 2019-08-16 17:06:51 +02:00
Goffi
b039dc4572 tools (config), memory: renamed SafeConfigParser following Python 3 port 2019-08-16 17:06:43 +02:00
Goffi
fbfe96c505 Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time

This patch port backend, bridge and frontends to Python 3.

Roughly this has been done this way:

- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
  to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
2019-08-13 19:08:41 +02:00
Goffi
e85c55f7a0 core (config): if flatpak is detected, config is also looked after in /app 2019-06-23 17:40:19 +02:00
Goffi
0f97a75f6f tools (xml_tools): added "read_only" argument in dataFormResult2XMLUI (and use it in plugin pubsub_schema) 2019-06-12 09:11:28 +02:00
Goffi
d117d5c98c tools (email): moved email code to common so it can be used by frontends 2019-05-26 22:20:33 +02:00
Goffi
0edb94b0a2 tools (common/template): fixed theme parsing when there is no "/" in parenthesis 2019-05-25 15:13:35 +02:00
Goffi
94f149bce6 tools (email): fixed bad default value while reading config 2019-05-14 20:16:45 +02:00
Goffi
2f30424c6f tools (common/data_objects): added a "deserialise" argument to BlogItem:
BlogItem is doing deserialisation itself, which is not clean (it should be done at bridge level), and which is causing trouble in jp which doesn't expect serialisation.

As a workaround, the "deserialise" argument has been added for now (default to True), until deserialisation is properly managed in bridge.
2019-05-05 18:50:30 +02:00
Goffi
7d8d9c8ccb tools (xml_tools): split new lines for multi-lines text in XMLUIResult2DataFormResult to be correctly handled in data form 2019-05-03 20:48:19 +02:00
Goffi
1ccb54e571 tools (sat_defer), plugin XEP-0060: added a function "stanza2NotFound" to convert item-not-found StanzaError to exceptions.NotFound in an errback 2019-04-14 08:21:51 +02:00
Goffi
bc061ee885 template (filters): set locale when using "date_fmt" 2019-04-14 08:21:51 +02:00
Goffi
e1ff10bf77 template (i18n): activate ext.i18n.trimmed policy, to have clean translation strings. Set minimal jinja2 version to 2.10 2019-04-14 08:21:51 +02:00