Commit graph libervia-backend/sat/tools
Author SHA1 Message Date
Goffi
6ebc7da1f1 tools(utils): fixed error catching when getting repository data with pkg_resources 2020-11-16 14:44:43 +01:00
Goffi
2d3d30d42b tools (async_trigger): use utils.asDeferred for async triggers:
A corouting or blocking method can now be used for async triggers.
2020-11-12 14:53:15 +01:00
Goffi
1aeeffd399 tools (xml_tools): domish.Element pretty formatting functions:
- `pFmtElt`: pretty format a `domish.Element`
- `ppElt`: use the above function to pretty print a `domish.Element`
2020-11-12 14:53:15 +01:00
Goffi
54494409d2 tools (xml_tools): added with_parent and with_children argument to elementCopy 2020-11-12 14:53:15 +01:00
Goffi
1167c12c6f tools(xml_tools): fixed <div> unwrapping + added parse instance:
`<div>` unwrapping could fail when a text node was a sibling of the top element (could
easily happen ith a `\n` line feed added by an editor). This is fixed by filtering on
IElement with `elements()`.

A `parse` instance has been added as it is not necessary to create a new `ElementParser`
each time that we want to parse something.
2020-11-12 14:53:15 +01:00
Goffi
a692ba8e2e tools (common/tls): removed unused import 2020-10-19 09:28:26 +02:00
Goffi
03cffe789c core: minor typos, docstring/comments update 2020-09-20 14:05:40 +02:00
Goffi
644277a659 tools: new video module:
this module is really basic at the moment, and use `ffmpeg` if present to make thumbnails.
2020-08-25 08:54:13 +02:00
Goffi
8854f96aec tools (image): fix_orientation on resize + fix_orientation method:
a new argument (`True` by default) fix orientation (i.e. rotate according to EXIF data) of
image when resizing it.

A new `fix_orientation` method (unused for now) let do it independently
2020-08-13 23:46:18 +02:00
Goffi
820fa05d49 tools (common/template): use to_json instead of json + added missing args to date_fmt 2020-07-16 09:07:26 +02:00
Goffi
9aa7b1b7f2 tools (common/data_objects): removed deprecated code:
`BlogItem`, `BlogItems` and `parsePubSubMetadata` are not needed anymore with the new blog
data serialisation.
2020-07-16 09:07:26 +02:00
Goffi
282d2a93d9 tools (common/data_objects): implemented json dumping for BlogItems/BlogItem 2020-06-19 15:47:16 +02:00
Goffi
4b0d91cb2e common (template): better json dumping:
default method is set for json dumping (the `tojson` filter), if the object has a `json`
attribute, it will be called, otherwise it is replaced by None, this avoids crash when
rendering the template.
2020-06-19 15:45:57 +02:00
Goffi
9ba6df5503 tools (common/utils): new OrderedSet class 2020-06-08 08:54:53 +02:00
Goffi
7000fcda34 tools (common/dynamic_import): log a warning if bridge can't be imported 2020-06-01 11:14:20 +02:00
Goffi
d09be4ba42 tools/common (tls): moved re-usable Twisted TLS code from Libervia to tools/common 2020-05-29 21:07:10 +02:00
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