mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Compare commits
No commits in common. "dev" and "debian/3.3.0" have entirely different histories.
dev
...
debian/3.3
125 changed files with 3915 additions and 6272 deletions
35
.github/workflows/autoblack.yml
vendored
35
.github/workflows/autoblack.yml
vendored
|
@ -1,35 +0,0 @@
|
|||
name: Check / auto apply Black
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
jobs:
|
||||
black:
|
||||
name: Check / auto apply black
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check files using the black formatter
|
||||
uses: psf/black@stable
|
||||
id: black
|
||||
with:
|
||||
options: "."
|
||||
continue-on-error: true
|
||||
- shell: pwsh
|
||||
id: check_files_changed
|
||||
run: |
|
||||
# Diff HEAD with the previous commit
|
||||
$diff = git diff
|
||||
$HasDiff = $diff.Length -gt 0
|
||||
Write-Host "::set-output name=files_changed::$HasDiff"
|
||||
- name: Create Pull Request
|
||||
if: steps.check_files_changed.outputs.files_changed == 'true'
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
title: "Format Python code with Black"
|
||||
commit-message: ":art: Format Python code with Black"
|
||||
body: |
|
||||
This pull request uses the [psf/black](https://github.com/psf/black) formatter.
|
||||
base: ${{ github.head_ref }} # Creates pull request onto pull request or commit branch
|
||||
branch: actions/black
|
29
.github/workflows/i18n.yml
vendored
29
.github/workflows/i18n.yml
vendored
|
@ -1,29 +0,0 @@
|
|||
name: Autoreformat locale files
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
jobs:
|
||||
i18n:
|
||||
name: Autoreformat locale files
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Apply reformating scripts
|
||||
id: action_reformat
|
||||
run: |
|
||||
python3 test/remove_stale_i18n_strings.py
|
||||
python3 test/autofix_locale_format.py
|
||||
python3 test/reformat_locales.py
|
||||
git diff -w --exit-code
|
||||
- name: Create Pull Request
|
||||
if: ${{ failure() }}
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
title: "Reformat locale files"
|
||||
commit-message: ":robot: Reformat locale files"
|
||||
body: |
|
||||
Automatic pull request using the scripts in `test/`
|
||||
base: ${{ github.head_ref }}
|
||||
branch: actions/i18nreformat
|
49
.github/workflows/tox.yml
vendored
49
.github/workflows/tox.yml
vendored
|
@ -1,49 +0,0 @@
|
|||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- bullseye
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.9]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install apt dependencies
|
||||
run: sudo apt install ldap-utils slapd libsasl2-dev libldap2-dev libssl-dev
|
||||
- name: Install tox
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install tox tox-gh-actions
|
||||
- name: Test with tox
|
||||
run: tox -e py39-pytest
|
||||
|
||||
invalidcode:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.9]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install tox
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install tox tox-gh-actions
|
||||
- name: Linter
|
||||
run: tox -e py39-invalidcode
|
||||
- name: Mypy
|
||||
run: tox -e py39-mypy
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,8 +1,5 @@
|
|||
*.py[co]
|
||||
|
||||
# Documentation
|
||||
doc/_build/
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
|
|
5
.travis.yml
Normal file
5
.travis.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
language: python
|
||||
install: "pip install pep8"
|
||||
python:
|
||||
- "2.7"
|
||||
script: "pep8 --ignore E501,E128,E731 moulinette"
|
67
README.md
67
README.md
|
@ -1,18 +1,12 @@
|
|||
<h1 align="center">Moulinette</h1>
|
||||
Moulinette
|
||||
==========
|
||||
|
||||
<div align="center">
|
||||
The *moulinette* is a Python package that allows to quickly and easily
|
||||
prototype interfaces for your application.
|
||||
|
||||

|
||||
[](https://github.com/YunoHost/moulinette/actions/workflows/tox.yml)
|
||||
[](https://lgtm.com/projects/g/YunoHost/moulinette/context:python)
|
||||
[](https://github.com/YunoHost/moulinette/blob/dev/LICENSE)
|
||||
|
||||
|
||||
Moulinette is a small Python framework meant to easily create programs with unified CLI and API.
|
||||
|
||||
In particular, it is used as a base framework for the YunoHost project.
|
||||
|
||||
</div>
|
||||
<a href="https://translate.yunohost.org/engage/yunohost/?utm_source=widget">
|
||||
<img src="https://translate.yunohost.org/widgets/yunohost/-/287x66-white.png" alt="Translation status" />
|
||||
</a>
|
||||
|
||||
Issues
|
||||
------
|
||||
|
@ -22,25 +16,42 @@ Issues
|
|||
Overview
|
||||
--------
|
||||
|
||||
Moulinette allows to create a YAML "actionmaps" that describes what commands are available. Moulinette will automatically make these commands available through the CLI and Web API, and will be mapped to a python function. Moulinette also provide some general helpers, for example for logging, i18n, authentication, or common file system operations.
|
||||
Initially, the moulinette was an application made for the
|
||||
[YunoHost](https://yunohost.org/) project in order to regroup all its
|
||||
related operations into a single program called *moulinette*. Those
|
||||
operations were available from a command-line interface and a Web server
|
||||
providing an API. Moreover, the usage of these operations (e.g.
|
||||
required/optional arguments) was defined into a simple yaml file -
|
||||
called *actionsmap*. This file was parsed in order to construct an
|
||||
*ArgumentParser* object and to parse the command arguments to process
|
||||
the proper operation.
|
||||
|
||||
<div align="center"><img src="doc/actionsmap.png" width="700" /></div>
|
||||
During a long refactoring with the goal of unify both interfaces, the
|
||||
idea to separate the core of the YunoHost operations has emerged.
|
||||
The core kept the same name *moulinette* and try to follow the same
|
||||
initial principle. An [Actions Map](#actions-map) - which defines
|
||||
available operations and their usage - is parsed and it's used to
|
||||
process an operation from several unified [Interfaces](#interfaces). It
|
||||
also supports a configuration mechanism - which allows to restrict an
|
||||
operation on an interface for example (see
|
||||
[Authenticators](#authenticators)).
|
||||
|
||||
Translation
|
||||
-----------
|
||||
|
||||
You can help translate Moulinette on our [translation platform](https://translate.yunohost.org/engage/yunohost/?utm_source=widget)
|
||||
### Actions Map
|
||||
...
|
||||
|
||||
<div align="center"><img src="https://translate.yunohost.org/widgets/yunohost/-/moulinette/horizontal-auto.svg" alt="Translation status" /></div>
|
||||
### Interfaces
|
||||
...
|
||||
|
||||
Developpers
|
||||
-----------
|
||||
### Authenticators
|
||||
...
|
||||
|
||||
- You can learn how to get started with developing on YunoHost by reading [this piece of documentation](https://yunohost.org/dev).
|
||||
- Specific doc for moulinette: https://moulinette.readthedocs.org
|
||||
- Run tests with:
|
||||
|
||||
```
|
||||
$ pip install tox
|
||||
$ tox
|
||||
```
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* Python 2.7
|
||||
* python-bottle (>= 0.10)
|
||||
* python-gnupg (>= 0.3)
|
||||
* python-ldap (>= 2.4)
|
||||
* PyYAML
|
||||
|
|
60
data/actionsmap/test.yml
Normal file
60
data/actionsmap/test.yml
Normal file
|
@ -0,0 +1,60 @@
|
|||
|
||||
#############################
|
||||
# Global parameters #
|
||||
#############################
|
||||
_global:
|
||||
configuration:
|
||||
authenticate:
|
||||
- api
|
||||
authenticator:
|
||||
default:
|
||||
vendor: ldap
|
||||
help: Admin Password
|
||||
parameters:
|
||||
uri: ldap://localhost:389
|
||||
base_dn: dc=yunohost,dc=org
|
||||
user_rdn: cn=admin
|
||||
ldap-anonymous:
|
||||
vendor: ldap
|
||||
parameters:
|
||||
uri: ldap://localhost:389
|
||||
base_dn: dc=yunohost,dc=org
|
||||
test-profile:
|
||||
vendor: ldap
|
||||
help: Admin Password (profile)
|
||||
parameters:
|
||||
uri: ldap://localhost:389
|
||||
base_dn: dc=yunohost,dc=org
|
||||
user_rdn: cn=admin
|
||||
argument_auth: true
|
||||
lock: false
|
||||
|
||||
#############################
|
||||
# Test Actions #
|
||||
#############################
|
||||
test:
|
||||
actions:
|
||||
non-auth:
|
||||
api: GET /test/non-auth
|
||||
configuration:
|
||||
authenticate: false
|
||||
auth:
|
||||
api: GET /test/auth
|
||||
configuration:
|
||||
authenticate: all
|
||||
auth-profile:
|
||||
api: GET /test/auth-profile
|
||||
configuration:
|
||||
authenticate: all
|
||||
authenticator: test-profile
|
||||
auth-cli:
|
||||
api: GET /test/auth-cli
|
||||
configuration:
|
||||
authenticate:
|
||||
- cli
|
||||
anonymous:
|
||||
api: GET /test/anon
|
||||
configuration:
|
||||
authenticate: all
|
||||
authenticator: ldap-anonymous
|
||||
argument_auth: false
|
33
data/moulinette_cli
Normal file
33
data/moulinette_cli
Normal file
|
@ -0,0 +1,33 @@
|
|||
# yunohost(1) completion
|
||||
|
||||
_yunohost_cli()
|
||||
{
|
||||
local argc cur prev opts
|
||||
COMPREPLY=()
|
||||
|
||||
argc=${COMP_CWORD}
|
||||
cur="${COMP_WORDS[argc]}"
|
||||
prev="${COMP_WORDS[argc-1]}"
|
||||
opts=$(yunohost -h | sed -n "/usage/,/}/p" | awk -F"{" '{print $2}' | awk -F"}" '{print $1}' | tr ',' ' ')
|
||||
|
||||
if [[ $argc = 1 ]];
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "$opts --help" -- $cur ) )
|
||||
fi
|
||||
|
||||
if [[ "$prev" != "--help" ]];
|
||||
then
|
||||
if [[ $argc = 2 ]];
|
||||
then
|
||||
opts2=$(yunohost $prev -h | sed -n "/usage/,/}/p" | awk -F"{" '{print $2}' | awk -F"}" '{print $1}' | tr ',' ' ')
|
||||
COMPREPLY=( $(compgen -W "$opts2 --help" -- $cur ) )
|
||||
elif [[ $argc = 3 ]];
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "--help" $cur ) )
|
||||
fi
|
||||
else
|
||||
COMPREPLY=()
|
||||
fi
|
||||
|
||||
}
|
||||
complete -F _yunohost_cli yunohost
|
539
debian/changelog
vendored
539
debian/changelog
vendored
|
@ -1,534 +1,3 @@
|
|||
moulinette (11.2.1) stable; urgency=low
|
||||
|
||||
- repo chores: various black enhancements
|
||||
- [i18n] Translations updated for Arabic, Basque, Catalan, Chinese (Simplified), Czech, Dutch, English, Esperanto, French, Galician, German, Hindi, Indonesian, Italian, Japanese, Nepali, Norwegian Bokmål, Persian, Polish, Portuguese, Russian, Spanish, Swedish, Turkish, Ukrainian
|
||||
|
||||
Thanks to all contributors <3 ! (Alexandre Aubin, Francescc, José M, Metin Bektas, ppr, Psycojoker, rosbeef andino, Tagada, xabirequejo, xaloc33)
|
||||
|
||||
-- OniriCorpe <oniricorpe@yunohost.org> Sun, 19 May 2024 23:49:00 +0200
|
||||
|
||||
moulinette (11.2) stable; urgency=low
|
||||
|
||||
- [i18n] Translations updated for Japanese
|
||||
|
||||
Thanks to all contributors <3 ! (motcha)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 17 Jul 2023 16:32:34 +0200
|
||||
|
||||
moulinette (11.1.5) stable; urgency=low
|
||||
|
||||
- setup.py: fix version specifier in python_requires, python tooling not happy with * i guess (2373a7fa)
|
||||
- auth: prevent stupid issue where outdated cookie usage would trigger error 500 intead of 401, resulting in a ~bug after Yunohost self-upgrade and the webadmin is confused about the API not being up again (c06e1a91)
|
||||
- i18n: Translations updated for Chinese (Simplified), Indonesian, Japanese
|
||||
|
||||
Thanks to all contributors <3 ! (liimee, motcha, Neko Nekowazarashi, Poesty Li)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 10 Jul 2023 21:32:20 +0200
|
||||
|
||||
moulinette (11.1.4) stable; urgency=low
|
||||
|
||||
- Releasing as stable
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 01 Feb 2023 20:28:56 +0100
|
||||
|
||||
moulinette (11.1.2.1) testing; urgency=low
|
||||
|
||||
- Handle calling 'yunohost' with no args more gracefully (4c03e16d)
|
||||
- [i18n] Translations updated for Arabic
|
||||
|
||||
Thanks to all contributors <3 ! (ButterflyOfFire)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 30 Jan 2023 16:34:23 +0100
|
||||
|
||||
moulinette (11.1.2) testing; urgency=low
|
||||
|
||||
- legacy: Remove the 'global argument' mechanism ... we only use it for --version and it's just batshit overly complicated for what this achieves... (50b19a95, 80873777, 7f4e8b39)
|
||||
- Dont take lock for read/GET operations ([#327](https://github.com/yunohost/moulinette/pull/327))
|
||||
- [i18n] Translations updated for Arabic, Basque, Dutch
|
||||
|
||||
Thanks to all contributors <3 ! (André Koot, ButterflyOfFire, xabirequejo)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Fri, 06 Jan 2023 00:37:23 +0100
|
||||
|
||||
moulinette (11.1.0) testing; urgency=low
|
||||
|
||||
- Bump version for testing release
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 26 Oct 2022 16:15:37 +0200
|
||||
|
||||
moulinette (11.0.9) stable; urgency=low
|
||||
|
||||
- Bump version for stable release
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Sun, 07 Aug 2022 23:30:35 +0200
|
||||
|
||||
moulinette (11.0.8) testing; urgency=low
|
||||
|
||||
- [fix] random_ascii helper was generating inconsistent string length (4239f466)
|
||||
- [i18n] Translations updated for German, Polish, Slovak
|
||||
|
||||
Thanks to all contributors <3 ! (Gregor, Jose Riha, Radek Raczkowski)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Sun, 07 Aug 2022 11:55:06 +0200
|
||||
|
||||
moulinette (11.0.7) testing; urgency=low
|
||||
|
||||
- [i18n] Translations updated for Spanish
|
||||
|
||||
Thanks to all contributors <3 ! (JimScope, Alexandre Aubin)
|
||||
|
||||
-- tituspijean <titus+yunohost@pijean.ovh> Wed, 18 May 2022 00:02:25 +0200
|
||||
|
||||
moulinette (11.0.6) testing; urgency=low
|
||||
|
||||
- [enh] cli: Add possibility to hide commands in --help (cb9ecb46)
|
||||
- [i18n] Translations updated for Finnish, Galician
|
||||
|
||||
Thanks to all contributors <3 ! (Alexandre Aubin, alexAubin, José M, Mico Hauataluoma, Weblate)
|
||||
|
||||
-- Kay0u <pierre@kayou.io> Tue, 29 Mar 2022 14:23:40 +0200
|
||||
|
||||
moulinette (11.0.2) testing; urgency=low
|
||||
|
||||
- [fix] Various tweaks for Python 3.9
|
||||
- [fix] cli: Adapt prompt_toolkit call because now using the v3.x of the lib (d901d28a, 12218bcb, c44e0252)
|
||||
- [mod] refactor: Rework actionsmap and m18n init, drop multiple actionsmap support (9fcc9630)
|
||||
- [mod] api: Move cookie session management logic to the authenticator for more flexibility ([#311](https://github.com/YunoHost/moulinette/pull/311))
|
||||
|
||||
Thanks to all contributors <3 ! (Kay0u)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 19 Jan 2022 21:15:58 +0100
|
||||
|
||||
moulinette (4.4.0) testing; urgency=low
|
||||
|
||||
- Bump version for 4.4 release
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 19 Jan 2022 21:10:44 +0100
|
||||
|
||||
moulinette (4.3.3.1) stable; urgency=low
|
||||
|
||||
- [i18n] Translations updated for Dutch, Finnish, German
|
||||
|
||||
Thanks to all contributors <3 ! (Boudewijn, Gregor, Kay0u, Mico Hauataluoma)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 19 Jan 2022 21:10:44 +0100
|
||||
|
||||
moulinette (4.3.3) stable; urgency=low
|
||||
|
||||
- [enh] quality: Apply pyupgrade ([#312](https://github.com/YunoHost/moulinette/pull/312))
|
||||
- [i18n] Translations updated for Czech, German, Portuguese
|
||||
|
||||
Thanks to all contributors <3 ! (Bram, Christian Wehrli, maique madeira, Radek S, Valentin von Guttenberg)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 29 Dec 2021 01:08:10 +0100
|
||||
|
||||
moulinette (4.3.2.2) stable; urgency=low
|
||||
|
||||
Aaaaaand typoed 'testing' instead of 'stable' in previous changelog
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 15 Nov 2021 18:44:09 +0100
|
||||
|
||||
moulinette (4.3.2.1) testing; urgency=low
|
||||
|
||||
- [fix] api: 'Missing credentials parameter' bug : request.POST is buggy when value contains special chars ... request.params appears to be more reliable (c5f577c0)
|
||||
- [fix] api: issue with accented chars in form .. decode() is not needed anymore? (c5700f1b)
|
||||
- [i18n] Translations updated for Chinese (Simplified), Italian
|
||||
|
||||
Thanks to all contributors <3 ! (dagangtie, Flavio Cristoforetti)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 15 Nov 2021 18:44:09 +0100
|
||||
|
||||
moulinette (4.3.2) stable; urgency=low
|
||||
|
||||
- Bump version for stable release
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Fri, 05 Nov 2021 02:35:56 +0100
|
||||
|
||||
moulinette (4.3.1.2) testing; urgency=low
|
||||
|
||||
- [i18n] Translations updated for Basque, Occitan, Russian, Spanish
|
||||
|
||||
Thanks to all contributors <3 ! (Page Asgardius, punkrockgirl, Quentí, Semen Turchikhin)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 03 Nov 2021 18:42:44 +0100
|
||||
|
||||
moulinette (4.3.1.1) testing; urgency=low
|
||||
|
||||
- [enh] Add cp helper (14e37366)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 04 Oct 2021 01:24:34 +0200
|
||||
|
||||
moulinette (4.3.1) testing; urgency=low
|
||||
|
||||
- [mod] Rework cli prompt mecanisc ([#303](https://github.com/YunoHost/moulinette/pull/303))
|
||||
- [i18n] Translations updated for Indonesian, Russian, Turkish
|
||||
|
||||
Thanks to all contributors <3 ! (Éric Gaspar, liimee)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 29 Sep 2021 22:37:28 +0200
|
||||
|
||||
moulinette (4.3.0) testing; urgency=low
|
||||
|
||||
- [enh] Allow file type in actionmaps ([#258](https://github.com/YunoHost/moulinette/pull/258))
|
||||
- [refactor] Rework and externalize the authenticator system ([#270](https://github.com/YunoHost/moulinette/pull/270))
|
||||
- [security] Add httponly to API cookies (8562c05d)
|
||||
- [enh] Add prefill and multiline in prompt ([#290](https://github.com/YunoHost/moulinette/pull/290), 08f7866f)
|
||||
- [enh] Support bytes/stream in write_to_file (6e714314)
|
||||
- [fix] Various technical bugs in utils/process.py (fdc61c91, 4eb60dac, 3741101d)
|
||||
- [i18n] Translations updated for French, Galician, Persian, Ukrainian
|
||||
|
||||
Thanks to all contributors <3 ! (Éric Gaspar, José M, Kay0u, ljf, Parviz Homayun, ppr, Tymofii-Lytvynenko)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Sun, 19 Sep 2021 21:19:43 +0200
|
||||
|
||||
moulinette (4.2.4) stable; urgency=low
|
||||
|
||||
- [fix] Avoid warning and use safeloader ([#281](https://github.com/YunoHost/moulinette/pull/281))
|
||||
- [fix] Add warning when trying to feed non-string values to Popen env (2a89a82)
|
||||
- [i18n] Translations updated for Esperanto, French, German, Portuguese
|
||||
|
||||
Thanks to all contributors <3 ! (amirale qt, Christian Wehrli, Éric Gaspar, ljf, mifegui)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Thu, 19 Aug 2021 19:25:30 +0200
|
||||
|
||||
moulinette (4.2.3.3) stable; urgency=low
|
||||
|
||||
- [fix] Damn array args bug (2c9ec9f6)
|
||||
|
||||
Thanks to all contributors <3 ! (ljf)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Thu, 03 Jun 2021 18:40:18 +0200
|
||||
|
||||
moulinette (4.2.3.2) stable; urgency=low
|
||||
|
||||
- [fix] wait 1s for message in call_async_output, prevent CPU overload ([#275](https://github.com/YunoHost/moulinette/pull/275))
|
||||
- [i18n] Translations updated for Chinese (Simplified)
|
||||
|
||||
Thanks to all contributors <3 ! (Kayou, yahoo~~)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 02 Jun 2021 20:23:31 +0200
|
||||
|
||||
moulinette (4.2.3.1) stable; urgency=low
|
||||
|
||||
- [fix] Request params not decoded ([#277](https://github.com/YunoHost/moulinette/pull/277))
|
||||
|
||||
Thanks to all contributors <3 ! (ljf)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Tue, 25 May 2021 18:59:01 +0200
|
||||
|
||||
moulinette (4.2.3) stable; urgency=low
|
||||
|
||||
- [fix] Unicode password doesn't log in ([#276](https://github.com/YunoHost/moulinette/pull/276))
|
||||
- [i18n] Translations updated for Chinese (Simplified), Galician
|
||||
|
||||
Thanks to all contributors <3 ! (José M, ljf, yahoo~~)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 24 May 2021 17:34:19 +0200
|
||||
|
||||
moulinette (4.2.2) stable; urgency=low
|
||||
|
||||
- [i18n] Translations updated for French, Hungarian
|
||||
- Release as stable
|
||||
|
||||
Thanks to all contributors <3 ! (Dominik Blahó, Éric Gaspar)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Sat, 08 May 2021 15:10:01 +0200
|
||||
|
||||
moulinette (4.2.1) testing; urgency=low
|
||||
|
||||
- Fix weird technical thing in actionmap sucategories loading, related to recent changes in Yunohost actionmap (135fae95)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Sat, 17 Apr 2021 04:58:10 +0200
|
||||
|
||||
moulinette (4.2.0) testing; urgency=low
|
||||
|
||||
- [mod] Python2 -> python3 ([#228](https://github.com/YunoHost/moulinette/pull/228), 8e70561f, 570e5323, 3758b811, 90f894b5, [#269](https://github.com/YunoHost/moulinette/pull/269), e85b9f71, cafe68f3)
|
||||
- [mod] Code formatting, test fixing, cleanup (677efcf6, 0de15467, [#268](https://github.com/YunoHost/moulinette/pull/268), affb54f8, f7199f7a, d6f82c91)
|
||||
- [enh] Improve error semantic such that the webadmin shall be able to redirect to the proper log view ([#257](https://github.com/YunoHost/moulinette/pull/257), [#271](https://github.com/YunoHost/moulinette/pull/271))
|
||||
- [fix] Simpler and more consistent logging initialization ([#263](https://github.com/YunoHost/moulinette/pull/263))
|
||||
|
||||
Thanks to all contributors <3 ! (Kay0u, Laurent Peuch)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Fri, 19 Mar 2021 18:39:42 +0100
|
||||
|
||||
moulinette (4.1.4) stable; urgency=low
|
||||
|
||||
- [enh] Remove useless warning
|
||||
- Stable release
|
||||
|
||||
Thanks to all contributors <3 ! (Aleks)
|
||||
|
||||
-- Kayou <pierre@kayou.io> Thu, 14 Jan 2021 21:49:37 +0100
|
||||
|
||||
moulinette (4.1.3) stable; urgency=low
|
||||
|
||||
- Stable release
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Fri, 08 Jan 2021 03:15:05 +0100
|
||||
|
||||
moulinette (4.1.2) testing; urgency=low
|
||||
|
||||
- [mod] Misc code cleanup ([#259](https://github.com/YunoHost/moulinette/pull/259), 82bc0e82, 8566eaaa, 2caf1234)
|
||||
- [mod] Improve error messages ([#264](https://github.com/YunoHost/moulinette/pull/264))
|
||||
- [fix] Minor issue about 'comment' in actionmaps ([#266](https://github.com/YunoHost/moulinette/pull/266))
|
||||
- [i18n] Improve translation for French
|
||||
|
||||
Thanks to all contributors <3 ! (Kay0u, Bram, ppr)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Thu, 07 Jan 2021 00:23:44 +0100
|
||||
|
||||
moulinette (4.1.1) testing; urgency=low
|
||||
|
||||
- [enh] Add options to write_to_json ([#261](https://github.com/YunoHost/moulinette/pull/261))
|
||||
- [fix] Fix tests ([#262](https://github.com/YunoHost/moulinette/pull/262))
|
||||
|
||||
Thanks to all contributors <3 ! (Kay0u)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Sat, 19 Dec 2020 01:52:06 +0100
|
||||
|
||||
moulinette (4.1.0.1) testing; urgency=low
|
||||
|
||||
- Tmp bump version number for CI / tests
|
||||
|
||||
moulinette (4.1.0) testing; urgency=low
|
||||
|
||||
- [enh] Simplify interface initialization (Moulinette#245)
|
||||
- [enh] Be able to return a raw HTTP response (Moulinette#255)
|
||||
- [fix] Incorrect locale in some situations (Moulinette/d9fa6c7)
|
||||
- [fix] Prevent installing moulinette 4.1 without Yunohost 4.1 (Moulinette/9609fe1)
|
||||
- [fix] Error messages are not displayed in some situations (Moulinette/2501ecd)
|
||||
- Update translations for French, Spanish, Italian, Portuguese, Czech (Moulinette#256)
|
||||
|
||||
Thanks to all contributors <3 ! (ppr, KaeruCT, Omnia89, roukydesbois, miloskroulik, Aleks, Kay0u, miloskroulik)
|
||||
|
||||
-- Kay0u <pierre@kayou.io> Thu, 03 Dec 2020 16:32:44 +0100
|
||||
|
||||
moulinette (4.0.3) stable; urgency=low
|
||||
|
||||
- Bump version number for stable release
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 29 Jul 2020 17:00:00 +0200
|
||||
|
||||
moulinette (4.0.2~beta) testing; urgency=low
|
||||
|
||||
- Bump version number for beta release
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Fri, 19 Jun 2020 15:33:29 +0200
|
||||
|
||||
moulinette (4.0.1~alpha) testing; urgency=low
|
||||
|
||||
- [fix] Get rid of legacy code which breaks postinstall on buster for some reason (ac83b10f)
|
||||
- [fix] Remove legacy Breaks and Replaces (e49a47c7)
|
||||
- [fix] Let's hash the password like we do in core during tests (0c78374e)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Fri, 05 Jun 2020 17:32:35 +0200
|
||||
|
||||
moulinette (3.8.1.3) stable; urgency=low
|
||||
|
||||
- Update authorship/maintainer information (7818f07)
|
||||
- [i18n] Translations updated for Arabic, Catalan, French, Italian
|
||||
|
||||
Thanks to all contributors <3 ! (ButterflyOfFire, É. Gaspar, L. Noferini, ppr, xaloc33)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 27 Jul 2020 17:15:36 +0200
|
||||
|
||||
moulinette (3.8.1.2) stable; urgency=low
|
||||
|
||||
- [fix] locale parsing in some edge case
|
||||
- [i18n] Translations updated for Chinese (Simplified), Catalan, French, Nepali, Occitan
|
||||
|
||||
Thanks to all contributors ! (Aleks, amirale qt, clecle226, Quentí, xaloc33)
|
||||
|
||||
-- Kay0u <pierre@kayou.io> Fri, 22 May 2020 07:58:19 +0000
|
||||
|
||||
moulinette (3.8.1.1) stable; urgency=low
|
||||
|
||||
Bumping version number for stable release
|
||||
|
||||
-- Kay0u <pierre@kayou.io> Wed, 20 May 2020 18:56:36 +0000
|
||||
|
||||
moulinette (3.8.1) testing; urgency=low
|
||||
|
||||
- [fix] Misc technical ux/debugging fixes (#242, #243, #244, 840f27d2)
|
||||
- [fix] try to autorestart ldap when the server is down (#247)
|
||||
- [i18n] Translations updated for Dutch, Esperanto, French, German, Nepali, Polish
|
||||
|
||||
Thanks to all contributors <3 ! (amirale qt, Bram, É. Gaspar, Kay0u, M. Döring, Zeik0s)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Sat, 09 May 2020 21:09:35 +0200
|
||||
|
||||
moulinette (3.8.0) testing; urgency=low
|
||||
|
||||
# Major stuff
|
||||
|
||||
- Simplify auth mechanism (#216)
|
||||
- Add more tests (#230)
|
||||
- Use Black in Moulinette (#220, 6f5daa0, 54b8cab)
|
||||
|
||||
# Minor technical stuff
|
||||
|
||||
- [fix] Don't display comment if argument is already set (#226)
|
||||
- Don't miserably crash if async running can't read incoming message (06d8c48)
|
||||
- Report the actual error when ldap fails (628ffc9)
|
||||
|
||||
# i18n
|
||||
|
||||
- Improve translations for Swedish, Dutch, Italian, Russian, Polish, Portuguese, Catalan, Spanish, Occitan, Nepali, Esperanto, Basque, Chinese (Simplified), Arabic, German, Hungarian, Greek, Turkish, Bengali (Bangladesh)
|
||||
|
||||
Thanks to all contributors ! (Aleks, Bram, ButterflyOfFire, Filip B., Jeroen F., Josué T., Kay0u, Quentí, Yifei D., amirale qt, decentral1se, Elie G., frju365, Romain R., xaloc33)
|
||||
|
||||
-- Kay0u <pierre@kayou.io> Thu, 09 Apr 2020 20:29:48 +0000
|
||||
|
||||
moulinette (3.7.1.1) stable; urgency=low
|
||||
|
||||
- [fix] Report actual errors when some LDAP operation fails to ease
|
||||
debugging
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Fri, 17 Apr 2020 17:00:00 +0000
|
||||
|
||||
moulinette (3.7.1) stable; urgency=low
|
||||
|
||||
- [enh] Lazy loading pytz for performances
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Thu, 9 Apr 2020 14:55:00 +0000
|
||||
|
||||
moulinette (3.7.0.2) stable; urgency=low
|
||||
|
||||
Bumping version number for stable release
|
||||
|
||||
-- Kay0u <pierre@kayou.io> Thu, 26 Mar 2020 22:03:23 +0000
|
||||
|
||||
moulinette (3.7.0.1) testing; urgency=low
|
||||
|
||||
- [fix] Slapd may crash if we try to update the LDAP with no change (moulinette#231)
|
||||
|
||||
Thanks to all contributors (Josué) <3 !
|
||||
|
||||
-- Kay0u <pierre@kayou.io> Sun, 15 Mar 2020 16:09:25 +0000
|
||||
|
||||
moulinette (3.7.0) testing; urgency=low
|
||||
|
||||
# ~ Major stuff
|
||||
|
||||
- [enh] Add group and permission mechanism (#189)
|
||||
- [mod] Be able to customize prompt colors (808f620)
|
||||
- [enh] Support app manifests in toml (#204, 55515cb)
|
||||
- [enh] Quite a lot of messages improvements, string cleaning, language rework... (599bec3, #208, #213, b7d415d, a8966b8, fdf9a71, d895ae3, bdf0a1c)
|
||||
- [i18n] Improved translations for Catalan, Occitan, French, Arabic, Spanish, German, Norwegian Bokmål
|
||||
|
||||
# Smaller or pretty technical fix/enh
|
||||
|
||||
- [enh] Preparations for moulinette Python3 migration (Tox, Pytest and unit tests) (#203, #206, #207, #210, #211 #212, 2403ee1, 69b0d49, 49c749c, 2c84ee1, cef72f7)
|
||||
- [enh] Add a write_to_yaml utility similar to write_to_json (2e2e627)
|
||||
- [enh] Warn the user about long locks (#205)
|
||||
- [mod] Tweak stuff about setuptools and moulinette deps? (b739f27, da00fc9, d8cbbb0)
|
||||
- [fix] Misc micro bugfixes or improvements (83d9e77)
|
||||
- [doc] Fix doc building + add doc build tests with Tox (f1ac5b8, df7d478, 74c8f79, bcf92c7, af2c80c, d52a574, 307f660, dced104, ed3823b)
|
||||
- [enh] READMEs improvements (1541b74, ad1eeef)
|
||||
|
||||
Thanks to all contributors <3 ! (accross all repo: Yunohost, Moulinette, SSOwat, Yunohost-admin) : advocatux, Aksel K., Aleks, Allan N., amirale qt, Armin P., Bram, ButterflyOfFire, Carles S. A., chema o. r., decentral1se, Emmanuel V., Etienne M., Filip B., Geoff M., htsr, Jibec, Josué, Julien J., Kayou, liberodark, ljf, lucaskev, Lukas D., madtibo, Martin D., Mélanie C., nr 458 h, pitfd, ppr, Quentí, sidddy, troll, tufek yamero, xaloc33, yalh76
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Thu, 31 Oct 2019 18:40:00 +0000
|
||||
|
||||
moulinette (3.6.4.1) stable; urgency=low
|
||||
|
||||
- [fix] Catch all exceptions in read_yaml helper
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 06 Aug 2019 18:40:00 +0000
|
||||
|
||||
moulinette (3.6.4) stable; urgency=low
|
||||
|
||||
Bumping version number for stable release
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Tue, 04 Jul 2019 23:30:00 +0000
|
||||
|
||||
moulinette (3.6.1) testing; urgency=low
|
||||
|
||||
- [enh] Add LDIF parsing utility (#201)
|
||||
|
||||
Thanks to all contributors <3 ! (Josué)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Tue, 04 Jun 2019 13:20:00 +0000
|
||||
|
||||
moulinette (3.6.0) testing; urgency=low
|
||||
|
||||
- [enh] Allow to use SASL authentication for LDAP (by root user) (#183)
|
||||
- [i18n] Improve translation for Spanish
|
||||
|
||||
Thanks to all contributors (Josue, advocatux) <3 !
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 22 May 2019 19:45:00 +0000
|
||||
|
||||
moulinette (3.5.2) stable; urgency=low
|
||||
|
||||
- Release as stable !
|
||||
- [fix] Do not miserably crash if the lock does not exist when attempting to release it
|
||||
- [i18n] Update translation for Arabic, Italian
|
||||
|
||||
Thanks to all contributors (Aleks, BoF, silkevicious) <3 !
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 10 Apr 2019 02:14:00 +0000
|
||||
|
||||
moulinette (3.5.1) testing; urgency=low
|
||||
|
||||
* [fix] Fix case where stdinfo is not provided in call_async_output (0a300e5)
|
||||
* [i18n] Improve translation for Greek, Hungarian, Polish, Swedish, French, Catalan, Occitan
|
||||
|
||||
Thanks to all contributors (Aleks, ariasuni, Quentí, ppr, Xaloc) <3 !
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 03 Apr 2019 02:25:00 +0000
|
||||
|
||||
moulinette (3.5.0) testing; urgency=low
|
||||
|
||||
* [i18n] Improve Russian and Chinese (Mandarin) translations
|
||||
|
||||
Contributors : n3uz, Алексей
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Wed, 13 Mar 2019 17:20:00 +0000
|
||||
|
||||
moulinette (3.4.2) stable; urgency=low
|
||||
|
||||
* [i18n] Improve Basque translation
|
||||
|
||||
Thanks to all contributors (A. Garaialde) <3 !
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Tue, 29 Jan 2019 16:50:00 +0000
|
||||
|
||||
moulinette (3.4.1) testing; urgency=low
|
||||
|
||||
* [i18n] Improve Chinese(Mandarin) translation
|
||||
* [i18n] Misc orthotypograhy
|
||||
|
||||
Thanks to all contributors (Jibec, aleiyer) <3 !
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Thu, 17 Jan 2019 21:50:00 +0000
|
||||
|
||||
moulinette (3.4.0) testing; urgency=low
|
||||
|
||||
* [fix] Code cleaning with autopep8 (#187)
|
||||
* [fix] Automatically reconnect LDAP authenticator when slapd restarts (#185)
|
||||
* [enh] Display date as system timezone (#184)
|
||||
* [mod] Make sure `gpg.encrypt` actually does something (#182)
|
||||
* [mod] Add possiblity to get attribute name of conflict in LDAP (#181)
|
||||
* [enh] Simplify moulinette error management (#180)
|
||||
* [mod] Remove Access-Control-Allow-Origin (#174)
|
||||
* [enh] Protect against CSRF (#171)
|
||||
* [i18n] Improve Spanish translation
|
||||
|
||||
Thanks to all contributors (Aleks, randomstuff, irina11y, Josue, gdayon, ljf) <3 !
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Thu, 20 Dec 2018 21:53:00 +0000
|
||||
|
||||
moulinette (3.3.1) stable; urgency=low
|
||||
|
||||
* [fix] 'force' semantics in 'utils.filesystem.mkdir' (#177)
|
||||
* [mod] Adjust coding style and tidy up unused imports (#178)
|
||||
* [i18n] Improve French translation
|
||||
|
||||
Thanks to all contributors (airwoodix, Jibec) <3 !
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Fri, 23 Nov 2018 15:00:00 +0000
|
||||
|
||||
moulinette (3.3.0) testing; urgency=low
|
||||
|
||||
* [fix] Remove unappropriate 'whoami' ldap warning (#173)
|
||||
|
@ -595,7 +64,7 @@ moulinette (2.7.13) testing; urgency=low
|
|||
* [i18n] Improve translations for Portugueuse, Occitan
|
||||
* [enh] Add read_yaml util (#161)
|
||||
|
||||
Contributors : Bram, by0ne, Quentí
|
||||
Contributors : Bram, by0ne, Quent-in
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 28 May 2018 02:55:00 +0000
|
||||
|
||||
|
@ -613,7 +82,7 @@ moulinette (2.7.11) testing; urgency=low
|
|||
* [fix] Avoid cases where get_cookie returns None
|
||||
* [mod] Improve exception logging in ldap stuff
|
||||
|
||||
Thanks to all contributors (pitchum, Bram, ButteflyOfFire, J. Keerl, Matthieu, Jibec, David B, Quentí, bjarkan) <3 !
|
||||
Thanks to all contributors (pitchum, Bram, ButteflyOfFire, J. Keerl, Matthieu, Jibec, David B, Quenti, bjarkan) <3 !
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Tue, 01 May 2018 23:33:59 +0000
|
||||
|
||||
|
@ -685,7 +154,7 @@ moulinette (2.7.0) testing; urgency=low
|
|||
* [enh] Show description of command in --help (#148)
|
||||
* [i18n] Update French translation (#149)
|
||||
|
||||
Thanks to all contributors (Bram, Aleks, R. Cabaret) ! <3
|
||||
Thanks to all contributors (Bram, Aleks, R. Cabaret) ! <3
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 07 Aug 2017 13:04:21 -0400
|
||||
|
||||
|
@ -703,7 +172,7 @@ moulinette (2.6.0) testing; urgency=low
|
|||
* [fix] Show positional arguments first in --help / usage (#138)
|
||||
* Update translations for Portuguese, German, Dutch
|
||||
|
||||
Thanks to all contributors and translators ! (Trollken, frju, Fabien Gruber, Jeroen Keerl, Aleks)
|
||||
Thanks to all contributors and translators ! (Trollken, frju, Fabien Gruber, Jeroen Keerl, Aleks)
|
||||
|
||||
-- Alexandre Aubin <alex.aubin@mailoo.org> Mon, 24 Apr 2017 12:44:23 -0400
|
||||
|
||||
|
|
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
9
|
34
debian/control
vendored
34
debian/control
vendored
|
@ -1,26 +1,28 @@
|
|||
Source: moulinette
|
||||
Section: python
|
||||
Priority: optional
|
||||
Maintainer: YunoHost Contributors <contrib@yunohost.org>
|
||||
Build-Depends: debhelper (>= 9), debhelper-compat (= 13), python3 (>= 3.7), dh-python, python3-setuptools, python3-psutil, python3-all (>= 3.7)
|
||||
Maintainer: Jérôme Lebleu <jerome.lebleu@mailoo.org>
|
||||
Build-Depends: debhelper (>= 9), python (>= 2.7), dh-python, python-psutil, python-all (>= 2.7)
|
||||
Standards-Version: 3.9.6
|
||||
X-Python-Version: >= 2.7
|
||||
Homepage: https://github.com/YunoHost/moulinette
|
||||
|
||||
Package: moulinette
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, ${python3:Depends},
|
||||
python3-yaml,
|
||||
python3-bottle (>= 0.12),
|
||||
python3-gevent-websocket,
|
||||
python3-toml,
|
||||
python3-psutil,
|
||||
python3-tz,
|
||||
python3-prompt-toolkit,
|
||||
python3-pygments
|
||||
Breaks: yunohost (<< 4.1)
|
||||
Depends: ${misc:Depends}, ${python:Depends},
|
||||
python-ldap,
|
||||
python-yaml,
|
||||
python-bottle (>= 0.12),
|
||||
python-gnupg,
|
||||
python-gevent-websocket,
|
||||
python-argcomplete,
|
||||
python-psutil
|
||||
Replaces: yunohost-cli
|
||||
Breaks: yunohost-cli
|
||||
Description: prototype interfaces with ease in Python
|
||||
Quickly and easily prototype interfaces for your application.
|
||||
Each action can be served through an HTTP API and from the
|
||||
command-line with a single method.
|
||||
The moulinette is a Python package that allows one to quickly and
|
||||
easily prototype interfaces for your application. Each action can
|
||||
be served through an HTTP API and from the command-line with a single
|
||||
method.
|
||||
.
|
||||
Originally designed and written for the YunoHost project.
|
||||
It was originally written for the YunoHost project.
|
||||
|
|
4
debian/rules
vendored
4
debian/rules
vendored
|
@ -1,6 +1,4 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
export PYBUILD_NAME=moulinette
|
||||
|
||||
%:
|
||||
dh $@ --with python3 --buildsystem=pybuild
|
||||
dh $@ --with python2 --buildsystem=python_distutils
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 48 KiB |
Binary file not shown.
Before Width: | Height: | Size: 77 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 166 KiB |
Binary file not shown.
Before Width: | Height: | Size: 133 KiB |
0
doc/_static/.git-dont-delete-me
vendored
0
doc/_static/.git-dont-delete-me
vendored
|
@ -2,8 +2,6 @@
|
|||
Role and syntax of the actionsmap
|
||||
=================================
|
||||
|
||||
.. _actionsmap:
|
||||
|
||||
Principle
|
||||
=========
|
||||
|
||||
|
|
80
doc/conf.py
80
doc/conf.py
|
@ -18,21 +18,18 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
sys.path.insert(0, os.path.abspath('..'))
|
||||
|
||||
|
||||
import sys
|
||||
from mock import Mock as MagicMock
|
||||
|
||||
|
||||
class Mock(MagicMock):
|
||||
@classmethod
|
||||
def __getattr__(cls, name):
|
||||
return MagicMock()
|
||||
|
||||
|
||||
MOCK_MODULES = ["ldap", "ldap.modlist", "ldap.sasl"]
|
||||
MOCK_MODULES = ['ldap', 'ldap.modlist']
|
||||
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
|
||||
|
||||
|
||||
|
@ -45,38 +42,36 @@ sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
|
|||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.intersphinx",
|
||||
"sphinx.ext.todo",
|
||||
"sphinx.ext.viewcode",
|
||||
]
|
||||
extensions = ['sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.viewcode']
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ["_templates"]
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = ".rst"
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = "index"
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = "Moulinette"
|
||||
copyright = "2017, YunoHost Collective"
|
||||
author = "YunoHost Collective"
|
||||
project = u'Moulinette'
|
||||
copyright = u'2017, YunoHost Collective'
|
||||
author = u'YunoHost Collective'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = "2.6.1"
|
||||
version = u'2.6.1'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = "2.6.1"
|
||||
release = u'2.6.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@ -88,10 +83,10 @@ language = None
|
|||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This patterns also effect to html_static_path and html_extra_path
|
||||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
||||
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = "sphinx"
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
|
@ -102,7 +97,7 @@ todo_include_todos = True
|
|||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = "classic"
|
||||
html_theme = 'classic'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
|
@ -113,7 +108,7 @@ html_theme = "classic"
|
|||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ["_static"]
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
|
@ -121,11 +116,11 @@ html_static_path = ["_static"]
|
|||
# This is required for the alabaster theme
|
||||
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
|
||||
html_sidebars = {
|
||||
"**": [
|
||||
'**': [
|
||||
# 'about.html',
|
||||
# 'navigation.html',
|
||||
# 'relations.html', # needs 'show_related': True theme option to display
|
||||
"searchbox.html",
|
||||
'searchbox.html',
|
||||
# 'donate.html',
|
||||
]
|
||||
}
|
||||
|
@ -134,7 +129,7 @@ html_sidebars = {
|
|||
# -- Options for HTMLHelp output ------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = "Moulinettedoc"
|
||||
htmlhelp_basename = 'Moulinettedoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
@ -143,12 +138,15 @@ latex_elements = {
|
|||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
|
@ -158,13 +156,8 @@ latex_elements = {
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(
|
||||
master_doc,
|
||||
"Moulinette.tex",
|
||||
"Moulinette Documentation",
|
||||
"YunoHost Collective",
|
||||
"manual",
|
||||
),
|
||||
(master_doc, 'Moulinette.tex', u'Moulinette Documentation',
|
||||
u'YunoHost Collective', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
|
@ -172,7 +165,10 @@ latex_documents = [
|
|||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [(master_doc, "moulinette", "Moulinette Documentation", [author], 1)]
|
||||
man_pages = [
|
||||
(master_doc, 'moulinette', u'Moulinette Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
@ -181,17 +177,13 @@ man_pages = [(master_doc, "moulinette", "Moulinette Documentation", [author], 1)
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(
|
||||
master_doc,
|
||||
"Moulinette",
|
||||
"Moulinette Documentation",
|
||||
author,
|
||||
"Moulinette",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
(master_doc, 'Moulinette', u'Moulinette Documentation',
|
||||
author, 'Moulinette', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {"https://docs.python.org/": None}
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
|
|
|
@ -22,6 +22,7 @@ a reference.
|
|||
utils/filesystem
|
||||
utils/network
|
||||
utils/process
|
||||
utils/stream
|
||||
utils/text
|
||||
|
||||
Indices and tables
|
||||
|
|
228
doc/ldap.rst
228
doc/ldap.rst
|
@ -122,7 +122,7 @@ Here is the method docstring:
|
|||
Users LDAP schema
|
||||
-----------------
|
||||
|
||||
According to :file:`ldapvi` this is the user schema (on YunoHost >3.7):
|
||||
According to :file:`ldapvi` this is the user schema (on YunoHost 2.7):
|
||||
|
||||
::
|
||||
|
||||
|
@ -131,7 +131,6 @@ According to :file:`ldapvi` this is the user schema (on YunoHost >3.7):
|
|||
objectClass: mailAccount
|
||||
objectClass: inetOrgPerson
|
||||
objectClass: posixAccount
|
||||
objectClass: userPermissionYnh
|
||||
loginShell: /bin/false
|
||||
uidNumber: 80833
|
||||
maildrop: the_unix_username # why?
|
||||
|
@ -148,11 +147,6 @@ According to :file:`ldapvi` this is the user schema (on YunoHost >3.7):
|
|||
mail: webmaster@domain.com
|
||||
mail: postmaster@domain.com
|
||||
givenName: first_name
|
||||
memberOf: cn=the_unix_username,ou=groups,dc=yunohost,dc=org
|
||||
memberOf: cn=all_users,ou=groups,dc=yunohost,dc=org
|
||||
permission: cn=main.mail,ou=permission,dc=yunohost,dc=org
|
||||
permission: cn=main.metronome,ou=permission,dc=yunohost,dc=org
|
||||
|
||||
|
||||
The admin user is a special case that looks like this:
|
||||
|
||||
|
@ -182,6 +176,15 @@ Other user related schemas:
|
|||
gidNumber: 4001
|
||||
cn: admins
|
||||
|
||||
# path: cn=sftpusers,ou=groups,dc=yunohost,dc=org
|
||||
objectClass: posixGroup
|
||||
objectClass: top
|
||||
gidNumber: 4002
|
||||
cn: sftpusers
|
||||
memberUid: admin
|
||||
memberUid: alice
|
||||
# and all other users
|
||||
|
||||
# path: cn=admin,ou=sudo,dc=yunohost,dc=org
|
||||
# this entry seems to specify which unix user is a sudoer
|
||||
cn: admin
|
||||
|
@ -217,95 +220,9 @@ Apparently we could also access one user using the following path (and not query
|
|||
|
||||
If you want specific attributes look at the general documentation on how to read from LDAP a bit above of this section.
|
||||
|
||||
|
||||
Group LDAP schema
|
||||
Users LDAP schema
|
||||
-----------------
|
||||
|
||||
According to :file:`ldapvi` this is the user schema (on YunoHost >3.4):
|
||||
|
||||
The groups will look like this:
|
||||
|
||||
::
|
||||
|
||||
dn: cn=the_unix_username,ou=groups,dc=yunohost,dc=org
|
||||
objectClass: top
|
||||
objectClass: groupOfNamesYnh
|
||||
objectClass: posixGroup
|
||||
gidNumber: 48335
|
||||
cn: the_unix_username
|
||||
structuralObjectClass: posixGroup
|
||||
member: uid=the_unix_username,ou=users,dc=yunohost,dc=org
|
||||
|
||||
By default you will find in all case a group named `all_users` which will contains all Yunohost users.
|
||||
|
||||
::
|
||||
|
||||
# path dn: cn=all_users,ou=groups,dc=yunohost,dc=org
|
||||
objectClass: posixGroup
|
||||
objectClass: groupOfNamesYnh
|
||||
gidNumber: 4002
|
||||
cn: all_users
|
||||
structuralObjectClass: posixGroup
|
||||
permission: cn=main.mail,ou=permission,dc=yunohost,dc=org
|
||||
permission: cn=main.metronome,ou=permission,dc=yunohost,dc=org
|
||||
member: uid=the_unix_username,ou=users,dc=yunohost,dc=org
|
||||
memberUid: the_unix_username
|
||||
|
||||
Reading group from LDAP
|
||||
-----------------------
|
||||
|
||||
The group schema is located at this path: :file:`ou=groups,dc=yunohost,dc=org`
|
||||
|
||||
The queries we uses are the 2 following python calls:
|
||||
|
||||
::
|
||||
|
||||
# all groups
|
||||
auth.search('ou=groups,dc=yunohost,dc=org', '(objectclass=groupOfNamesYnh)')
|
||||
|
||||
# one groups
|
||||
auth.search(base='ou=groups,dc=yunohost,dc=org', filter='cn=' + groupname)
|
||||
|
||||
|
||||
Permission LDAP schema
|
||||
----------------------
|
||||
|
||||
According to :file:`ldapvi` this is the user schema (on YunoHost >3.4):
|
||||
|
||||
The permission will look like this:
|
||||
|
||||
::
|
||||
|
||||
dn: cn=main.mail,ou=permission,dc=yunohost,dc=org
|
||||
objectClass: posixGroup
|
||||
objectClass: permissionYnh
|
||||
gidNumber: 5001
|
||||
groupPermission: cn=all_users,ou=groups,dc=yunohost,dc=org
|
||||
cn: main.mail
|
||||
structuralObjectClass: posixGroup
|
||||
memberUid: the_unix_username
|
||||
inheritPermission: uid=the_unix_username,ou=users,dc=yunohost,dc=org
|
||||
|
||||
By default you will have a permission for the mail and for metronome. When you install an application a permission also created.
|
||||
|
||||
Reading permissions from LDAP
|
||||
-----------------------------
|
||||
|
||||
The permission schema is located at this path: :file:`ou=permission,dc=yunohost,dc=org`
|
||||
|
||||
The queries we uses are the 2 following python calls:
|
||||
|
||||
::
|
||||
|
||||
# For all permission
|
||||
auth.search('ou=permission,dc=yunohost,dc=org', '(objectclass=permissionYnh)')
|
||||
|
||||
# For one permission
|
||||
auth.search(base='ou=permission,dc=yunohost,dc=org', filter='cn=' + permission_name)
|
||||
|
||||
Domain LDAP schema
|
||||
------------------
|
||||
|
||||
According to :file:`ldapvi` this is the domain schema (on YunoHost 2.7):
|
||||
|
||||
::
|
||||
|
@ -319,8 +236,6 @@ According to :file:`ldapvi` this is the domain schema (on YunoHost 2.7):
|
|||
Adding data in LDAP
|
||||
===================
|
||||
|
||||
If you add an object linked to user, group or permission you need run the function `permission_sync_to_user` to keep integrity of permission in LDAP.
|
||||
|
||||
Adding stuff in LDAP seems pretty simple, according to existing code it looks like this:
|
||||
|
||||
::
|
||||
|
@ -337,7 +252,7 @@ They weird stuff is the path you need to create. This looks like that for domain
|
|||
# user
|
||||
auth.add('uid=%s,ou=users' % username, attr_dict)
|
||||
|
||||
You need to respect the expected attributes. Refer to the schema for that.
|
||||
You need to respect the expected attributes. Refer to the schemas for that.
|
||||
|
||||
:file:`auth.add` seems to return something false when it failed (None probably)
|
||||
so you need to check it's return code.
|
||||
|
@ -385,8 +300,6 @@ Here is how it's done for a new domain:
|
|||
Updating LDAP data
|
||||
==================
|
||||
|
||||
If you add an object linked to user, group or permission you need run the function `permission_sync_to_user` to keep integrity of permission in LDAP.
|
||||
|
||||
Update a user from LDAP looks like a simplified version of searching. The syntax is the following one:
|
||||
|
||||
::
|
||||
|
@ -419,8 +332,8 @@ Refer to the user schema to know which attributes you can modify.
|
|||
Validate uniqueness
|
||||
===================
|
||||
|
||||
There is a method to validate the uniqueness of some entry that is used during
|
||||
user creation. It's useful by example to be sure that we have no conflict about email between each user.
|
||||
There is a method to validate the uniquess of some entry that is used during
|
||||
user creation. I haven't used it and I'm not sure on how it work.
|
||||
|
||||
Here is how it's used (I don't understand why a path is not provided):
|
||||
|
||||
|
@ -434,27 +347,11 @@ Here is how it's used (I don't understand why a path is not provided):
|
|||
|
||||
And here is its docstring:
|
||||
|
||||
.. automethod:: moulinette.authenticators.ldap.Authenticator.validate_uniqueness
|
||||
|
||||
Get conflict
|
||||
============
|
||||
|
||||
Like the last function `validate_uniqueness` but give instead of rising an error this function return which attribute with witch value generate a conflict.
|
||||
|
||||
::
|
||||
|
||||
# Validate uniqueness of groupname in LDAP
|
||||
conflict = auth.get_conflict({
|
||||
'cn': groupname
|
||||
}, base_dn='ou=groups,dc=yunohost,dc=org')
|
||||
if conflict:
|
||||
raise YunohostError('group_name_already_exist', name=groupname)
|
||||
.. automethod:: moulinette.authenticators.ldap.Authenticator.update
|
||||
|
||||
Remove entries from LDAP
|
||||
========================
|
||||
|
||||
If you add an object linked to user, group or permission you need run the function `permission_sync_to_user` to keep integrity of permission in LDAP.
|
||||
|
||||
Remove entries from LDAP is very simple, quite close to adding stuff except you don't need to specify the attributes dict, you just need to entrie path:
|
||||
|
||||
::
|
||||
|
@ -475,98 +372,3 @@ Here how it looks like for domain and user:
|
|||
(:file:`None` ?) so you need to check it returns code.
|
||||
|
||||
.. automethod:: moulinette.authenticators.ldap.Authenticator.remove
|
||||
|
||||
Reading LDIF file
|
||||
=================
|
||||
|
||||
Reading parsing a ldif to be able to insert in the LDAP database is really easy. Here is how to get the content of a LDIF file
|
||||
|
||||
::
|
||||
|
||||
from moulinette.utils.filesystem import read_ldif
|
||||
|
||||
my_reslut = read_ldif("your_file.ldif")
|
||||
|
||||
|
||||
Note that the main difference of what the auth object return with the search method is that this function return a 2-tuples with the "dn" and the LDAP entry.
|
||||
|
||||
=============================
|
||||
LDAP architecture in Yunohost
|
||||
=============================
|
||||
|
||||
In Yunohost to be able to manage the user and the permission we use 3 parts:
|
||||
|
||||
* User object
|
||||
* Permission object
|
||||
* Group object
|
||||
|
||||
We can see the interaction between these object as this following:
|
||||
|
||||
.. image:: Yunohost_LDAP_documentation/LDAP_Liaison_logique_entre_objets.png
|
||||
|
||||
As you can see there are link between these 3 objets:
|
||||
|
||||
* The first link is between the user and the group. It define which user is in which group. Note that all user has a group with his name. Note that in all Yunohost instance you have a group named `all_users`. In this group you will find all Yunohost users.
|
||||
* The second link is between the permission and the groups. This link is defined by the administrator. By default all permission are linked to the group `all_users`, so all user will be allowed to access to this permission.
|
||||
* The third link between the User and the Permission is more technical. It give the possibility to the application to get a list of all user allowed to access to. This link is dynamically generated by core. The function `permission_sync_to_user` in the module `permission` do this work.
|
||||
|
||||
The option `force` of the function `permission_sync_to_user` is used when you add the data to LDAP with `slapadd`. `slapadd` update the LDAP database without the LDAP demon process. The advantage of this is that you can bypass the integrity check (like the link between the object by the memberOf overlay). The disadvantage is that the the memberOf overlay wont update anything so if you don't fix the integrity after after to run `slapadd`, the permission in LDAP might be corrupted. Running the function permission_sync_to_user` with the option `force` will do this work to fix all integrity error.
|
||||
|
||||
To be able to have an attribute in both is of theses 3 link we use the `memberOf` overlay in LDAP. This following line define the configuration to have these 3 link dynamically updated :
|
||||
|
||||
::
|
||||
|
||||
# Link user <-> group
|
||||
#dn: olcOverlay={0}memberof,olcDatabase={1}mdb,cn=config
|
||||
overlay memberof
|
||||
memberof-group-oc groupOfNamesYnh
|
||||
memberof-member-ad member
|
||||
memberof-memberof-ad memberOf
|
||||
memberof-dangling error
|
||||
memberof-refint TRUE
|
||||
|
||||
# Link permission <-> groupes
|
||||
#dn: olcOverlay={1}memberof,olcDatabase={1}mdb,cn=config
|
||||
overlay memberof
|
||||
memberof-group-oc permissionYnh
|
||||
memberof-member-ad groupPermission
|
||||
memberof-memberof-ad permission
|
||||
memberof-dangling error
|
||||
memberof-refint TRUE
|
||||
|
||||
# Link permission <-> user
|
||||
#dn: olcOverlay={2}memberof,olcDatabase={1}mdb,cn=config
|
||||
overlay memberof
|
||||
memberof-group-oc permissionYnh
|
||||
memberof-member-ad inheritPermission
|
||||
memberof-memberof-ad permission
|
||||
memberof-dangling error
|
||||
memberof-refint TRUE
|
||||
|
||||
This foolwing example show how will be represented in LDAP as simple concept of permission.
|
||||
|
||||
.. image:: Yunohost_LDAP_documentation/LDAP_Representation_logique.png
|
||||
|
||||
This schema show what will be in LDAP in these following schema:
|
||||
|
||||
.. image:: Yunohost_LDAP_documentation/Schema_LDAP_1.png
|
||||
.. image:: Yunohost_LDAP_documentation/Schema_LDAP_2.png
|
||||
|
||||
=========================================
|
||||
LDAP integration in Yunohost applications
|
||||
=========================================
|
||||
|
||||
To have a complete integration of LDAP in your application you need to configure LDAP as follow :
|
||||
|
||||
::
|
||||
|
||||
Host: ldap://localhost
|
||||
Port: 389
|
||||
Base DN: dc=yunohost,dc=org
|
||||
User DN: ou=users,dc=yunohost,dc=org
|
||||
Group DN: ou=groups,dc=yunohost,dc=org
|
||||
fiter : (&(objectClass=posixAccount)(permission=cn=YOUR_APP.main,ou=permission,dc=yunohost,dc=org))
|
||||
LDAP Username: uid
|
||||
LDAP Email Address: mail
|
||||
|
||||
By this your application will get the list of all user allowed to access to your application.
|
||||
|
|
|
@ -84,24 +84,6 @@ strict digraph "<stdin>" {
|
|||
|
||||
|
||||
n2 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
dn: ou=users,dc=yunohost,dc=org
|
||||
</FONT></TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: organizationalUnit</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">ou: users</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n0->n2
|
||||
|
||||
|
||||
|
||||
n3 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -115,11 +97,11 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n0->n3
|
||||
n0->n2
|
||||
|
||||
|
||||
|
||||
n4 [label=<
|
||||
n3 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -133,11 +115,11 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n0->n4
|
||||
n0->n3
|
||||
|
||||
|
||||
|
||||
n5 [label=<
|
||||
n4 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -151,11 +133,11 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n0->n5
|
||||
n0->n4
|
||||
|
||||
|
||||
|
||||
n6 [label=<
|
||||
n5 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -169,71 +151,29 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n0->n6
|
||||
n0->n5
|
||||
|
||||
|
||||
|
||||
n7 [label=<
|
||||
n6 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
dn: ou=permission,dc=yunohost,dc=org
|
||||
dn: ou=users,dc=yunohost,dc=org
|
||||
</FONT></TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: organizationalUnit</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">ou: permission</FONT>
|
||||
<FONT FACE="Helvetica Bold">ou: users</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n0->n7
|
||||
n0->n6
|
||||
|
||||
|
||||
|
||||
n8 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
dn: cn=all_users,ou=groups,dc=yunohost,dc=org
|
||||
</FONT></TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: posixGroup</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: groupOfNamesYnh</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 4002</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">cn: all_users</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">permission: cn=main.mail,ou=permission,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">permission: cn=main.metronome,ou=permission,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">member: uid=alice,ou=users,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">member: uid=example_admin_user,ou=users,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: alice</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: example_admin_user</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n4->n8
|
||||
|
||||
|
||||
|
||||
n9 [label=<
|
||||
n7 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -253,11 +193,44 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n4->n9
|
||||
n3->n7
|
||||
|
||||
|
||||
|
||||
n10 [label=<
|
||||
n8 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
dn: cn=sftpusers,ou=groups,dc=yunohost,dc=org
|
||||
</FONT></TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: posixGroup</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 4002</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">cn: sftpusers</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: admin</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: neutrinet</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: alice</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: bob</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n3->n8
|
||||
|
||||
|
||||
|
||||
n9 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -283,89 +256,11 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n5->n10
|
||||
n4->n9
|
||||
|
||||
|
||||
|
||||
n11 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
dn: cn=main.mail,ou=permission,dc=yunohost,dc=org
|
||||
</FONT></TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: posixGroup</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: permissionYnh</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 5001</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">groupPermission: cn=all_users,ou=groups,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">cn: main.mail</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: alice</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: example_admin_user</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">inheritPermission: uid=alice,ou=users,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">inheritPermission: uid=example_admin_user,ou=users,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n7->n11
|
||||
|
||||
|
||||
|
||||
n12 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
dn: cn=main.metronome,ou=permission,dc=yunohost,dc=org
|
||||
</FONT></TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: posixGroup</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: permissionYnh</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 5002</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">groupPermission: cn=all_users,ou=groups,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">cn: main.metronome</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: alice</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">memberUid: example_admin_user</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">inheritPermission: uid=alice,ou=users,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">inheritPermission: uid=example_admin_user,ou=users,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n7->n12
|
||||
|
||||
|
||||
|
||||
n13 [label=<
|
||||
n10 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -379,11 +274,11 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n3->n13
|
||||
n2->n10
|
||||
|
||||
|
||||
|
||||
n14 [label=<
|
||||
n11 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -400,15 +295,12 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: posixAccount</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: userPermissionYnh</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">loginShell: /bin/false</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">uidNumber: 23431</FONT>
|
||||
<FONT FACE="Helvetica Bold">uidNumber: 80833</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">maildrop: example_admin_user</FONT>
|
||||
|
@ -423,7 +315,7 @@ strict digraph "<stdin>" {
|
|||
<FONT FACE="Helvetica Bold">mailuserquota: 0</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 23431</FONT>
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 80833</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">sn: lastname</FONT>
|
||||
|
@ -448,47 +340,14 @@ strict digraph "<stdin>" {
|
|||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">givenName: firstname</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">permission: cn=main.mail,ou=permission,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">permission: cn=main.metronome,ou=permission,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n2->n14
|
||||
n6->n11
|
||||
|
||||
|
||||
|
||||
n15 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
dn: cn=example_admin_user,ou=groups,dc=yunohost,dc=org
|
||||
</FONT></TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: groupOfNamesYnh</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: posixGroup</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 23431</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">cn: example_admin_user</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">member: uid=example_admin_user,ou=users,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n4->n15
|
||||
|
||||
|
||||
|
||||
n16 [label=<
|
||||
n12 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
|
@ -507,13 +366,7 @@ strict digraph "<stdin>" {
|
|||
<FONT FACE="Helvetica Bold">objectClass: posixAccount</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: userPermissionYnh</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">loginShell: /bin/false</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">uidNumber: 98803</FONT>
|
||||
<FONT FACE="Helvetica Bold">uidNumber: 41580</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">maildrop: alice</FONT>
|
||||
|
@ -528,7 +381,7 @@ strict digraph "<stdin>" {
|
|||
<FONT FACE="Helvetica Bold">mailuserquota: 0</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 98803</FONT>
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 41580</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">sn: pouet</FONT>
|
||||
|
@ -537,47 +390,17 @@ strict digraph "<stdin>" {
|
|||
<FONT FACE="Helvetica Bold">homeDirectory: /home/alice</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">mail: alice@domain.com</FONT>
|
||||
<FONT FACE="Helvetica Bold">mail: alice@ynh.local</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">givenName: alice</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">permission: cn=main.mail,ou=permission,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">permission: cn=main.metronome,ou=permission,dc=yunohost,dc=org</FONT>
|
||||
<FONT FACE="Helvetica Bold">loginShell: /bin/bash</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n2->n16
|
||||
|
||||
|
||||
|
||||
n17 [label=<
|
||||
<TABLE BGCOLOR="palegoldenrod" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR><TD CELLPADDING="4" ALIGN="CENTER" BGCOLOR="olivedrab4">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">
|
||||
dn: cn=alice,ou=groups,dc=yunohost,dc=org
|
||||
</FONT></TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: groupOfNamesYnh</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">objectClass: posixGroup</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">gidNumber: 98803</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">cn: alice</FONT>
|
||||
</TD></TR>
|
||||
<TR><TD BORDER="0" ALIGN="LEFT">
|
||||
<FONT FACE="Helvetica Bold">member: uid=alice,ou=users,dc=yunohost,dc=org</FONT>
|
||||
</TD></TR>
|
||||
</TABLE>
|
||||
>]
|
||||
n4->n17
|
||||
n6->n12
|
||||
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 292 KiB After Width: | Height: | Size: 178 KiB |
|
@ -27,12 +27,6 @@ description: LDAP Administrator
|
|||
uidNumber: 1007
|
||||
uid: admin
|
||||
|
||||
# users, yunohost.org
|
||||
dn: ou=users,dc=yunohost,dc=org
|
||||
objectClass: organizationalUnit
|
||||
objectClass: top
|
||||
ou: users
|
||||
|
||||
# domains, yunohost.org
|
||||
dn: ou=domains,dc=yunohost,dc=org
|
||||
objectClass: organizationalUnit
|
||||
|
@ -57,24 +51,11 @@ objectClass: organizationalUnit
|
|||
objectClass: top
|
||||
ou: apps
|
||||
|
||||
# permission, yunohost.org
|
||||
dn: ou=permission,dc=yunohost,dc=org
|
||||
# users, yunohost.org
|
||||
dn: ou=users,dc=yunohost,dc=org
|
||||
objectClass: organizationalUnit
|
||||
objectClass: top
|
||||
ou: permission
|
||||
|
||||
# all_users, groups, yunohost.org
|
||||
dn: cn=all_users,ou=groups,dc=yunohost,dc=org
|
||||
objectClass: posixGroup
|
||||
objectClass: groupOfNamesYnh
|
||||
gidNumber: 4002
|
||||
cn: all_users
|
||||
permission: cn=main.mail,ou=permission,dc=yunohost,dc=org
|
||||
permission: cn=main.metronome,ou=permission,dc=yunohost,dc=org
|
||||
member: uid=alice,ou=users,dc=yunohost,dc=org
|
||||
member: uid=example_admin_user,ou=users,dc=yunohost,dc=org
|
||||
memberUid: alice
|
||||
memberUid: example_admin_user
|
||||
ou: users
|
||||
|
||||
# admins, groups, yunohost.org
|
||||
dn: cn=admins,ou=groups,dc=yunohost,dc=org
|
||||
|
@ -84,6 +65,17 @@ memberUid: admin
|
|||
gidNumber: 4001
|
||||
cn: admins
|
||||
|
||||
# sftpusers, groups, yunohost.org
|
||||
dn: cn=sftpusers,ou=groups,dc=yunohost,dc=org
|
||||
objectClass: posixGroup
|
||||
objectClass: top
|
||||
gidNumber: 4002
|
||||
cn: sftpusers
|
||||
memberUid: admin
|
||||
memberUid: neutrinet
|
||||
memberUid: alice
|
||||
memberUid: bob
|
||||
|
||||
# admin, sudo, yunohost.org
|
||||
dn: cn=admin,ou=sudo,dc=yunohost,dc=org
|
||||
cn: admin
|
||||
|
@ -94,30 +86,6 @@ objectClass: top
|
|||
sudoOption: !authenticate
|
||||
sudoHost: ALL
|
||||
|
||||
# main.mail, permission, yunohost.org
|
||||
dn: cn=main.mail,ou=permission,dc=yunohost,dc=org
|
||||
objectClass: posixGroup
|
||||
objectClass: permissionYnh
|
||||
gidNumber: 5001
|
||||
groupPermission: cn=all_users,ou=groups,dc=yunohost,dc=org
|
||||
cn: main.mail
|
||||
memberUid: alice
|
||||
memberUid: example_admin_user
|
||||
inheritPermission: uid=alice,ou=users,dc=yunohost,dc=org
|
||||
inheritPermission: uid=example_admin_user,ou=users,dc=yunohost,dc=org
|
||||
|
||||
# main.metronome, permission, yunohost.org
|
||||
dn: cn=main.metronome,ou=permission,dc=yunohost,dc=org
|
||||
objectClass: posixGroup
|
||||
objectClass: permissionYnh
|
||||
gidNumber: 5002
|
||||
groupPermission: cn=all_users,ou=groups,dc=yunohost,dc=org
|
||||
cn: main.metronome
|
||||
memberUid: alice
|
||||
memberUid: example_admin_user
|
||||
inheritPermission: uid=alice,ou=users,dc=yunohost,dc=org
|
||||
inheritPermission: uid=example_admin_user,ou=users,dc=yunohost,dc=org
|
||||
|
||||
# domain.com, domains, yunohost.org
|
||||
dn: virtualdomain=domain.com,ou=domains,dc=yunohost,dc=org
|
||||
objectClass: mailDomain
|
||||
|
@ -130,14 +98,13 @@ uid: example_admin_user
|
|||
objectClass: mailAccount
|
||||
objectClass: inetOrgPerson
|
||||
objectClass: posixAccount
|
||||
objectClass: userPermissionYnh
|
||||
loginShell: /bin/false
|
||||
uidNumber: 23431
|
||||
uidNumber: 80833
|
||||
maildrop: example_admin_user
|
||||
cn: firstname lastname
|
||||
displayName: firstname lastname
|
||||
mailuserquota: 0
|
||||
gidNumber: 23431
|
||||
gidNumber: 80833
|
||||
sn: lastname
|
||||
homeDirectory: /home/example_admin_user
|
||||
mail: example_admin_user@domain.com
|
||||
|
@ -146,17 +113,6 @@ mail: admin@domain.com
|
|||
mail: webmaster@domain.com
|
||||
mail: postmaster@domain.com
|
||||
givenName: firstname
|
||||
permission: cn=main.mail,ou=permission,dc=yunohost,dc=org
|
||||
permission: cn=main.metronome,ou=permission,dc=yunohost,dc=org
|
||||
|
||||
# example_admin_user, groups, yunohost.org
|
||||
dn: cn=example_admin_user,ou=groups,dc=yunohost,dc=org
|
||||
objectClass: top
|
||||
objectClass: groupOfNamesYnh
|
||||
objectClass: posixGroup
|
||||
gidNumber: 23431
|
||||
cn: example_admin_user
|
||||
member: uid=example_admin_user,ou=users,dc=yunohost,dc=org
|
||||
|
||||
# alice, users, yunohost.org
|
||||
dn: uid=alice,ou=users,dc=yunohost,dc=org
|
||||
|
@ -164,33 +120,21 @@ uid: alice
|
|||
objectClass: mailAccount
|
||||
objectClass: inetOrgPerson
|
||||
objectClass: posixAccount
|
||||
objectClass: userPermissionYnh
|
||||
loginShell: /bin/false
|
||||
uidNumber: 98803
|
||||
uidNumber: 41580
|
||||
maildrop: alice
|
||||
cn: alice pouet
|
||||
displayName: alice pouet
|
||||
mailuserquota: 0
|
||||
gidNumber: 98803
|
||||
gidNumber: 41580
|
||||
sn: pouet
|
||||
homeDirectory: /home/alice
|
||||
mail: alice@domain.com
|
||||
mail: alice@ynh.local
|
||||
givenName: alice
|
||||
permission: cn=main.mail,ou=permission,dc=yunohost,dc=org
|
||||
permission: cn=main.metronome,ou=permission,dc=yunohost,dc=org
|
||||
|
||||
# alice, groups, yunohost.org
|
||||
dn: cn=alice,ou=groups,dc=yunohost,dc=org
|
||||
objectClass: top
|
||||
objectClass: groupOfNamesYnh
|
||||
objectClass: posixGroup
|
||||
gidNumber: 98803
|
||||
cn: alice
|
||||
member: uid=alice,ou=users,dc=yunohost,dc=org
|
||||
loginShell: /bin/bash
|
||||
|
||||
# search result
|
||||
search: 2
|
||||
result: 0 Success
|
||||
|
||||
# numResponses: 19
|
||||
# numEntries: 18
|
||||
# numResponses: 21
|
||||
# numEntries: 20
|
||||
|
|
|
@ -34,7 +34,7 @@ ldapsearch -x -b 'dc=nodomain' | \\
|
|||
import sys
|
||||
|
||||
|
||||
class Element:
|
||||
class Element(object):
|
||||
"""Represents an LDIF entry."""
|
||||
|
||||
def __init__(self):
|
||||
|
@ -43,7 +43,7 @@ class Element:
|
|||
|
||||
def __repr__(self):
|
||||
"""Returns a basic state dump."""
|
||||
return "Element" + str(self.index) + str(self.attributes)
|
||||
return 'Element' + str(self.index) + str(self.attributes)
|
||||
|
||||
def add(self, line):
|
||||
"""Adds a line of input to the object.
|
||||
|
@ -57,10 +57,10 @@ class Element:
|
|||
"""
|
||||
|
||||
def _valid(line):
|
||||
return line and not line.startswith("#")
|
||||
return line and not line.startswith('#')
|
||||
|
||||
def _interesting(line):
|
||||
return line != "objectClass: top"
|
||||
return line != 'objectClass: top'
|
||||
|
||||
if self.is_valid() and not _valid(line):
|
||||
return True
|
||||
|
@ -70,11 +70,11 @@ class Element:
|
|||
|
||||
def is_valid(self):
|
||||
"""Indicates whether a valid entry has been read."""
|
||||
return len(self.attributes) != 0 and self.attributes[0].startswith("dn: ")
|
||||
return len(self.attributes) != 0 and self.attributes[0].startswith('dn: ')
|
||||
|
||||
def dn(self):
|
||||
"""Returns the DN for this entry."""
|
||||
if self.attributes[0].startswith("dn: "):
|
||||
if self.attributes[0].startswith('dn: '):
|
||||
return self.attributes[0][4:]
|
||||
else:
|
||||
return None
|
||||
|
@ -86,12 +86,12 @@ class Element:
|
|||
Element objects) and returns a string which declares a DOT edge, or an
|
||||
empty string, if no parent was found.
|
||||
"""
|
||||
dn_components = self.dn().split(",")
|
||||
dn_components = self.dn().split(',')
|
||||
for i in range(1, len(dn_components) + 1):
|
||||
parent = ",".join(dn_components[i:])
|
||||
parent = ','.join(dn_components[i:])
|
||||
if parent in dnmap:
|
||||
return " n%d->n%d\n" % (dnmap[parent].index, self.index)
|
||||
return ""
|
||||
return ' n%d->n%d\n' % (dnmap[parent].index, self.index)
|
||||
return ''
|
||||
|
||||
def dot(self, dnmap):
|
||||
"""Returns a text representation of the node and perhaps its parent edge.
|
||||
|
@ -99,7 +99,6 @@ class Element:
|
|||
Args:
|
||||
- dnmap: dictionary mapping dn names to Element objects
|
||||
"""
|
||||
|
||||
def _format(attributes):
|
||||
result = [TITLE_ENTRY_TEMPALTE % attributes[0]]
|
||||
|
||||
|
@ -108,14 +107,9 @@ class Element:
|
|||
|
||||
return result
|
||||
|
||||
return TABLE_TEMPLATE % (
|
||||
self.index,
|
||||
"\n ".join(_format(self.attributes)),
|
||||
self.edge(dnmap),
|
||||
)
|
||||
return TABLE_TEMPLATE % (self.index, '\n '.join(_format(self.attributes)), self.edge(dnmap))
|
||||
|
||||
|
||||
class Converter:
|
||||
class Converter(object):
|
||||
"""An LDIF to DOT converter."""
|
||||
|
||||
def __init__(self):
|
||||
|
@ -150,11 +144,7 @@ class Converter:
|
|||
e = Element()
|
||||
if e.is_valid():
|
||||
self._append(e)
|
||||
return BASE_TEMPLATE % (
|
||||
name,
|
||||
"".join([e.dot(self.dnmap) for e in self.elements]),
|
||||
)
|
||||
|
||||
return (BASE_TEMPLATE % (name, ''.join([e.dot(self.dnmap) for e in self.elements])))
|
||||
|
||||
BASE_TEMPLATE = """\
|
||||
strict digraph "%s" {
|
||||
|
@ -201,13 +191,13 @@ ENTRY_TEMPALTE = """\
|
|||
"""
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 2:
|
||||
raise "Expected at most one argument."
|
||||
raise 'Expected at most one argument.'
|
||||
elif len(sys.argv) == 2:
|
||||
name = sys.argv[1]
|
||||
file = open(sys.argv[1], "r")
|
||||
file = open(sys.argv[1], 'r')
|
||||
else:
|
||||
name = "<stdin>"
|
||||
name = '<stdin>'
|
||||
file = sys.stdin
|
||||
print(Converter().parse(file, name))
|
||||
print Converter().parse(file, name)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
sphinx
|
||||
gnupg
|
||||
mock
|
||||
pyyaml
|
||||
toml
|
||||
|
|
|
@ -4,7 +4,6 @@ File system operation utils
|
|||
.. autofunction:: moulinette.utils.filesystem.read_file
|
||||
.. autofunction:: moulinette.utils.filesystem.read_json
|
||||
.. autofunction:: moulinette.utils.filesystem.read_yaml
|
||||
.. autofunction:: moulinette.utils.filesystem.read_toml
|
||||
.. autofunction:: moulinette.utils.filesystem.write_to_file
|
||||
.. autofunction:: moulinette.utils.filesystem.append_to_file
|
||||
.. autofunction:: moulinette.utils.filesystem.write_to_json
|
||||
|
|
|
@ -4,4 +4,3 @@ Process operation utils
|
|||
.. autofunction:: moulinette.utils.process.check_output
|
||||
.. autofunction:: moulinette.utils.process.call_async_output
|
||||
.. autofunction:: moulinette.utils.process.run_commands
|
||||
.. autofunction:: moulinette.utils.process.LogPipe
|
||||
|
|
5
doc/utils/stream.rst
Normal file
5
doc/utils/stream.rst
Normal file
|
@ -0,0 +1,5 @@
|
|||
Stream operation utils
|
||||
======================
|
||||
|
||||
.. autofunction:: moulinette.utils.stream.consume_queue
|
||||
.. autofunction:: moulinette.utils.stream.async_file_reading
|
181
generate_api_doc.py
Normal file
181
generate_api_doc.py
Normal file
|
@ -0,0 +1,181 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" License
|
||||
|
||||
Copyright (C) 2013 YunoHost
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program; if not, see http://www.gnu.org/licenses
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
Generate JSON specification files API
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
import json
|
||||
import requests
|
||||
from yunohost import str_to_func, __version__
|
||||
|
||||
def main():
|
||||
"""
|
||||
|
||||
"""
|
||||
with open('action_map.yml') as f:
|
||||
action_map = yaml.load(f)
|
||||
|
||||
try:
|
||||
with open('/etc/yunohost/current_host', 'r') as f:
|
||||
domain = f.readline().rstrip()
|
||||
except IOError:
|
||||
domain = requests.get('http://ip.yunohost.org').text
|
||||
|
||||
with open('action_map.yml') as f:
|
||||
action_map = yaml.load(f)
|
||||
|
||||
resource_list = {
|
||||
'apiVersion': __version__,
|
||||
'swaggerVersion': '1.1',
|
||||
'basePath': 'http://'+ domain + ':6767',
|
||||
'apis': []
|
||||
}
|
||||
|
||||
resources = {}
|
||||
|
||||
del action_map['general_arguments']
|
||||
for category, category_params in action_map.items():
|
||||
if 'category_help' not in category_params: category_params['category_help'] = ''
|
||||
resource_path = '/api/'+ category
|
||||
resource_list['apis'].append({
|
||||
'path': resource_path,
|
||||
'description': category_params['category_help']
|
||||
})
|
||||
resources[category] = {
|
||||
'apiVersion': __version__,
|
||||
'swaggerVersion': '1.1',
|
||||
'basePath': 'http://'+ domain + ':6767',
|
||||
'apis': []
|
||||
}
|
||||
|
||||
resources[category]['resourcePath'] = resource_path
|
||||
|
||||
registered_paths = {}
|
||||
|
||||
for action, action_params in category_params['actions'].items():
|
||||
if 'action_help' not in action_params:
|
||||
action_params['action_help'] = ''
|
||||
if 'api' not in action_params:
|
||||
action_params['api'] = 'GET /'+ category +'/'+ action
|
||||
|
||||
method, path = action_params['api'].split(' ')
|
||||
key_param = ''
|
||||
if '{' in path:
|
||||
key_param = path[path.find("{")+1:path.find("}")]
|
||||
|
||||
notes = ''
|
||||
if str_to_func('yunohost_'+ category +'.'+ category +'_'+ action) is None:
|
||||
notes = 'Not yet implemented'
|
||||
|
||||
operation = {
|
||||
'httpMethod': method,
|
||||
'nickname': category +'_'+ action,
|
||||
'summary': action_params['action_help'],
|
||||
'notes': notes,
|
||||
'errorResponses': []
|
||||
}
|
||||
|
||||
if 'arguments' in action_params:
|
||||
operation['parameters'] = []
|
||||
for arg_name, arg_params in action_params['arguments'].items():
|
||||
if 'help' not in arg_params:
|
||||
arg_params['help'] = ''
|
||||
param_type = 'query'
|
||||
allow_multiple = False
|
||||
required = True
|
||||
allowable_values = None
|
||||
name = arg_name.replace('-', '_')
|
||||
if name[0] == '_':
|
||||
required = False
|
||||
if 'full' in arg_params:
|
||||
name = arg_params['full'][2:]
|
||||
else:
|
||||
name = name[2:]
|
||||
name = name.replace('-', '_')
|
||||
|
||||
if 'nargs' in arg_params:
|
||||
if arg_params['nargs'] == '*':
|
||||
allow_multiple = True
|
||||
required = False
|
||||
if arg_params['nargs'] == '+':
|
||||
allow_multiple = True
|
||||
required = True
|
||||
else:
|
||||
allow_multiple = False
|
||||
if 'choices' in arg_params:
|
||||
allowable_values = {
|
||||
'valueType': 'LIST',
|
||||
'values': arg_params['choices']
|
||||
}
|
||||
if 'action' in arg_params and arg_params['action'] == 'store_true':
|
||||
allowable_values = {
|
||||
'valueType': 'LIST',
|
||||
'values': ['true', 'false']
|
||||
}
|
||||
|
||||
if name == key_param:
|
||||
param_type = 'path'
|
||||
required = True
|
||||
allow_multiple = False
|
||||
|
||||
parameters = {
|
||||
'paramType': param_type,
|
||||
'name': name,
|
||||
'description': arg_params['help'],
|
||||
'dataType': 'string',
|
||||
'required': required,
|
||||
'allowMultiple': allow_multiple
|
||||
}
|
||||
if allowable_values is not None:
|
||||
parameters['allowableValues'] = allowable_values
|
||||
|
||||
operation['parameters'].append(parameters)
|
||||
|
||||
|
||||
if path in registered_paths:
|
||||
resources[category]['apis'][registered_paths[path]]['operations'].append(operation)
|
||||
resources[category]['apis'][registered_paths[path]]['description'] = ''
|
||||
else:
|
||||
registered_paths[path] = len(resources[category]['apis'])
|
||||
resources[category]['apis'].append({
|
||||
'path': path,
|
||||
'description': action_params['action_help'],
|
||||
'operations': [operation]
|
||||
})
|
||||
|
||||
|
||||
try: os.listdir(os.getcwd() +'/doc')
|
||||
except OSError: os.makedirs(os.getcwd() +'/doc')
|
||||
|
||||
for category, api_dict in resources.items():
|
||||
with open(os.getcwd() +'/doc/'+ category +'.json', 'w') as f:
|
||||
json.dump(api_dict, f)
|
||||
|
||||
with open(os.getcwd() +'/doc/resources.json', 'w') as f:
|
||||
json.dump(resource_list, f)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
114
generate_function_doc.py
Normal file
114
generate_function_doc.py
Normal file
|
@ -0,0 +1,114 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" License
|
||||
|
||||
Copyright (C) 2013 YunoHost
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program; if not, see http://www.gnu.org/licenses
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
Generate function header documentation
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
import re
|
||||
|
||||
def main():
|
||||
"""
|
||||
|
||||
"""
|
||||
with open('action_map.yml') as f:
|
||||
action_map = yaml.load(f)
|
||||
|
||||
resources = {}
|
||||
|
||||
del action_map['general_arguments']
|
||||
for category, category_params in action_map.items():
|
||||
if 'category_help' not in category_params: category_params['category_help'] = ''
|
||||
|
||||
with open('yunohost_'+ category +'.py', 'r') as f:
|
||||
lines = f.readlines()
|
||||
with open('yunohost_'+ category +'.py', 'w') as f:
|
||||
in_block = False
|
||||
for line in lines:
|
||||
if in_block:
|
||||
if re.search(r'^"""', line):
|
||||
in_block = False
|
||||
f.write('\n')
|
||||
f.write(' '+ category_params['category_help'] +'\n')
|
||||
f.write('"""\n')
|
||||
else:
|
||||
f.write(line)
|
||||
|
||||
if re.search(r'^""" yunohost_'+ category, line):
|
||||
in_block = True
|
||||
|
||||
for action, action_params in category_params['actions'].items():
|
||||
if 'action_help' not in action_params:
|
||||
action_params['action_help'] = ''
|
||||
|
||||
help_lines = [
|
||||
' """',
|
||||
' '+ action_params['action_help'],
|
||||
''
|
||||
]
|
||||
|
||||
if 'arguments' in action_params:
|
||||
help_lines.append(' Keyword argument:')
|
||||
for arg_name, arg_params in action_params['arguments'].items():
|
||||
if 'help' in arg_params:
|
||||
help = ' -- '+ arg_params['help']
|
||||
else:
|
||||
help = ''
|
||||
name = arg_name.replace('-', '_')
|
||||
if name[0] == '_':
|
||||
required = False
|
||||
if 'full' in arg_params:
|
||||
name = arg_params['full'][2:]
|
||||
else:
|
||||
name = name[2:]
|
||||
name = name.replace('-', '_')
|
||||
|
||||
help_lines.append(' '+ name + help)
|
||||
|
||||
help_lines.append('')
|
||||
help_lines.append(' """')
|
||||
|
||||
with open('yunohost_'+ category +'.py', 'r') as f:
|
||||
lines = f.readlines()
|
||||
with open('yunohost_'+ category +'.py', 'w') as f:
|
||||
in_block = False
|
||||
first_quotes = True
|
||||
for line in lines:
|
||||
if in_block:
|
||||
if re.search(r'^ """', line):
|
||||
if first_quotes:
|
||||
first_quotes = False
|
||||
else:
|
||||
in_block = False
|
||||
for help_line in help_lines:
|
||||
f.write(help_line +'\n')
|
||||
else:
|
||||
f.write(line)
|
||||
|
||||
if re.search(r'^def '+ category +'_'+ action +'\(', line):
|
||||
in_block = True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
0
test/__init__.py → lib/test/__init__.py
Normal file → Executable file
0
test/__init__.py → lib/test/__init__.py
Normal file → Executable file
19
lib/test/test.py
Normal file
19
lib/test/test.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
def test_non_auth():
|
||||
return {'action': 'non-auth'}
|
||||
|
||||
def test_auth(auth):
|
||||
return {'action': 'auth',
|
||||
'authenticator': 'default', 'authenticate': 'all'}
|
||||
|
||||
def test_auth_profile(auth):
|
||||
return {'action': 'auth-profile',
|
||||
'authenticator': 'test-profile', 'authenticate': 'all'}
|
||||
|
||||
def test_auth_cli():
|
||||
return {'action': 'auth-cli',
|
||||
'authenticator': 'default', 'authenticate': ['cli']}
|
||||
|
||||
def test_anonymous():
|
||||
return {'action': 'anonymous',
|
||||
'authenticator': 'ldap-anonymous', 'authenticate': 'all'}
|
|
@ -1,47 +1,54 @@
|
|||
{
|
||||
"argument_required": "المُعامِل '{argument}' مطلوب",
|
||||
"authentication_profile_required": "المصادقة مع الملف الشخصي '{profile}' مطلوبة",
|
||||
"authentication_required": "المصادقة مطلوبة",
|
||||
"authentication_required_long": "المصادقة مطلوبة قبل القيام بهذا الإجراء",
|
||||
"colon": "{}: ",
|
||||
"confirm": "تأكيد {prompt}",
|
||||
"deprecated_command": "'{prog} {command}' تم التخلي عنه و سوف تتم إزالته مستقبلا",
|
||||
"deprecated_command_alias": "'{prog} {old}' تم التخلي عنه و سوف يتم إزالته مستقبلا، إستخدم '{prog} {new}' بدلا من ذلك",
|
||||
"error": "خطأ :",
|
||||
"error_see_log": "طرأ هناك خطأ. يرجى الإطلاع على السجلات للمزيد مِن التفاصيل على المسار /var/log/yunohost/.",
|
||||
"file_exists": "إنّ الملف موجود من قبل : '{path}'",
|
||||
"file_not_exist": "الملف غير موجود : '{path}'",
|
||||
"folder_exists": "إنّ المجلد موجود من قبل : '{path}'",
|
||||
"instance_already_running": "هناك بالفعل عملية YunoHost جارية. الرجاء الانتظار حتى ينتهي الأمر قبل تشغيل آخر.",
|
||||
"folder_not_exist": "المجلد غير موجود",
|
||||
"instance_already_running": "هناك نسخة خادوم تشتغل مِن قبل",
|
||||
"invalid_argument": "المُعامِل غير صالح '{argument}': {error}",
|
||||
"invalid_password": "كلمة السر خاطئة",
|
||||
"invalid_usage": "إستعمال غير صالح، إستخدم --help لعرض المساعدة",
|
||||
"ldap_attribute_already_exists": "الخاصية '{attribute}' موجودة مسبقا و تحمل القيمة '{value}'",
|
||||
"ldap_operation_error": "طرأ هناك خطأ أثناء عملية في LDAP",
|
||||
"ldap_server_down": "لا يمكن الإتصال بخادم LDAP",
|
||||
"logged_in": "مُتّصل",
|
||||
"logged_out": "تم تسجيل خروجك",
|
||||
"not_logged_in": "لم تقم بعدُ بتسجيل دخولك",
|
||||
"operation_interrupted": "تم توقيف العملية",
|
||||
"password": "كلمة السر",
|
||||
"pattern_not_match": "لا يتطابق مع النموذج",
|
||||
"permission_denied": "رُفض التصريح",
|
||||
"root_required": "يتوجب عليك أن تكون مدير الجذر root للقيام بهذا الإجراء",
|
||||
"server_already_running": "هناك خادم يشتغل على ذاك المنفذ",
|
||||
"success": "تم بنجاح !",
|
||||
"unable_authenticate": "تعذرت المصادقة",
|
||||
"unable_retrieve_session": "تعذرت مواصلة الجلسة",
|
||||
"unknown_group": "الفريق '{group}' مجهول",
|
||||
"unknown_user": "المستخدم '{user}' مجهول",
|
||||
"values_mismatch": "القيمتين غير متطابقتين",
|
||||
"warning": "تحذير :",
|
||||
"websocket_request_expected": "كان ينتظر طلبًا عبر الويب سوكت WebSocket",
|
||||
"cannot_open_file": "ليس بالإمكان فتح الملف {file} (السبب : {error})",
|
||||
"cannot_write_file": "لا يمكن الكتابة في الملف {file} (السبب : {error})",
|
||||
"unknown_error_reading_file": "طرأ هناك خطأ ما أثناء عملية قراءة الملف {file} (السبب: {error})",
|
||||
"corrupted_json": "قراءة ملف JSON مُشوّهة مِن {ressource} (السبب : {error})",
|
||||
"error_writing_file": "طرأ هناك خطأ أثناء الكتابة في الملف {file}: {error}",
|
||||
"error_removing": "خطأ أثناء عملية حذف {path}: {error}",
|
||||
"error_changing_file_permissions": "خطأ أثناء عملية تعديل التصريحات لـ {path}: {error}",
|
||||
"invalid_url": "فشل الاتصال بـ {url}… ربما تكون الخدمة معطلة ، أو أنك غير متصل بشكل صحيح بالإنترنت في IPv4 / IPv6.",
|
||||
"download_ssl_error": "خطأ في الاتصال الآمن عبر الـ SSL أثناء محاولة الربط بـ {url}",
|
||||
"download_timeout": "{url} استغرق مدة طويلة جدا للإستجابة، فتوقّف.",
|
||||
"download_unknown_error": "خطأ أثناء عملية تنزيل البيانات مِن {url} : {error}",
|
||||
"download_bad_status_code": "{url} أعاد رمز الحالة {code}",
|
||||
"corrupted_yaml": "قراءة مُشوّهة لملف YAML مِن {ressource} (السبب : {error})",
|
||||
"info": "معلومة:",
|
||||
"warn_the_user_about_waiting_lock_again": "جارٍ الانتظار…",
|
||||
"warn_the_user_that_lock_is_acquired": "لقد انتهى تنفيذ ذاك الأمر للتوّ ، جارٍ تنفيذ هذا الأمر",
|
||||
"warn_the_user_about_waiting_lock": "هناك أمر لـ YunoHost قيد التشغيل حاليا. في انتظار انتهاء تنفيذه قبل تشغيل التالي",
|
||||
"edit_text_question": "{}. تعديل هذا النص؟ [yN]: ",
|
||||
"corrupted_toml": "قراءة مُشوّهة لملف TOML مِن {ressource} (السبب : {error})"
|
||||
"cannot_open_file": "ليس بالإمكان فتح الملف {file:s} (السبب : {error:s})",
|
||||
"cannot_write_file": "لا يمكن الكتابة في الملف {file:s} (السبب : {error:s})",
|
||||
"unknown_error_reading_file": "طرأ هناك خطأ ما أثناء عملية قراءة الملف {file:s}",
|
||||
"corrupted_json": "قراءة json مُشوّهة مِن {ressource:s} (السبب : {error:s})",
|
||||
"error_writing_file": "طرأ هناك خطأ أثناء الكتابة في الملف {file:s}: {error:s}",
|
||||
"error_removing": "خطأ أثناء عملية حذف {path:s}: {error:s}",
|
||||
"error_changing_file_permissions": "خطأ أثناء عملية تعديل التصريحات لـ {path:s}: {error:s}",
|
||||
"invalid_url": "خطأ في عنوان الرابط {url:s} (هل هذا الموقع موجود حقًا ؟)",
|
||||
"download_ssl_error": "خطأ في الإتصال الآمن عبر الـ SSL أثناء محاولة الإتصال بـ {url:s}",
|
||||
"download_timeout": "{url:s} استغرق مدة طويلة جدا للإستجابة، فتوقّف.",
|
||||
"download_unknown_error": "خطأ أثناء عملية تنزيل البيانات مِن {url:s} : {error:s}",
|
||||
"download_bad_status_code": "{url:s} أعاد رمز الحالة {code:s}",
|
||||
"command_unknown": "الأمر '{command:s}' غير معروف ؟",
|
||||
"corrupted_yaml": "قراءة مُشوّهة لنسق yaml مِن {ressource:s} (السبب : {error:s})"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"logged_out": "প্রস্থান",
|
||||
"password": "পাসওয়ার্ড"
|
||||
}
|
|
@ -1,47 +1,54 @@
|
|||
{
|
||||
"argument_required": "Es requereix l'argument «{argument}»",
|
||||
"argument_required": "Es requereix l'argument {argument}",
|
||||
"authentication_profile_required": "Autenticació requerida al perfil {profile}",
|
||||
"authentication_required": "Es requereix autenticació",
|
||||
"confirm": "Confirmar {prompt}",
|
||||
"authentication_required_long": "Es requereix autenticació per realitzar aquesta tasca",
|
||||
"colon": "{}: ",
|
||||
"confirm": "Confirmar{prompt}",
|
||||
"deprecated_command": "{prog}{command}és obsolet i es desinstal·larà en el futur",
|
||||
"deprecated_command_alias": "{prog}{old}és obsolet i es desinstal·larà en el futur, utilitzeu {prog}{new}en el seu lloc",
|
||||
"error": "Error:",
|
||||
"error_see_log": "Hi ha hagut un error. Si us plau verifiqueu el registre per a més informació, són a /var/log/yunohost/.",
|
||||
"file_exists": "El fitxer ja existeix: '{path}'",
|
||||
"file_not_exist": "El fitxer no existeix: '{path}'",
|
||||
"folder_exists": "La carpeta ja existeix: '{path}'",
|
||||
"instance_already_running": "Ja hi ha una operació de YunoHost en curs. Espereu a que s'acabi abans d'executar-ne una altra.",
|
||||
"folder_not_exist": "La carpeta no existeix",
|
||||
"instance_already_running": "Una instància ja s'està executant",
|
||||
"invalid_argument": "Argument invàlid '{argument}': {error}",
|
||||
"invalid_password": "Contrasenya invàlida",
|
||||
"invalid_usage": "Utilització invàlida, utilitzeu --help per veure l'ajuda",
|
||||
"ldap_attribute_already_exists": "L'atribut '{attribute}' ja existeix amb el valor '{value}'",
|
||||
"ldap_operation_error": "Hi ha hagut un error durant l'operació de LDAP",
|
||||
"ldap_server_down": "No s'ha pogut connectar amb el servidor LDAP",
|
||||
"logged_in": "Sessió iniciada",
|
||||
"logged_out": "Sessió tancada",
|
||||
"not_logged_in": "No ha iniciat sessió",
|
||||
"operation_interrupted": "Operació interrompuda",
|
||||
"password": "Contrasenya",
|
||||
"pattern_not_match": "No coincideix amb el patró",
|
||||
"permission_denied": "Permís denegat",
|
||||
"root_required": "Ha de ser root per realitzar aquesta acció",
|
||||
"server_already_running": "Ja s'està executant un servidor en aquest port",
|
||||
"success": "Èxit!",
|
||||
"unable_authenticate": "No s'ha pogut autenticar",
|
||||
"unable_retrieve_session": "No s'ha pogut recuperar la sessió",
|
||||
"unknown_group": "Grup '{group}' desconegut",
|
||||
"unknown_user": "Usuari '{user}' desconegut",
|
||||
"values_mismatch": "Els valors no coincideixen",
|
||||
"warning": "Atenció:",
|
||||
"websocket_request_expected": "S'esperava una petició WebSocket",
|
||||
"cannot_open_file": "No s'ha pogut obrir el fitxer {file} (motiu: {error})",
|
||||
"cannot_write_file": "No s'ha pogut escriure el fitxer {file} (motiu: {error})",
|
||||
"unknown_error_reading_file": "Error desconegut al intentar llegir el fitxer {file} (motiu: {error})",
|
||||
"corrupted_json": "JSON corrupte llegit des de {ressource} (motiu: {error})",
|
||||
"corrupted_yaml": "YAML corrupte llegit des de {ressource} (motiu: {error})",
|
||||
"error_writing_file": "Error al escriure el fitxer {file}: {error}",
|
||||
"error_removing": "Error al eliminar {path}: {error}",
|
||||
"error_changing_file_permissions": "Error al canviar els permisos per {path}: {error}",
|
||||
"invalid_url": "No s'ha pogut connectar a {url}… pot ser que el servei estigui caigut, o que no hi hagi connexió a Internet amb IPv4/IPv6.",
|
||||
"download_ssl_error": "Error SSL al connectar amb {url}",
|
||||
"download_timeout": "{url} ha tardat massa en respondre, s'ha deixat d'esperar.",
|
||||
"download_unknown_error": "Error al baixar dades des de {url}: {error}",
|
||||
"download_bad_status_code": "{url} ha retornat el codi d'estat {code}",
|
||||
"info": "Info:",
|
||||
"corrupted_toml": "El fitxer TOML ha estat corromput en la lectura des de {ressource} (motiu: {error})",
|
||||
"warn_the_user_about_waiting_lock": "Hi ha una altra ordre de YunoHost en execució, s'executarà aquesta ordre un cop l'anterior hagi acabat",
|
||||
"warn_the_user_about_waiting_lock_again": "Encara en espera…",
|
||||
"warn_the_user_that_lock_is_acquired": "L'altra ordre tot just ha acabat, ara s'executarà aquesta ordre",
|
||||
"edit_text_question": "{}. Edita aquest text ? [yN]: "
|
||||
"cannot_open_file": "No s'ha pogut obrir el fitxer {file:s} (motiu: {error:s})",
|
||||
"cannot_write_file": "No s'ha pogut escriure el fitxer {file:s} (motiu: {error:s})",
|
||||
"unknown_error_reading_file": "Error desconegut al intentar llegir el fitxer {file:s}",
|
||||
"corrupted_json": "Json corrupte llegit des de {ressource:s} (motiu: {error:s})",
|
||||
"corrupted_yaml": "Yaml corrupte llegit des de {ressource:s} (motiu: {error:s})",
|
||||
"error_writing_file": "Error al escriure el fitxer {file:s}: {error:s}",
|
||||
"error_removing": "Error al eliminar {path:s}: {error:s}",
|
||||
"error_changing_file_permissions": "Error al canviar els permisos per {path:s}: {error:s}",
|
||||
"invalid_url": "Url invàlid {url:s} (el lloc web existeix?)",
|
||||
"download_ssl_error": "Error SSL al connectar amb {url:s}",
|
||||
"download_timeout": "{url:s} ha tardat massa en respondre, s'ha deixat d'esperar.",
|
||||
"download_unknown_error": "Error al baixar dades des de {url:s}: {error:s}",
|
||||
"download_bad_status_code": "{url:s} ha retornat el codi d'estat {code:s}",
|
||||
"command_unknown": "Ordre '{command:s}' desconegut ?"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"argument_required": "参数“{argument}”是必须的",
|
||||
"authentication_required": "需要验证",
|
||||
"confirm": "确认 {prompt}",
|
||||
"deprecated_command": "{prog}{command}已经放弃使用,将来会删除",
|
||||
"deprecated_command_alias": "{prog}{old}已经放弃使用,将来会删除,请使用{prog}{new}代替",
|
||||
"error": "错误:",
|
||||
"file_not_exist": "文件不存在: '{path}'",
|
||||
"folder_exists": "目录已存在: '{path}'",
|
||||
"info": "信息:",
|
||||
"instance_already_running": "已经有一个YunoHost操作正在运行。 请等待它完成再运行另一个。",
|
||||
"invalid_argument": "参数错误{argument}:{error}",
|
||||
"invalid_usage": "用法错误,输入 --help 查看帮助信息",
|
||||
"logged_in": "登录",
|
||||
"logged_out": "登出",
|
||||
"not_logged_in": "您未登录",
|
||||
"operation_interrupted": "操作中断",
|
||||
"password": "密码",
|
||||
"pattern_not_match": "模式匹配失败",
|
||||
"root_required": "必须以root身份进行此操作",
|
||||
"server_already_running": "服务已运行在指定端口",
|
||||
"success": "成功!",
|
||||
"unable_authenticate": "认证失败",
|
||||
"unknown_group": "未知组{group}",
|
||||
"unknown_user": "未知用户{user}",
|
||||
"values_mismatch": "值不匹配",
|
||||
"warning": "警告:",
|
||||
"websocket_request_expected": "期望一个WebSocket请求",
|
||||
"cannot_open_file": "不能打开文件{file}(原因:{error})",
|
||||
"cannot_write_file": "写入文件{file}失败(原因:{error})",
|
||||
"unknown_error_reading_file": "尝试读取文件{file}时发生未知错误(原因:{error})",
|
||||
"corrupted_json": "从{ressource}读取的JSON损坏(原因:{error})",
|
||||
"corrupted_yaml": "从{ressource}读取的YMAL损坏(原因:{error})",
|
||||
"error_writing_file": "写入文件{file}失败:{error}",
|
||||
"error_removing": "删除路径{path}失败:{error}",
|
||||
"error_changing_file_permissions": "目录{path}权限修改失败:{error}",
|
||||
"invalid_url": "{url} 连接失败… 可能是服务中断了,或者你没有正确连接到IPv4/IPv6的互联网。",
|
||||
"download_ssl_error": "连接{url}时发生SSL错误",
|
||||
"download_timeout": "{url}响应超时,放弃。",
|
||||
"download_unknown_error": "下载{url}失败:{error}",
|
||||
"download_bad_status_code": "{url}返回状态码:{code}",
|
||||
"warn_the_user_that_lock_is_acquired": "另一个命令刚刚完成,现在启动此命令",
|
||||
"warn_the_user_about_waiting_lock_again": "仍在等待…",
|
||||
"warn_the_user_about_waiting_lock": "目前正在运行另一个YunoHost命令,我们在运行此命令之前等待它完成",
|
||||
"corrupted_toml": "从{ressource}读取的TOML已损坏(原因:{error})",
|
||||
"edit_text_question": "{}.编辑此文本?[yN]: "
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"password": "Heslo",
|
||||
"logged_out": "Jste odhlášen/a",
|
||||
"warn_the_user_that_lock_is_acquired": "Předchozí operace dokončena, nyní spouštíme tuto",
|
||||
"warn_the_user_about_waiting_lock_again": "Stále čekáme…",
|
||||
"warn_the_user_about_waiting_lock": "Jiná YunoHost operace právě probíhá, před spuštěním této čekáme na její dokončení",
|
||||
"download_bad_status_code": "{url} vrátil stavový kód {code}",
|
||||
"download_unknown_error": "Chyba při stahování dat z {url}: {error}",
|
||||
"download_timeout": "{url} příliš dlouho neodpovídá, akce přerušena.",
|
||||
"download_ssl_error": "SSL chyba při spojení s {url}",
|
||||
"invalid_url": "Špatný odkaz {url} (je vůbec dostupný?).",
|
||||
"error_changing_file_permissions": "Chyba při nastavování oprávnění pro {path}: {error}",
|
||||
"error_removing": "Chyba při přesunu {path}: {error}",
|
||||
"error_writing_file": "Chyba při zápisu souboru/ů {file}: {error}",
|
||||
"corrupted_toml": "Nepodařilo se načíst TOML z {ressource} (reason: {error})",
|
||||
"corrupted_yaml": "Nepodařilo se načíst YAML z {ressource} (reason: {error})",
|
||||
"corrupted_json": "Nepodařilo se načíst JSON {ressource} (reason: {error})",
|
||||
"unknown_error_reading_file": "Vyskytla se neznámá chyba při čtení souboru/ů {file} (reason: {error})",
|
||||
"cannot_write_file": "Nelze zapsat soubor/y {file} (reason: {error})",
|
||||
"cannot_open_file": "Nelze otevřít soubor/y {file} (reason: {error})",
|
||||
"websocket_request_expected": "Očekáván WebSocket požadavek",
|
||||
"warning": "Varování:",
|
||||
"values_mismatch": "Hodnoty nesouhlasí",
|
||||
"unknown_user": "Neznámý '{user}' uživatel",
|
||||
"unknown_group": "Neznámá '{group}' skupina",
|
||||
"unable_authenticate": "Není možné ověřit",
|
||||
"success": "Zadařilo se!",
|
||||
"server_already_running": "Na tomto portu je server již provozován",
|
||||
"root_required": "Pro provedení této akce musíte být root",
|
||||
"pattern_not_match": "Neodpovídá výrazu",
|
||||
"operation_interrupted": "Operace přerušena",
|
||||
"not_logged_in": "Nejste přihlášen",
|
||||
"logged_in": "Přihlášení",
|
||||
"invalid_usage": "Nesprávné použití, pass --help pro zobrazení nápovědy",
|
||||
"invalid_argument": "Nesprávný argument '{argument}': {error}",
|
||||
"instance_already_running": "Právě probíhá jiná YunoHost operace. Před spuštěním další operace vyčkejte na její dokončení.",
|
||||
"info": "Info:",
|
||||
"folder_exists": "Adresář již existuje: '{path}'",
|
||||
"file_not_exist": "Soubor neexistuje: '{path}'",
|
||||
"error": "Chyba:",
|
||||
"deprecated_command_alias": "'{prog} {old}' je zastaralý a bude odebrán v budoucích verzích, použijte '{prog} {new}'",
|
||||
"deprecated_command": "'{prog} {command}' je zastaralý a bude odebrán v budoucích verzích",
|
||||
"confirm": "Potvrdit {prompt}",
|
||||
"authentication_required": "Vyžadováno ověření",
|
||||
"argument_required": "Je vyžadován argument '{argument}'",
|
||||
"edit_text_question": "{}. Upravit tento text? [yN]: "
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,47 +1,40 @@
|
|||
{
|
||||
"argument_required": "Der Parameter {argument} ist erforderlich",
|
||||
"authentication_profile_required": "Anmeldung als Nutzer '{profile}' wird benötigt",
|
||||
"authentication_required": "Anmeldung erforderlich",
|
||||
"confirm": "Bestätigen Sie {prompt}",
|
||||
"authentication_required_long": "Bitte erst anmelden um diese Aktion auszuführen",
|
||||
"colon": "{}: ",
|
||||
"confirm": "Bestätige {prompt}",
|
||||
"error": "Fehler:",
|
||||
"error_see_log": "Ein Fehler ist aufgetreten. Für Details bitte im Log nachsehen.",
|
||||
"file_exists": "Datei existiert bereits: '{path}'",
|
||||
"file_not_exist": "Datei ist nicht vorhanden: '{path}'",
|
||||
"folder_exists": "Ordner existiert bereits: '{path}'",
|
||||
"instance_already_running": "Es läuft bereits eine YunoHost-Operation. Bitte warte, bis sie fertig ist, bevor du eine weitere startest.",
|
||||
"folder_not_exist": "Ordner existiert nicht",
|
||||
"instance_already_running": "Eine Instanz läuft bereits",
|
||||
"invalid_argument": "Argument ungültig '{argument}': {error}",
|
||||
"invalid_password": "Passwort falsch",
|
||||
"invalid_usage": "Falscher Aufruf, verwende --help für den Hilfstext",
|
||||
"ldap_attribute_already_exists": "Attribute existieren bereits: '{attribute}={value}'",
|
||||
"ldap_operation_error": "Ein Fehler trat während der LDAP Abfrage auf",
|
||||
"ldap_server_down": "LDAP-Server nicht erreichbar",
|
||||
"logged_in": "Angemeldet",
|
||||
"logged_out": "Abgemeldet",
|
||||
"logged_out": "Ausgeloggt",
|
||||
"not_logged_in": "Du bist nicht angemeldet",
|
||||
"operation_interrupted": "Vorgang unterbrochen",
|
||||
"password": "Passwort",
|
||||
"pattern_not_match": "Entspricht nicht dem Muster",
|
||||
"permission_denied": "Zugriff verweigert",
|
||||
"root_required": "Nur der Nutzer root kann diesen Vorgang ausführen",
|
||||
"server_already_running": "Einen anderer Dienst arbeitet bereits auf diesem Port",
|
||||
"success": "Erfolg!",
|
||||
"unable_authenticate": "Anmelden fehlgeschlagen",
|
||||
"values_mismatch": "Die Werte passen nicht zusammen",
|
||||
"unable_retrieve_session": "Sitzung konnte nicht abgerufen werden",
|
||||
"values_mismatch": "Die Werte passen nicht",
|
||||
"warning": "Warnung:",
|
||||
"websocket_request_expected": "Eine WebSocket-Anfrage wurde erwartet",
|
||||
"websocket_request_expected": "Eine WebSocket Anfrage wurde erwartet",
|
||||
"deprecated_command": "'{prog} {command}' ist veraltet und wird bald entfernt werden",
|
||||
"deprecated_command_alias": "'{prog} {old}' ist veraltet und wird bald entfernt werden, benutze '{prog} {new}' stattdessen",
|
||||
"unknown_group": "Gruppe '{group}' ist unbekannt",
|
||||
"unknown_user": "Konto '{user}' ist unbekannt",
|
||||
"info": "Info:",
|
||||
"corrupted_json": "Beschädigtes JSON gelesen von {ressource} (reason: {error})",
|
||||
"unknown_error_reading_file": "Unbekannter Fehler beim Lesen der Datei {file} (reason: {error})",
|
||||
"cannot_write_file": "Kann Datei {file} nicht schreiben (reason: {error})",
|
||||
"cannot_open_file": "Datei {file} konnte nicht geöffnet werden (Ursache: {error})",
|
||||
"corrupted_yaml": "Beschädigtes YAML gelesen von {ressource} (reason: {error})",
|
||||
"warn_the_user_that_lock_is_acquired": "Der andere Befehl wurde gerade abgeschlossen, starte jetzt diesen Befehl",
|
||||
"warn_the_user_about_waiting_lock_again": "Immer noch wartend…",
|
||||
"warn_the_user_about_waiting_lock": "Ein anderer YunoHost Befehl läuft gerade, wir warten bis er fertig ist, bevor dieser laufen kann",
|
||||
"download_bad_status_code": "{url} lieferte folgende(n) Status Code(s) {code}",
|
||||
"download_unknown_error": "Fehler beim Herunterladen von Daten von {url}: {error}",
|
||||
"download_timeout": "{url} brauchte zu lange zum Antworten, hab aufgegeben.",
|
||||
"download_ssl_error": "SSL Fehler beim Verbinden zu {url}",
|
||||
"invalid_url": "Konnte keine Verbindung zu {url} herstellen… vielleicht ist der Dienst ausgefallen, oder Sie sind nicht richtig mit dem Internet in IPv4/IPv6 verbunden.",
|
||||
"error_changing_file_permissions": "Fehler beim Ändern der Berechtigungen für {path}: {error}",
|
||||
"error_removing": "Fehler beim Entfernen {path}: {error}",
|
||||
"error_writing_file": "Fehler beim Schreiben von Datei {file}: {error}",
|
||||
"corrupted_toml": "Beschädigtes TOML gelesen von {ressource} (reason: {error})",
|
||||
"edit_text_question": "{}. Diesen Text bearbeiten? [yN]: "
|
||||
"unknown_user": "Benutzer '{user}' ist unbekannt"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"logged_out": "Αποσυνδέθηκα",
|
||||
"password": "Κωδικός πρόσβασης"
|
||||
}
|
|
@ -1,47 +1,56 @@
|
|||
{
|
||||
"argument_required": "Argument '{argument}' is required",
|
||||
"authentication_profile_required": "Authentication to profile '{profile}' required",
|
||||
"authentication_required": "Authentication required",
|
||||
"authentication_required_long": "Authentication is required to perform this action",
|
||||
"colon": "{}: ",
|
||||
"confirm": "Confirm {prompt}",
|
||||
"deprecated_command": "'{prog} {command}' is deprecated and will be removed in the future",
|
||||
"deprecated_command_alias": "'{prog} {old}' is deprecated and will be removed in the future, use '{prog} {new}' instead",
|
||||
"edit_text_question": "{}. Edit this text ? [yN]: ",
|
||||
"error": "Error:",
|
||||
"error_see_log": "An error occurred. Please see the logs for details, they are located in /var/log/yunohost/.",
|
||||
"file_exists": "File already exists: '{path}'",
|
||||
"file_not_exist": "File does not exist: '{path}'",
|
||||
"folder_exists": "Folder already exists: '{path}'",
|
||||
"folder_not_exist": "Folder does not exist",
|
||||
"info": "Info:",
|
||||
"instance_already_running": "There is already a YunoHost operation running. Please wait for it to finish before running another one.",
|
||||
"instance_already_running": "An instance is already running",
|
||||
"invalid_argument": "Invalid argument '{argument}': {error}",
|
||||
"invalid_password": "Invalid password",
|
||||
"invalid_usage": "Invalid usage, pass --help to see help",
|
||||
"ldap_attribute_already_exists": "Attribute '{attribute}' already exists with value '{value}'",
|
||||
"ldap_operation_error": "An error occurred during LDAP operation",
|
||||
"ldap_server_down": "Unable to reach LDAP server",
|
||||
"logged_in": "Logged in",
|
||||
"logged_out": "Logged out",
|
||||
"not_logged_in": "You are not logged in",
|
||||
"operation_interrupted": "Operation interrupted",
|
||||
"password": "Password",
|
||||
"pattern_not_match": "Does not match pattern",
|
||||
"permission_denied": "Permission denied",
|
||||
"root_required": "You must be root to perform this action",
|
||||
"server_already_running": "A server is already running on that port",
|
||||
"success": "Success!",
|
||||
"unable_authenticate": "Unable to authenticate",
|
||||
"unable_retrieve_session": "Unable to retrieve the session",
|
||||
"unknown_group": "Unknown '{group}' group",
|
||||
"unknown_user": "Unknown '{user}' user",
|
||||
"values_mismatch": "Values don't match",
|
||||
"info": "Info:",
|
||||
"warning": "Warning:",
|
||||
"websocket_request_expected": "Expected a WebSocket request",
|
||||
"cannot_open_file": "Could not open file {file} (reason: {error})",
|
||||
"cannot_write_file": "Could not write file {file} (reason: {error})",
|
||||
"unknown_error_reading_file": "Unknown error while trying to read file {file} (reason: {error})",
|
||||
"corrupted_json": "Corrupted JSON read from {ressource} (reason: {error})",
|
||||
"corrupted_yaml": "Corrupted YAML read from {ressource} (reason: {error})",
|
||||
"corrupted_toml": "Corrupted TOML read from {ressource} (reason: {error})",
|
||||
"error_writing_file": "Error when writing file {file}: {error}",
|
||||
"error_removing": "Error when removing {path}: {error}",
|
||||
"error_changing_file_permissions": "Error when changing permissions for {path}: {error}",
|
||||
"invalid_url": "Failed to connect to {url}... maybe the service is down, or you are not properly connected to the Internet in IPv4/IPv6.",
|
||||
"download_ssl_error": "SSL error when connecting to {url}",
|
||||
"download_timeout": "{url} took too long to answer, gave up.",
|
||||
"download_unknown_error": "Error when downloading data from {url}: {error}",
|
||||
"download_bad_status_code": "{url} returned status code {code}",
|
||||
"warn_the_user_about_waiting_lock": "Another YunoHost command is running right now, we are waiting for it to finish before running this one",
|
||||
"warn_the_user_about_waiting_lock_again": "Still waiting...",
|
||||
"warn_the_user_that_lock_is_acquired": "The other command just completed, now starting this command"
|
||||
"cannot_open_file": "Could not open file {file:s} (reason: {error:s})",
|
||||
"cannot_write_file": "Could not write file {file:s} (reason: {error:s})",
|
||||
"unknown_error_reading_file": "Unknown error while trying to read file {file:s}",
|
||||
"corrupted_json": "Corrupted json read from {ressource:s} (reason: {error:s})",
|
||||
"corrupted_yaml": "Corrupted yaml read from {ressource:s} (reason: {error:s})",
|
||||
"error_writing_file": "Error when writing file {file:s}: {error:s}",
|
||||
"error_removing": "Error when removing {path:s}: {error:s}",
|
||||
"error_changing_file_permissions": "Error when changing permissions for {path:s}: {error:s}",
|
||||
"invalid_url": "Invalid url {url:s} (does this site exists ?)",
|
||||
"download_ssl_error": "SSL error when connecting to {url:s}",
|
||||
"download_timeout": "{url:s} took too long to answer, gave up.",
|
||||
"download_unknown_error": "Error when downloading data from {url:s} : {error:s}",
|
||||
"download_bad_status_code": "{url:s} returned status code {code:s}",
|
||||
"command_unknown": "Command '{command:s}' unknown ?"
|
||||
}
|
||||
|
|
|
@ -1,46 +1,3 @@
|
|||
{
|
||||
"password": "Pasvorto",
|
||||
"warn_the_user_that_lock_is_acquired": "La alia komando ĵus kompletigis, nun komencante ĉi tiun komandon",
|
||||
"warn_the_user_about_waiting_lock_again": "Ankoraŭ atendanta…",
|
||||
"warn_the_user_about_waiting_lock": "Alia komando de YunoHost funkcias ĝuste nun, ni atendas, ke ĝi finiĝos antaŭ ol funkcii ĉi tiu",
|
||||
"download_bad_status_code": "{url} redonita statuskodo {code}",
|
||||
"download_unknown_error": "Eraro dum elŝutado de datumoj de {url}: {error}",
|
||||
"download_timeout": "{url} prenis tro da tempo por respondi, rezignis.",
|
||||
"download_ssl_error": "SSL-eraro dum konekto al {url}",
|
||||
"invalid_url": "Nevalida URL{url} (ĉu ĉi tiu retejo ekzistas?)",
|
||||
"error_changing_file_permissions": "Eraro dum ŝanĝo de permesoj por {path}: {error}",
|
||||
"error_removing": "Eraro dum la forigo de {path}: {error}",
|
||||
"error_writing_file": "Eraro skribinte dosieron {file}: {error}",
|
||||
"corrupted_toml": "Korupta TOML legita el {ressource} (kialo: {error})",
|
||||
"corrupted_yaml": "Korupta YAML legita de {ressource} (kialo: {error})",
|
||||
"corrupted_json": "Koruptita JSON legis de {ressource} (Kialo: {error})",
|
||||
"unknown_error_reading_file": "Nekonata eraro dum provi legi dosieron {file} (kialo: {error})",
|
||||
"cannot_write_file": "Ne povis skribi dosieron {file} (kialo: {error})",
|
||||
"cannot_open_file": "Ne povis malfermi dosieron {file} (kialo: {error})",
|
||||
"websocket_request_expected": "Atendis ret-peto",
|
||||
"warning": "Averto:",
|
||||
"values_mismatch": "Valoroj ne kongruas",
|
||||
"unknown_user": "Nekonata uzanto '{user}'",
|
||||
"unknown_group": "Nekonata grupo \"{group}\"",
|
||||
"unable_authenticate": "Ne eblas aŭtentiĝi",
|
||||
"success": "Sukceson!",
|
||||
"server_already_running": "Servilo jam funkcias sur tiu haveno",
|
||||
"root_required": "Vi devas esti 'root' por plenumi ĉi tiun agon",
|
||||
"pattern_not_match": "Ne kongruas kun ŝablono",
|
||||
"operation_interrupted": "Operacio interrompita",
|
||||
"not_logged_in": "Vi ne estas ensalutinta",
|
||||
"logged_in": "Ensalutinta",
|
||||
"invalid_usage": "Nevalida uzado, preterpase '--help' por vidi helpon",
|
||||
"invalid_argument": "Nevalida argumento '{argument}': {error}",
|
||||
"instance_already_running": "Jam funkcias YunoHost-operacio. Bonvolu atendi, ke ĝi finiĝos antaŭ ol funkcii alia.",
|
||||
"info": "informoj:",
|
||||
"folder_exists": "Dosierujo jam ekzistas: '{path}'",
|
||||
"file_not_exist": "Dosiero ne ekzistas: '{path}'",
|
||||
"error": "Eraro:",
|
||||
"deprecated_command_alias": "'{prog} {old}' malakceptas kaj estos forigita estonte, uzu anstataŭe '{prog} {new}'",
|
||||
"deprecated_command": "'{prog} {command}' malakceptas kaj estos forigita estonte",
|
||||
"confirm": "Konfirmu {prompt}",
|
||||
"authentication_required": "Aŭtentigo bezonata",
|
||||
"argument_required": "Argumento '{argument}' estas bezonata",
|
||||
"logged_out": "Ensalutinta"
|
||||
"password": "Pasvorto"
|
||||
}
|
|
@ -1,47 +1,53 @@
|
|||
{
|
||||
"argument_required": "Se requiere el argumento «{argument}»",
|
||||
"argument_required": "Se requiere el argumento '{argument}'",
|
||||
"authentication_profile_required": "Autenticación requerida para el perfil '{profile}'",
|
||||
"authentication_required": "Se requiere autentificación",
|
||||
"authentication_required_long": "Debe autenticarse para realizar esta acción",
|
||||
"colon": "{}: ",
|
||||
"confirm": "Confirmar {prompt}",
|
||||
"deprecated_command": "«{prog} {command}» está obsoleto y será eliminado en el futuro",
|
||||
"deprecated_command_alias": "«{prog} {old}» está obsoleto y se eliminará en el futuro, use «{prog} {new}» en su lugar",
|
||||
"deprecated_command": "'{prog} {command}' está obsoleto y será eliminado en el futuro",
|
||||
"deprecated_command_alias": "'{prog} {old}' está obsoleto y se eliminará en el futuro, use '{prog} {new}' en su lugar",
|
||||
"error": "Error:",
|
||||
"file_not_exist": "El archivo no existe: «{path}»",
|
||||
"folder_exists": "El directorio ya existe: «{path}»",
|
||||
"instance_already_running": "Ya se está ejecutando una instancia de YunoHost. Espere a que termine antes de ejecutar otra.",
|
||||
"invalid_argument": "Argumento no válido «{argument}»: {error}",
|
||||
"error_see_log": "Ha ocurrido un error. Consulte el registro para obtener más información, localizado en /var/log/yunohost/.",
|
||||
"file_exists": "El archivo ya existe: '{path}'",
|
||||
"file_not_exist": "El archivo no existe: '{path}'",
|
||||
"folder_exists": "El directorio ya existe: '{path}'",
|
||||
"folder_not_exist": "El directorio no existe",
|
||||
"instance_already_running": "Una instancia ya se está ejecutando",
|
||||
"invalid_argument": "Argumento no válido '{argument}': {error}",
|
||||
"invalid_password": "Contraseña no válida",
|
||||
"invalid_usage": "Uso no válido, utilice --help para ver la ayuda",
|
||||
"ldap_attribute_already_exists": "El atributo '{attribute}' ya existe con el valor '{value}'",
|
||||
"ldap_operation_error": "Ha ocurrido un error durante la operación de LDAP",
|
||||
"ldap_server_down": "No se pudo conectar con el servidor LDAP",
|
||||
"logged_in": "Sesión iniciada",
|
||||
"logged_out": "Sesión cerrada",
|
||||
"not_logged_in": "No ha iniciado sesión",
|
||||
"operation_interrupted": "Operación interrumpida",
|
||||
"password": "Contraseña",
|
||||
"pattern_not_match": "No coincide con el patrón",
|
||||
"permission_denied": "Permiso denegado",
|
||||
"root_required": "Solo root puede realizar esta acción",
|
||||
"server_already_running": "Ya se está ejecutando un servidor en ese puerto",
|
||||
"success": "¡Éxito!",
|
||||
"unable_authenticate": "No se puede autentificar",
|
||||
"unknown_group": "Grupo «{group}» desconocido",
|
||||
"unknown_user": "Usuario «{user}» desconocido",
|
||||
"unable_authenticate": "No se puede autenticar",
|
||||
"unable_retrieve_session": "No se puede recuperar la sesión",
|
||||
"unknown_group": "Grupo '{group}' desconocido",
|
||||
"unknown_user": "Usuario '{user}' desconocido",
|
||||
"values_mismatch": "Los valores no coinciden",
|
||||
"warning": "Advertencia:",
|
||||
"websocket_request_expected": "Se esperaba una petición WebSocket",
|
||||
"cannot_open_file": "No se pudo abrir el archivo {file} (motivo: {error})",
|
||||
"cannot_write_file": "No se pudo escribir el archivo {file} (motivo: {error})",
|
||||
"unknown_error_reading_file": "Error desconocido al intentar leer el archivo {file} (motivo: {error})",
|
||||
"corrupted_json": "Lectura corrupta de JSON desde {ressource} (motivo: {error})",
|
||||
"error_writing_file": "Error al escribir el archivo {file}: {error}",
|
||||
"error_removing": "Error al eliminar {path}: {error}",
|
||||
"error_changing_file_permissions": "Error al cambiar los permisos para {path}: {error}",
|
||||
"invalid_url": "Imposible de conectarse a {url} (¿ la URL esta correcta, existe este sitio, o internet esta accesible?).",
|
||||
"download_ssl_error": "Error SSL al conectar con {url}",
|
||||
"download_timeout": "{url} tardó demasiado en responder, abandono.",
|
||||
"download_unknown_error": "Error al descargar datos desde {url} : {error}",
|
||||
"download_bad_status_code": "{url} devolvió el código de estado {code}",
|
||||
"corrupted_yaml": "Lectura corrupta de YAML desde {ressource} (motivo: {error})",
|
||||
"info": "Información:",
|
||||
"corrupted_toml": "Lectura corrupta de TOML desde {ressource} (motivo: {error})",
|
||||
"warn_the_user_that_lock_is_acquired": "La otra orden recién terminó, iniciando esta orden ahora",
|
||||
"warn_the_user_about_waiting_lock_again": "Aún esperando…",
|
||||
"warn_the_user_about_waiting_lock": "Otra orden de YunoHost se está ejecutando ahora, estamos esperando a que termine antes de ejecutar esta",
|
||||
"edit_text_question": "{}. Editar este texto ? [sN]: "
|
||||
"cannot_open_file": "No se pudo abrir el fichero{file:s} (motivo:{error:s})",
|
||||
"cannot_write_file": "No se pudo escribir el fichero {file:s} (motivo: {error:s})",
|
||||
"unknown_error_reading_file": "Error desconocido al intentar leer el fichero {file:s}",
|
||||
"corrupted_json": "Json corrupto leido desde {ressource:s} (motivo: {error:s})",
|
||||
"error_writing_file": "Error al escribir el fichero {file:s}: {error:s}",
|
||||
"error_removing": "Error al eliminar {path:s}: {error:s}",
|
||||
"error_changing_file_permissions": "Error al cambiar los permisos para {path:s}: {error:s}",
|
||||
"invalid_url": "Url no válida {url:s} (¿existe este sitio web?)",
|
||||
"download_ssl_error": "Error SSL al conectar con {url:s}",
|
||||
"download_timeout": "{url:s} tardó demasiado en responder, me rindo.",
|
||||
"download_unknown_error": "Error al descargar datos desde {url:s} : {error:s}",
|
||||
"download_bad_status_code": "{url:s} devolvió el código de estado {code:s}",
|
||||
"command_unknown": "Comando '{command:s}' desconocido ?"
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"argument_required": "'{argument}' argumentua ezinbestekoa da",
|
||||
"logged_out": "Saioa amaituta",
|
||||
"password": "Pasahitza",
|
||||
"authentication_required": "Autentifikazioa behar da",
|
||||
"confirm": "{prompt} baieztatu",
|
||||
"edit_text_question": "{}. Testua editatu nahi al duzu? [yN]: ",
|
||||
"deprecated_command": "'{prog} {command}' zaharkitua dago eta etorkizunean kenduko da",
|
||||
"deprecated_command_alias": "'{prog} {old} zaharkitua dago eta etorkizunean kenduko da, erabili '{prog} {new}' haren ordez",
|
||||
"error": "Errorea:",
|
||||
"file_not_exist": "Fitxategia ez da existitzen: '{path}'",
|
||||
"error_changing_file_permissions": "Errorea {path}-i eragiten dioten baimenak aldatzean: {error}",
|
||||
"invalid_argument": "'{argument}' argumentua ez da egokia: {error}",
|
||||
"success": "Arrakasta!",
|
||||
"info": "Informazioa:",
|
||||
"logged_in": "Saioa hasita",
|
||||
"not_logged_in": "Ez duzu saiorik hasi",
|
||||
"operation_interrupted": "Eragiketa geldiarazi da",
|
||||
"unknown_group": "'{group}' taldea ezezaguna da",
|
||||
"unknown_user": "'{user}' erabiltzailea ezezaguna da",
|
||||
"cannot_write_file": "Ezinezkoa izan da {file} fitxategia idaztea (zergatia: {error})",
|
||||
"download_ssl_error": "SSL errorea {url}-(e)ra konektatzean",
|
||||
"corrupted_toml": "{ressource}-eko/go TOMLa kaltetuta dago (zergatia: {error})",
|
||||
"warn_the_user_about_waiting_lock": "YunoHosten beste komando bat ari da exekutatzen, horrek amaitu arte gaude zain",
|
||||
"warn_the_user_about_waiting_lock_again": "Zain...",
|
||||
"folder_exists": "Direktorioa existitzen da dagoeneko: '{path}'",
|
||||
"instance_already_running": "YunoHosten eragiketa bat exekutatzen ari da dagoeneko. Itxaron amaitu arte beste eragiketa bat abiarazi baino lehen.",
|
||||
"invalid_usage": "Erabilera okerra, idatzi --help aukerak ikusteko",
|
||||
"pattern_not_match": "Ez dator ereduarekin bat",
|
||||
"root_required": "Ezinbestekoa da 'root' izatea eragiketa hau exekutatzeko",
|
||||
"server_already_running": "Zerbitzari bat martxan dago dagoeneko ataka horretan",
|
||||
"unable_authenticate": "Ezin da autentifikatu",
|
||||
"values_mismatch": "Balioak ez datoz bat",
|
||||
"warning": "Adi:",
|
||||
"cannot_open_file": "Ezinezkoa izan da {file} fitxategia irekitzea (zergatia: {error})",
|
||||
"corrupted_json": "{ressource}-eko/go JSONa kaltetuta dago (zergatia: {error})",
|
||||
"corrupted_yaml": "{ressource}-eko/go YAMLa kaltetuta dago (zergatia: {error})",
|
||||
"websocket_request_expected": "WebSocket eskaera bat espero zen",
|
||||
"unknown_error_reading_file": "Errore ezezaguna {file} fitxategia irakurtzen saiatzerakoan (zergatia: {error})",
|
||||
"download_unknown_error": "Errorea {url}(e)tik deskargatzerakoan: {error}",
|
||||
"warn_the_user_that_lock_is_acquired": "Aurreko komandoa amaitu berri, orain komando hau abiarazten",
|
||||
"error_writing_file": "Errorea {file} fitxategia idazterakoan: {error}",
|
||||
"error_removing": "Errorea {path} ezabatzerakoan: {error}",
|
||||
"download_bad_status_code": "{url} helbideak {code} egoera kodea agertu du",
|
||||
"invalid_url": "{url}-(e)ra konektatzeak huts egin du... agian zerbitzua ez dago martxan, edo ez zaude IPv4/IPv6 bidez ondo konektatuta internetera.",
|
||||
"download_timeout": "{url}(e)k denbora gehiegi behar izan du erantzuteko, bertan behera utzi du zerbitzariak."
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"logged_in": "وارد شده",
|
||||
"invalid_usage": "استفاده نامعتبر ، برای مشاهده راهنما --help را ارسال کنید",
|
||||
"invalid_argument": "استدلال نامعتبر '{argument}': {error}",
|
||||
"instance_already_running": "در حال حاضر یک عملیات YunoHost در حال اجرا است. لطفاً قبل از اجرای یکی دیگر ، منتظر بمانید تا آن به پایان برسد.",
|
||||
"info": "اطلاعات:",
|
||||
"folder_exists": "پوشه موجود است: '{path}'",
|
||||
"file_not_exist": "فایل وجود ندارد: '{path}'",
|
||||
"error": "ایراد:",
|
||||
"deprecated_command_alias": "'{prog} {old}' منسوخ شده است و در آینده حذف خواهد شد ، بجای آن از '{prog} {new}' استفاده کنید",
|
||||
"deprecated_command": "'{prog} {command}' منسوخ شده است و در آینده حذف خواهد شد",
|
||||
"confirm": "تایید کردن {prompt}",
|
||||
"authentication_required": "احراز هویّت الزامی است",
|
||||
"argument_required": "استدلال '{argument}' ضروری است",
|
||||
"password": "کلمه عبور",
|
||||
"warn_the_user_that_lock_is_acquired": "فرمان دیگر به تازگی تکمیل شده است ، اکنون این دستور را شروع کنید",
|
||||
"warn_the_user_about_waiting_lock_again": "هنوز در انتظار…",
|
||||
"warn_the_user_about_waiting_lock": "یکی دیگر از دستورات YunoHost در حال اجرا است ، ما منتظر هستیم تا قبل از اجرای این دستور به پایان برسد",
|
||||
"download_bad_status_code": "{url} کد وضعیّت بازگشتی {code}",
|
||||
"download_unknown_error": "خطا هنگام بارگیری داده ها از {url}: {error}",
|
||||
"download_timeout": "پاسخ {url} خیلی طول کشید ، منصرف شو.",
|
||||
"download_ssl_error": "خطای SSL هنگام اتصال به {url}",
|
||||
"invalid_url": "اتصال به {url} انجام نشد … شاید سرویس خاموش باشد یا در IPv4/IPv6 به درستی به اینترنت متصل نشده باشید.",
|
||||
"error_changing_file_permissions": "خطا هنگام تغییر مجوزهای {path}: {error}",
|
||||
"error_removing": "خطا هنگام حذف {path}: {error}",
|
||||
"error_writing_file": "خطا هنگام نوشتن فایل {file}: {error}",
|
||||
"corrupted_toml": "TOML خراب از {ressource} (دلیل: {error})",
|
||||
"corrupted_yaml": "YAML خراب از {ressource} (دلیل: {error})",
|
||||
"corrupted_json": "جی سان خراب شده از {ressource} میخواند (دلیل: {error})",
|
||||
"unknown_error_reading_file": "خطای ناشناخته هنگام تلاش برای خواندن فایل {file} (دلیل: {error})",
|
||||
"cannot_write_file": "نمی توان فایل {file} را نوشت (دلیل: {error})",
|
||||
"cannot_open_file": "فایل {file} باز نشد (دلیل: {error})",
|
||||
"websocket_request_expected": "در انتظار درخواست وب سوکت",
|
||||
"warning": "هشدار:",
|
||||
"values_mismatch": "مقدار ها مطابقت ندارند",
|
||||
"unknown_user": "کاربر'{user}' ناشناخته",
|
||||
"unknown_group": "گروه '{group}' ناشناخته",
|
||||
"unable_authenticate": "احراز هویّت امکان پذیر نیست",
|
||||
"success": "موفقیّت!",
|
||||
"server_already_running": "در حال حاضر یک سرور روی آن پورت کار می کند",
|
||||
"root_required": "برای انجام این عمل باید کاربر ریشه باشید",
|
||||
"pattern_not_match": "با الگو مطابقت ندارد",
|
||||
"operation_interrupted": "عملیات قطع شده است",
|
||||
"not_logged_in": "شما وارد نشده اید",
|
||||
"logged_out": "خارج شده"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"password": "Salasana",
|
||||
"logged_out": "Kirjauduttu ulos"
|
||||
}
|
|
@ -1,47 +1,54 @@
|
|||
{
|
||||
"argument_required": "L'argument '{argument}' est requis",
|
||||
"argument_required": "L'argument « {argument} » est requis",
|
||||
"authentication_profile_required": "L’authentification au profil « {profile} » requise",
|
||||
"authentication_required": "Authentification requise",
|
||||
"confirm": "Confirmez {prompt}",
|
||||
"deprecated_command": "'{prog} {command}' est déprécié et sera bientôt supprimé",
|
||||
"deprecated_command_alias": "'{prog} {old}' est déprécié et sera bientôt supprimé, utilisez '{prog} {new}' à la place",
|
||||
"error": "Erreur :",
|
||||
"file_not_exist": "Le fichier '{path}' n'existe pas",
|
||||
"folder_exists": "Le dossier existe déjà : '{path}'",
|
||||
"instance_already_running": "Une instance est déjà en cours d'exécution, merci d'attendre sa fin avant d'en lancer une autre.",
|
||||
"invalid_argument": "Argument '{argument}' incorrect : {error}",
|
||||
"authentication_required_long": "L’authentification est requise pour exécuter cette action",
|
||||
"colon": "{} : ",
|
||||
"confirm": "Confirmez : {prompt}",
|
||||
"deprecated_command": "« {prog} {command} » est déprécié et sera bientôt supprimé",
|
||||
"deprecated_command_alias": "« {prog} {old} » est déprécié et sera bientôt supprimé, utilisez « {prog} {new} » à la place",
|
||||
"error": "Erreur :",
|
||||
"error_see_log": "Une erreur est survenue. Veuillez consulter les journaux pour plus de détails, ils sont situés en /var/log/yunohost/.",
|
||||
"file_exists": "Le fichier existe déjà : « {path} »",
|
||||
"file_not_exist": "Le fichier « {path} » n'existe pas",
|
||||
"folder_exists": "Le dossier existe déjà : « {path} »",
|
||||
"folder_not_exist": "Le dossier n'existe pas",
|
||||
"instance_already_running": "Une instance est déjà en cours d'exécution",
|
||||
"invalid_argument": "Argument « {argument} » incorrect : {error}",
|
||||
"invalid_password": "Mot de passe incorrect",
|
||||
"invalid_usage": "Utilisation erronée, utilisez --help pour accéder à l'aide",
|
||||
"ldap_attribute_already_exists": "L'attribut « {attribute} » existe déjà avec comme valeur : {value}",
|
||||
"ldap_operation_error": "Une erreur est survenue lors de l'opération LDAP",
|
||||
"ldap_server_down": "Impossible d'atteindre le serveur LDAP",
|
||||
"logged_in": "Connecté",
|
||||
"logged_out": "Déconnecté",
|
||||
"not_logged_in": "Vous n'êtes pas connecté",
|
||||
"operation_interrupted": "Opération interrompue",
|
||||
"password": "Mot de passe",
|
||||
"pattern_not_match": "Ne correspond pas au motif",
|
||||
"root_required": "Vous devez avoir les droits d'administration pour exécuter cette action",
|
||||
"permission_denied": "Permission refusée",
|
||||
"root_required": "Vous devez être super-utilisateur pour exécuter cette action",
|
||||
"server_already_running": "Un serveur est déjà en cours d'exécution sur ce port",
|
||||
"success": "Succès !",
|
||||
"success": "Succès !",
|
||||
"unable_authenticate": "Impossible de vous authentifier",
|
||||
"unknown_group": "Le groupe '{group}' est inconnu",
|
||||
"unknown_user": "Le compte '{user}' est inconnu",
|
||||
"unable_retrieve_session": "Impossible de récupérer la session",
|
||||
"unknown_group": "Groupe « {group} » inconnu",
|
||||
"unknown_user": "Utilisateur « {user} » inconnu",
|
||||
"values_mismatch": "Les valeurs ne correspondent pas",
|
||||
"warning": "Attention :",
|
||||
"websocket_request_expected": "Une requête WebSocket est attendue",
|
||||
"cannot_open_file": "Impossible d'ouvrir le fichier {file} (raison : {error})",
|
||||
"cannot_write_file": "Ne peut pas écrire le fichier {file} (raison : {error})",
|
||||
"unknown_error_reading_file": "Erreur inconnue en essayant de lire le fichier {file} (raison :{error})",
|
||||
"corrupted_json": "Fichier JSON corrompu en lecture depuis {ressource} (raison : {error})",
|
||||
"error_writing_file": "Erreur en écrivant le fichier {file} : {error}",
|
||||
"error_removing": "Erreur lors de la suppression {path} : {error}",
|
||||
"error_changing_file_permissions": "Erreur lors de la modification des autorisations pour {path} : {error}",
|
||||
"invalid_url": "Impossible de se connecter à {url}... peut-être que le service est en panne ou que vous n'êtes pas correctement connecté à Internet en IPv4/IPv6.",
|
||||
"download_ssl_error": "Erreur SSL lors de la connexion à {url}",
|
||||
"download_timeout": "{url} a pris trop de temps pour répondre : abandon.",
|
||||
"download_unknown_error": "Erreur lors du téléchargement des données à partir de {url} : {error}",
|
||||
"download_bad_status_code": "{url} renvoie le code d'état {code}",
|
||||
"corrupted_yaml": "Fichier YAML corrompu en lecture depuis {ressource} (raison : {error})",
|
||||
"info": "Info :",
|
||||
"corrupted_toml": "Fichier TOML corrompu en lecture depuis {ressource} (raison : {error})",
|
||||
"warn_the_user_about_waiting_lock": "Une autre commande YunoHost est actuellement en cours, nous attendons qu'elle se termine avant de démarrer celle là",
|
||||
"warn_the_user_about_waiting_lock_again": "Toujours en attente...",
|
||||
"warn_the_user_that_lock_is_acquired": "La commande précédente vient de se terminer, lancement de cette nouvelle commande",
|
||||
"edit_text_question": "{}. Modifier ce texte ? [yN] : "
|
||||
"warning": "Attention :",
|
||||
"websocket_request_expected": "Requête WebSocket attendue",
|
||||
"cannot_open_file": "Impossible d'ouvrir le fichier {file:s} (cause : {error:s})",
|
||||
"cannot_write_file": "Ne peut pas écrire le fichier {file:s} (cause : {error:s})",
|
||||
"unknown_error_reading_file": "Erreur inconnue en essayant de lire le fichier {file:s}",
|
||||
"corrupted_json": "Json corrompu lu depuis {ressource:s} (cause : {error:s})",
|
||||
"error_writing_file": "Erreur en écrivant le fichier {file:s}:{error:s}",
|
||||
"error_removing": "Erreur lors de la suppression {path:s}:{error:s}",
|
||||
"error_changing_file_permissions": "Erreur lors de la modification des autorisations pour {path:s}:{error:s}",
|
||||
"invalid_url": "Url invalide {url:s} (ce site existe-t-il ?)",
|
||||
"download_ssl_error": "Erreur SSL lors de la connexion à {url:s}",
|
||||
"download_timeout": "{url:s} a pris trop de temps pour répondre, abandon.",
|
||||
"download_unknown_error": "Erreur lors du téléchargement des données à partir de {url:s}:{error:s}",
|
||||
"download_bad_status_code": "{url:s} code de statut renvoyé {code:s}",
|
||||
"command_unknown": "Commande '{command:s}' inconnue ?",
|
||||
"corrupted_yaml": "YAML corrompu lu {ressource:s} depuis (cause : {error:s})"
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"invalid_usage": "Uso non válido, pass --help para ver a axuda",
|
||||
"invalid_argument": "Argumento non válido '{argument}': {error}",
|
||||
"instance_already_running": "Hai unha operación de YunoHost en execución. Por favor agarda a que remate antes de realizar unha nova.",
|
||||
"info": "Info:",
|
||||
"folder_exists": "Xa existe o cartafol: '{path}'",
|
||||
"file_not_exist": "Non existe o ficheiro: '{path}'",
|
||||
"error": "Erro:",
|
||||
"deprecated_command_alias": "'{prog} {old}' xa non se utiliza e será eliminado no futuro, usa '{prog} {new}' no seu lugar",
|
||||
"deprecated_command": "'{prog} {command}' xa non se utiliza e xa non se usará no futuro",
|
||||
"confirm": "Confirma {prompt}",
|
||||
"authentication_required": "Autenticación requerida",
|
||||
"argument_required": "O argumento '{argument}' é requerido",
|
||||
"logged_out": "Sesión pechada",
|
||||
"password": "Contrasinal",
|
||||
"warning": "Aviso:",
|
||||
"values_mismatch": "Non concordan os valores",
|
||||
"unknown_user": "Usuaria '{user}' descoñecida",
|
||||
"unknown_group": "Grupo '{group}' descoñecido",
|
||||
"unable_authenticate": "Non se puido autenticar",
|
||||
"success": "Ben feito!",
|
||||
"server_already_running": "Xa hai un servidor a funcionar nese porto",
|
||||
"root_required": "Tes que ser root para facer esta acción",
|
||||
"pattern_not_match": "Non concorda co patrón",
|
||||
"operation_interrupted": "Interrumpeuse a operación",
|
||||
"not_logged_in": "Non iniciaches sesión",
|
||||
"logged_in": "Sesión iniciada",
|
||||
"warn_the_user_that_lock_is_acquired": "O outro comando rematou, agora executarase este",
|
||||
"warn_the_user_about_waiting_lock_again": "Agardando…",
|
||||
"warn_the_user_about_waiting_lock": "Estase executando outro comando de YunoHost neste intre, estamos agardando a que remate para executar este",
|
||||
"download_bad_status_code": "{url} devolveu o código de estado {code}",
|
||||
"download_unknown_error": "Erro ao descargar os datos desde {url}: {error}",
|
||||
"download_timeout": "{url} está tardando en responder, deixámolo.",
|
||||
"download_ssl_error": "Erro SSL ao conectar con {url}",
|
||||
"invalid_url": "Fallou a conexión con {url}... pode que o servizo estea caído, ou que non teñas conexión a Internet con IPv4/IPv6.",
|
||||
"error_changing_file_permissions": "Erro ao cambiar os permisos de {path}: {error}",
|
||||
"error_removing": "Erro ao eliminar {path}: {error}",
|
||||
"error_writing_file": "Erro ao escribir o ficheiro {file}: {error}",
|
||||
"corrupted_toml": "Lectura corrupta de datos TOML de {ressource} (razón: {error})",
|
||||
"corrupted_yaml": "Lectura corrupta dos datos YAML de {ressource} (razón: {error})",
|
||||
"corrupted_json": "Lectura corrupta dos datos JSON de {ressource} (razón: {error})",
|
||||
"unknown_error_reading_file": "Erro descoñecido ao intentar ler o ficheiro {file} (razón: {error})",
|
||||
"cannot_write_file": "Non se puido escribir o ficheiro {file} (razón: {error})",
|
||||
"cannot_open_file": "Non se puido abrir o ficheiro {file} (razón: {error})",
|
||||
"websocket_request_expected": "Agardábase unha solicitude WebSocket",
|
||||
"edit_text_question": "{}. Editar este texto ? [yN]: "
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,29 +1,40 @@
|
|||
{
|
||||
"argument_required": "तर्क '{argument}' आवश्यक है",
|
||||
"authentication_profile_required": "{profile} प्रोफ़ाइल के लिए प्रमाणीकरण की आवश्यकता है",
|
||||
"authentication_required": "प्रमाणीकरण आवश्यक",
|
||||
"authentication_required_long": "इस कार्य को करने के लिए प्रमाणीकरण आवश्यक है",
|
||||
"colon": "{}: ",
|
||||
"confirm": "पुष्टि करें {prompt}",
|
||||
"deprecated_command": "'{prog}' '{command}' का प्रयोग न करे, भविष्य में इसे हटा दिया जाएगा",
|
||||
"deprecated_command_alias": "'{prog} {old}' अब पुराना हो गया है और इसे भविष्य में हटा दिया जाएगा, इस की जगह '{prog} {new}' का प्रयोग करें",
|
||||
"deprecated_command_alias": "'{prog} {old}' का प्रयोग न करे ,भविष्य में इसे हटा दिया जाएगा।इस की जगह '{prog} {new}' का प्रोयोग करे।",
|
||||
"error": "गलती:",
|
||||
"error_see_log": "एक त्रुटि पाई गई। कृपया विवरण के लिए लॉग देखें।",
|
||||
"file_exists": "फ़ाइल पहले से ही मौजूद है:'{path}'",
|
||||
"file_not_exist": "फ़ाइल मौजूद नहीं है: '{path}'",
|
||||
"folder_exists": "फ़ोल्डर में पहले से ही मौजूद है: '{path}'",
|
||||
"instance_already_running": "यूनोहोस्ट का एक कार्य पहले से चल रहा है। कृपया इस कार्य के समाप्त होने का इंतज़ार करें।",
|
||||
"folder_not_exist": "फ़ोल्डर मौजूद नहीं है।",
|
||||
"instance_already_running": "आवृत्ति पहले से चल रही है।",
|
||||
"invalid_argument": "अवैध तर्क '{argument}':'{error}'",
|
||||
"invalid_password": "अवैध पासवर्ड",
|
||||
"invalid_usage": "अवैध उपयोग, सहायता देखने के लिए --help साथ लिखे।",
|
||||
"ldap_attribute_already_exists": "'{attribute}' तर्क पहले इस वैल्यू '{value}' से मौजूद है।",
|
||||
"ldap_operation_error": "LDAP ऑपरेशन के दौरान त्रुटि हो गई है।",
|
||||
"ldap_server_down": "LDAP सर्वर तक पहुंचने में असमर्थ।",
|
||||
"logged_in": "लोग्ड इन",
|
||||
"logged_out": "लॉग आउट",
|
||||
"not_logged_in": "आप लोग्ड इन नहीं हैं।",
|
||||
"operation_interrupted": "कार्य बाधित",
|
||||
"password": "पासवर्ड",
|
||||
"pattern_not_match": "पैटर्न मेल नहीं खता है।",
|
||||
"permission_denied": "अनुमति से इनकार।",
|
||||
"root_required": "इस कार्य को करने के लिए ,आप का root होना आवक्षक है।",
|
||||
"server_already_running": "कोई सर्वर पहले से ही इस पोर्ट पर चल रहा है।",
|
||||
"success": "सफलता!",
|
||||
"unable_authenticate": "प्रमाणित करने में असमर्थ।",
|
||||
"unable_retrieve_session": "सेशन को प्राप्त करने में असमर्थ।",
|
||||
"unknown_group": "अज्ञात ग्रुप: '{group}'",
|
||||
"unknown_user": "अज्ञात उपयोगकर्ता: '{user}'",
|
||||
"values_mismatch": "वैल्यूज मेल नहीं खाती।",
|
||||
"warning": "चेतावनी:",
|
||||
"websocket_request_expected": "एक WebSocket अनुरोध की उम्मीद।",
|
||||
"info": "सूचना:"
|
||||
"websocket_request_expected": "एक WebSocket अनुरोध की उम्मीद।"
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"logged_out": "Kilépett",
|
||||
"password": "Jelszó",
|
||||
"download_timeout": "{url} régóta nem válaszol, folyamat megszakítva.",
|
||||
"invalid_url": "Helytelen URL: {url} (biztos létezik az oldal?)",
|
||||
"cannot_open_file": "{file} megnyitása sikertelen (Oka: {error})",
|
||||
"unknown_user": "Ismeretlen felhasználó: '{user}'",
|
||||
"unknown_group": "Ismeretlen csoport: '{group}'",
|
||||
"server_already_running": "Egy szerver már fut ezen a porton",
|
||||
"logged_in": "Bejelentkezve",
|
||||
"success": "Siker!",
|
||||
"values_mismatch": "Eltérő értékek",
|
||||
"warning": "Figyelem:",
|
||||
"info": "Információ:",
|
||||
"file_not_exist": "A fájl nem létezik: '{path}'",
|
||||
"error": "Hiba:"
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"argument_required": "Argumen '{argument}' dibutuhkan",
|
||||
"authentication_required": "Autentikasi dibutuhkan",
|
||||
"deprecated_command": "'{prog} {command}' sudah usang dan akan dihapus nanti",
|
||||
"logged_out": "Berhasil keluar",
|
||||
"password": "Kata sandi",
|
||||
"deprecated_command_alias": "'{prog} {old}' sudah usang dan akan dihapus nanti, gunakan '{prog} {new}'",
|
||||
"info": "Informasi:",
|
||||
"instance_already_running": "Sudah ada tindakan YunoHost yang sedang berjalan. Tunggu itu selesai sebelum menjalankan yang lain.",
|
||||
"logged_in": "Berhasil masuk",
|
||||
"warning": "Peringatan:",
|
||||
"cannot_open_file": "Tidak dapat membuka berkas {file} (alasan: {error})",
|
||||
"error_removing": "Terjadi galat ketika menghapus {path}: {error}",
|
||||
"success": "Berhasil!",
|
||||
"warn_the_user_about_waiting_lock": "Perintah YunoHost lain sedang berjalan saat ini, kami sedang menunggu itu selesai sebelum menjalankan yang ini",
|
||||
"warn_the_user_about_waiting_lock_again": "Masih menunggu...",
|
||||
"unable_authenticate": "Tidak dapat mengautentikasi",
|
||||
"warn_the_user_that_lock_is_acquired": "Perintah yang tadi baru saja selesai, akan memulai perintah ini",
|
||||
"server_already_running": "Sebuah peladen telah berjalan di porta tersebut",
|
||||
"unknown_group": "Kelompok '{group}' tidak diketahui",
|
||||
"unknown_user": "Pengguna '{user}' tidak diketahui",
|
||||
"values_mismatch": "Nnilai berbeda",
|
||||
"cannot_write_file": "Tidak dapat menyimpan berkas {file} (alasan: {error})",
|
||||
"unknown_error_reading_file": "Galat yang tidak diketahui ketika membaca berkas {file} (alasan: {error})",
|
||||
"invalid_url": "Gagal terhubung dengan {url}... mungkin layanan tersebut sedang turun, atau Anda tidak terhubung dengan benar ke internet di IPv4/IPv6.",
|
||||
"download_timeout": "{url} memakan waktu yang lama untuk menjawab, menyerah.",
|
||||
"download_unknown_error": "Galat ketika mengunduh data dari {url}: {error}",
|
||||
"download_bad_status_code": "{url} menjawab dengan kode status {code}",
|
||||
"confirm": "Konfirmasi {prompt}",
|
||||
"edit_text_question": "{}. Sunting teks ini ? [yN]: ",
|
||||
"error": "Galat:",
|
||||
"file_not_exist": "Berkas tidak ada: '{path}'",
|
||||
"folder_exists": "Berkas sudah ada: '{path}'",
|
||||
"invalid_argument": "Argumen tidak valid '{argument}': {error}",
|
||||
"invalid_usage": "Tidak valid, ikutkan --help untuk melihat bantuan",
|
||||
"not_logged_in": "Anda belum masuk",
|
||||
"operation_interrupted": "Tindakan terganggu",
|
||||
"error_writing_file": "Galat ketika menyimpan berkas {file}: {error}",
|
||||
"error_changing_file_permissions": "Galat ketika mengubah izin untuk {path}: {error}",
|
||||
"download_ssl_error": "Galat SSL ketika menghubungi {url}",
|
||||
"pattern_not_match": "Tidak cocok dengan pola",
|
||||
"root_required": "Anda harus berada di root untuk melakukan tindakan ini",
|
||||
"corrupted_yaml": "Pembacaan rusak untuk YAML {ressource} (alasan: {error})",
|
||||
"corrupted_toml": "Pembacaan rusak untuk TOML {ressource} (alasan: {error})",
|
||||
"corrupted_json": "Pembacaan rusak untuk JSON {ressource} (alasan: {error})",
|
||||
"websocket_request_expected": "Mengharapkan permintaan WebSocket"
|
||||
}
|
|
@ -2,46 +2,53 @@
|
|||
"logged_out": "Disconnesso",
|
||||
"password": "Password",
|
||||
"argument_required": "L'argomento '{argument}' è richiesto",
|
||||
"authentication_profile_required": "Autenticazione al profilo '{profile}' richiesta",
|
||||
"authentication_required": "Autenticazione richiesta",
|
||||
"authentication_required_long": "Autenticazione richiesta per eseguire questa azione",
|
||||
"colon": "{}: ",
|
||||
"confirm": "Confermare {prompt}",
|
||||
"deprecated_command": "'{prog} {command}' è deprecato e sarà rimosso in futuro",
|
||||
"deprecated_command_alias": "'{prog} {old}' è deprecato e sarà rimosso in futuro, usa invece '{prog} {new}'",
|
||||
"error": "Errore:",
|
||||
"error_see_log": "Si è verificato un errore. Per favore controlla i registri per i dettagli, sono salvati in /var/log/yunohost/.",
|
||||
"file_exists": "Il file esiste già: '{path}'",
|
||||
"file_not_exist": "Il file non esiste: '{path}'",
|
||||
"folder_exists": "La cartella esiste già: '{path}'",
|
||||
"instance_already_running": "Esiste già un'operazione YunoHost in esecuzione. Attendi il completamento prima di eseguirne un altro.",
|
||||
"folder_not_exist": "La cartella non esiste",
|
||||
"instance_already_running": "Un'istanza è già in esecuzione",
|
||||
"invalid_argument": "Argomento non valido '{argument}': {error}",
|
||||
"invalid_password": "Password non valida",
|
||||
"invalid_usage": "Utilizzo non valido, usa --help per vedere l'aiuto",
|
||||
"ldap_attribute_already_exists": "L'attributo '{attribute}' esiste già con valore '{value}'",
|
||||
"ldap_operation_error": "Si è verificato un errore durante l'operazione LDAP",
|
||||
"ldap_server_down": "Impossibile raggiungere il server LDAP",
|
||||
"logged_in": "Connesso",
|
||||
"not_logged_in": "Non hai effettuato l'accesso",
|
||||
"operation_interrupted": "Operazione interrotta",
|
||||
"pattern_not_match": "Non corrisponde al modello",
|
||||
"permission_denied": "Permesso negato",
|
||||
"root_required": "Devi essere root per eseguire questa azione",
|
||||
"server_already_running": "Un server è già in esecuzione su quella porta",
|
||||
"success": "Riuscito!",
|
||||
"unable_authenticate": "Autenticazione fallita",
|
||||
"unable_retrieve_session": "Recupero della sessione non riuscito",
|
||||
"unknown_group": "Gruppo '{group}' sconosciuto",
|
||||
"unknown_user": "Utente '{user}' sconosciuto",
|
||||
"values_mismatch": "I valori non corrispondono",
|
||||
"warning": "Attenzione:",
|
||||
"websocket_request_expected": "Richiesta WebSocket attesa",
|
||||
"cannot_open_file": "Impossibile aprire il file {file} (motivo: {error})",
|
||||
"cannot_write_file": "Impossibile scrivere il file {file} (motivo: {error})",
|
||||
"unknown_error_reading_file": "Errore sconosciuto durante il tentativo di leggere il file {file} (motivo: {error})",
|
||||
"corrupted_json": "Lettura JSON corrotta da {ressource} (motivo: {error})",
|
||||
"corrupted_yaml": "Lettura YAML corrotta da {ressource} (motivo: {error})",
|
||||
"error_writing_file": "Errore durante la scrittura del file {file}: {error}",
|
||||
"error_removing": "Errore durante la rimozione {path}: {error}",
|
||||
"error_changing_file_permissions": "Errore durante il cambio di permessi per {path}: {error}",
|
||||
"invalid_url": "Fallita connessione a {url}… magari il servizio è down, o non sei connesso correttamente ad internet con IPv4/IPv6.",
|
||||
"download_ssl_error": "Errore SSL durante la connessione a {url}",
|
||||
"download_timeout": "{url} ci ha messo troppo a rispondere, abbandonato.",
|
||||
"download_unknown_error": "Errore durante il download di dati da {url} : {error}",
|
||||
"download_bad_status_code": "{url} ha restituito il codice di stato {code}",
|
||||
"info": "Info:",
|
||||
"warn_the_user_that_lock_is_acquired": "L'altro comando è appena completato, ora avvio questo comando",
|
||||
"warn_the_user_about_waiting_lock_again": "Sto ancora aspettando…",
|
||||
"warn_the_user_about_waiting_lock": "Un altro comando YunoHost è in esecuzione in questo momento, stiamo aspettando che finisca prima di eseguire questo",
|
||||
"corrupted_toml": "TOML corrotto da {ressource} (motivo: {error})",
|
||||
"edit_text_question": "{}. Modificare il testo? [yN]: "
|
||||
"cannot_open_file": "Impossibile aprire il file {file:s} (motivo: {error:s})",
|
||||
"cannot_write_file": "Impossibile scrivere il file {file:s} (motivo: {error:s})",
|
||||
"unknown_error_reading_file": "Errore sconosciuto nel tentativo di leggere il file {file:s}",
|
||||
"corrupted_json": "Lettura json corrotta da {ressource:s} (motivo: {error:s})",
|
||||
"corrupted_yaml": "Lettura yaml corrotta da {ressource:s} (motivo: {error:s})",
|
||||
"error_writing_file": "Errore durante la scrittura del file {file:s}: {error:s}",
|
||||
"error_removing": "Errore durante la rimozione {path:s}: {error:s}",
|
||||
"error_changing_file_permissions": "Errore durante il cambio di permessi per {path:s}: {error:s}",
|
||||
"invalid_url": "URL non valido {url:s} (questo sito esiste?)",
|
||||
"download_ssl_error": "Errore SSL durante la connessione a {url:s}",
|
||||
"download_timeout": "{url:s} ci ha messo troppo a rispondere, abbandonato.",
|
||||
"download_unknown_error": "Errore durante il download di dati da {url:s} : {error:s}",
|
||||
"download_bad_status_code": "{url:s} ha restituito il codice di stato {code:s}",
|
||||
"command_unknown": "Comando '{command:s}' sconosciuto ?"
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"logged_out": "ログアウトしました",
|
||||
"password": "パスワード",
|
||||
"argument_required": "引数 '{argument}' が必要です",
|
||||
"authentication_required": "認証が必要",
|
||||
"confirm": "{prompt}の確認",
|
||||
"deprecated_command": "'{prog} {command}' は非推奨であり、将来削除される予定です",
|
||||
"deprecated_command_alias": "'{prog} {old}' は非推奨であり、今後削除される予定です。代わりに '{prog} {new}' を使用してください",
|
||||
"edit_text_question": "{}.このテキストを編集しますか?[yN]: ",
|
||||
"error": "エラー:",
|
||||
"info": "インフォメーション:",
|
||||
"download_unknown_error": "{url}からデータをダウンロードする際のエラー:{error}",
|
||||
"download_bad_status_code": "{url}は状態コード {code} を返しました",
|
||||
"warn_the_user_about_waiting_lock": "別のYunoHostコマンドが現在実行されているため、完了するのを待っています",
|
||||
"warn_the_user_about_waiting_lock_again": "まだ待っています…",
|
||||
"warn_the_user_that_lock_is_acquired": "他のコマンドが完了しました。このコマンドが開始されました",
|
||||
"file_not_exist": "ファイルが存在しません: '{path}'",
|
||||
"folder_exists": "フォルダは既に存在します: '{path}'",
|
||||
"instance_already_running": "YunoHost 操作が既に実行されています。他の操作が完了するのを待ってください。",
|
||||
"invalid_argument": "無効な引数 '{argument}': {error}",
|
||||
"invalid_usage": "無効な使用法です。--help を渡してヘルプを表示します",
|
||||
"logged_in": "ログイン済み",
|
||||
"not_logged_in": "ログインしていません",
|
||||
"operation_interrupted": "操作が中断されました",
|
||||
"pattern_not_match": "パターンと一致しない",
|
||||
"root_required": "このアクションを実行するには、rootである必要があります",
|
||||
"server_already_running": "サーバーはそのポートで既に実行されています",
|
||||
"success": "成功!",
|
||||
"unable_authenticate": "認証できません",
|
||||
"unknown_group": "不明な '{group}' グループ",
|
||||
"unknown_user": "不明な '{user}' ユーザー",
|
||||
"values_mismatch": "値が一致しない",
|
||||
"warning": "警告:",
|
||||
"websocket_request_expected": "WebSocket 要求が必要です",
|
||||
"cannot_open_file": "ファイル{file}を開けませんでした(理由:{error})",
|
||||
"cannot_write_file": "ファイル {file}を書き込めませんでした (理由: {error})",
|
||||
"unknown_error_reading_file": "ファイル{file}を読み取ろうとしているときに不明なエラーが発生しました(理由:{error})",
|
||||
"corrupted_json": "{ressource}から読み取られたJSONは破損していました(理由:{error})",
|
||||
"corrupted_yaml": "破損した YAML が{ressource}から読み取られました (理由: {error})",
|
||||
"corrupted_toml": "破損した TOML が{ressource}から読み取られました (理由: {error})",
|
||||
"error_writing_file": "ファイル{file}書き込み時のエラー:{error}",
|
||||
"error_removing": "{path}を削除するときのエラー:{error}",
|
||||
"error_changing_file_permissions": "{path}のアクセス許可変更時のエラー: {error}",
|
||||
"invalid_url": "{url}に接続できませんでした…サービスがダウンしているか、IPv4 / IPv6でインターネットに正しく接続されていない可能性があります。",
|
||||
"download_ssl_error": "{url}への接続時のSSLエラー",
|
||||
"download_timeout": "{url}は応答に時間がかかりすぎたため、あきらめました。"
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"error": "Erreur :",
|
||||
"success": "Akka d rrbeḥ !",
|
||||
"password": "Awal n uɛeddi",
|
||||
"logged_in": "Taqqneḍ",
|
||||
"logged_out": "Yeffeɣ",
|
||||
"authentication_required": "Tlaq tuqqna"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"argument_required": "Argumentet '{argument}' er påkrevd",
|
||||
"warn_the_user_about_waiting_lock_again": "Venter fremdeles…",
|
||||
"websocket_request_expected": "Forventet en WebSocket-forespørsel",
|
||||
"warning": "Advarsel:",
|
||||
"values_mismatch": "Verdiene samsvarer ikke",
|
||||
"unknown_user": "Ukjent '{user}' bruker",
|
||||
"unknown_group": "Ukjent '{group}' gruppe",
|
||||
"unable_authenticate": "Kunne ikke identitetsbekrefte",
|
||||
"success": "Vellykket!",
|
||||
"operation_interrupted": "Operasjon forstyrret",
|
||||
"not_logged_in": "Du er ikke innlogget",
|
||||
"logged_in": "Innlogget",
|
||||
"info": "Info:",
|
||||
"error": "Feil:",
|
||||
"confirm": "Bekreft {prompt}",
|
||||
"logged_out": "Utlogget",
|
||||
"password": "Passord"
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"logged_out": "लग आउट",
|
||||
"password": "पासवर्ड",
|
||||
"deprecated_command_alias": "'{prog} {old}' अस्वीकृत गरिएको छ र भविष्यमा हटाइनेछ, यसको सट्टा '{prog} {new}' प्रयोग गर्नुहोस्।",
|
||||
"deprecated_command": "'{prog} {command}' अस्वीकृत गरिएको छ र भविष्यमा हटाइनेछ",
|
||||
"confirm": "कन्फर्म {prompt}",
|
||||
"authentication_required": "प्रमाणीकरण आवाश्यक छ",
|
||||
"argument_required": "तर्क '{argument}' आवश्यक छ"
|
||||
}
|
|
@ -1,23 +1,35 @@
|
|||
{
|
||||
"argument_required": "Argument {argument} is vereist",
|
||||
"authentication_profile_required": "Authenticatie tot profiel '{profile}' is vereist",
|
||||
"authentication_required": "Aanmelding vereist",
|
||||
"authentication_required_long": "Aanmelding is vereist om deze actie uit te voeren",
|
||||
"colon": "{}: ",
|
||||
"confirm": "Bevestig {prompt}",
|
||||
"error": "Fout:",
|
||||
"error_see_log": "Er is een fout opgetreden, zie logboek voor meer informatie. Je kan deze vinden in /var/log/yunohost/.",
|
||||
"file_exists": "Kan '{path}' niet aanmaken: bestand bestaat al",
|
||||
"file_not_exist": "Bestand bestaat niet: '{path}'",
|
||||
"folder_exists": "Deze map bestaat al: '{path}'",
|
||||
"instance_already_running": "Er is al een bewerking bezig. Even geduld tot deze afgesloten is, alvorens een andere te starten.",
|
||||
"folder_not_exist": "Map bestaat niet",
|
||||
"instance_already_running": "Er is al een instantie actief",
|
||||
"invalid_argument": "Ongeldig argument '{argument}': {error}",
|
||||
"invalid_password": "Ongeldig wachtwoord",
|
||||
"invalid_usage": "Ongeldig gebruik, doe --help om de hulptekst te lezen",
|
||||
"ldap_attribute_already_exists": "Attribuut '{attribute}' bestaat al met waarde '{value}'",
|
||||
"ldap_operation_error": "Er is een fout opgetreden bij het uitvoeren van LDAP operatie",
|
||||
"ldap_server_down": "Kan LDAP server niet bereiken",
|
||||
"logged_in": "Ingelogd",
|
||||
"logged_out": "Uitgelogd",
|
||||
"not_logged_in": "U bent niet ingelogd",
|
||||
"operation_interrupted": "Operatie onderbroken",
|
||||
"password": "Wachtwoord",
|
||||
"pattern_not_match": "Past niet in het patroon",
|
||||
"permission_denied": "Toegang geweigerd",
|
||||
"root_required": "Je moet root zijn om deze actie uit te voeren",
|
||||
"server_already_running": "Er is al een server actief op die poort",
|
||||
"success": "Succes!",
|
||||
"unable_authenticate": "Aanmelding niet mogelijk",
|
||||
"unable_retrieve_session": "Kan de sessie niet ophalen",
|
||||
"values_mismatch": "Waarden zijn niet gelijk",
|
||||
"warning": "Waarschuwing:",
|
||||
"websocket_request_expected": "Verwachtte een WebSocket request",
|
||||
|
@ -25,23 +37,17 @@
|
|||
"deprecated_command_alias": "'{prog} {old}' is verouderd en wordt binnenkort verwijderd, gebruik in de plaats '{prog} {new}'",
|
||||
"unknown_group": "Groep '{group}' is onbekend",
|
||||
"unknown_user": "Gebruiker '{user}' is onbekend",
|
||||
"cannot_open_file": "Niet mogelijk om bestand {file} te openen (reden: {error})",
|
||||
"cannot_write_file": "Niet gelukt om bestand {file} te schrijven (reden: {error})",
|
||||
"unknown_error_reading_file": "Ongekende fout tijdens het lezen van bestand {file} (cause:{error})",
|
||||
"corrupted_json": "Corrupte JSON gelezen van {ressource} (reden: {error})",
|
||||
"error_writing_file": "Fout tijdens het schrijven van bestand {file}: {error}",
|
||||
"error_removing": "Fout tijdens het verwijderen van {path}: {error}",
|
||||
"error_changing_file_permissions": "Fout tijdens het veranderen van machtiging voor {path}: {error}",
|
||||
"invalid_url": "Kon niet verbinden met {url}… misschien is de dienst uit de lucht, of ben je niet goed verbonden via IPv4 of IPv6.",
|
||||
"download_ssl_error": "SSL fout gedurende verbinding met {url}",
|
||||
"download_timeout": "{url} neemt te veel tijd om te antwoorden, we geven het op.",
|
||||
"download_unknown_error": "Fout tijdens het downloaden van data van {url}: {error}",
|
||||
"download_bad_status_code": "{url} stuurt status code {code}",
|
||||
"warn_the_user_that_lock_is_acquired": "De andere opdracht is zojuist voltooid; nu wordt nu deze opdracht gestart",
|
||||
"warn_the_user_about_waiting_lock_again": "Nog steeds aan het wachten…",
|
||||
"warn_the_user_about_waiting_lock": "Een ander YunoHost commando wordt uitgevoerd, we wachten tot het gedaan is alovrens dit te starten",
|
||||
"corrupted_toml": "Ongeldige TOML werd gelezen van {ressource} (reason: {error})",
|
||||
"corrupted_yaml": "Ongeldig YAML bestand op {ressource} (reden: {error})",
|
||||
"info": "Ter info:",
|
||||
"edit_text_question": "{}. Deze tekst bewerken ? [yN]: "
|
||||
"cannot_open_file": "Niet mogelijk om bestand {file:s} te openen (reden: {error:s})",
|
||||
"cannot_write_file": "Niet gelukt om bestand {file:s} te schrijven (reden: {error:s})",
|
||||
"unknown_error_reading_file": "Ongekende fout tijdens het lezen van bestand {file:s}",
|
||||
"corrupted_json": "Corrupte json gelezen van {ressource:s} (reden: {error:s})",
|
||||
"error_writing_file": "Fout tijdens het schrijven van bestand {file:s}: {error:s}",
|
||||
"error_removing": "Fout tijdens het verwijderen van {path:s}: {error:s}",
|
||||
"error_changing_file_permissions": "Fout tijdens het veranderen van machtiging voor {path:s}: {error:s}",
|
||||
"invalid_url": "Ongeldige URL {url:s} (bestaat deze website?)",
|
||||
"download_ssl_error": "SSL fout gedurende verbinding met {url:s}",
|
||||
"download_timeout": "{url:s} neemt te veel tijd om te antwoorden, we geven het op.",
|
||||
"download_unknown_error": "Fout tijdens het downloaden van data van {url:s}: {error:s}",
|
||||
"download_bad_status_code": "{url:s} stuurt status code {code:s}",
|
||||
"command_unknown": "Opdracht '{command:s}' ongekend ?"
|
||||
}
|
|
@ -1,47 +1,54 @@
|
|||
{
|
||||
"argument_required": "L’argument {argument} es requesit",
|
||||
"authentication_profile_required": "L’identificacion del perfil {profile} es requesida",
|
||||
"authentication_required": "Autentificacion requesida",
|
||||
"authentication_required_long": "Una autentificacion es requesida per acomplir aquesta accion",
|
||||
"logged_in": "Connectat",
|
||||
"logged_out": "Desconnectat",
|
||||
"password": "Senhal",
|
||||
"colon": "{}: ",
|
||||
"confirm": "Confirmatz : {prompt}",
|
||||
"deprecated_command": "« {prog} {command} » es despreciat e serà lèu suprimit",
|
||||
"deprecated_command_alias": "« {prog} {old} » es despreciat e serà lèu suprimit, utilizatz « {prog} {new} » allòc",
|
||||
"error": "Error :",
|
||||
"error_see_log": "Una error s’es producha. Mercés de consultar los jornals per mai detalhs, son plaçats dins /var/log/yunohost/.",
|
||||
"file_exists": "Lo fichièr existís ja : « {path} »",
|
||||
"file_not_exist": "Lo fichièr « {path} » existís pas",
|
||||
"folder_exists": "Lo repertòri existís ja : « {path} »",
|
||||
"instance_already_running": "I a ja una operacion de YunoHost en cors. Mercés d’esperar que s’acabe abans de ne lançar una mai.",
|
||||
"folder_not_exist": "Lo repertòri existís pas",
|
||||
"instance_already_running": "Una instància es ja en execucion",
|
||||
"invalid_argument": "Argument « {argument} » incorrècte : {error}",
|
||||
"invalid_password": "Senhal incorrècte",
|
||||
"ldap_server_down": "Impossible d’aténher lo servidor LDAP",
|
||||
"not_logged_in": "Cap de session començada",
|
||||
"pattern_not_match": "Correspond pas al patron",
|
||||
"permission_denied": "Permission refusada",
|
||||
"root_required": "Cal èsser root per realizar aquesta accion",
|
||||
"unable_retrieve_session": "Impossible de recuperar la session",
|
||||
"unknown_group": "Grop « {group} » desconegut",
|
||||
"unknown_user": "Utilizaire « {user} » desconegut",
|
||||
"values_mismatch": "Las valors correspondon pas",
|
||||
"warning": "Atencion :",
|
||||
"invalid_usage": "Usatge invalid, utilizatz --help per accedir a l’ajuda",
|
||||
"ldap_attribute_already_exists": "L’atribut « {attribute} » existís ja amb la valor : {value}",
|
||||
"ldap_operation_error": "Una error s’es producha pendent l’operacion LDAP",
|
||||
"operation_interrupted": "Operacion interrompuda",
|
||||
"server_already_running": "Un servidor es ja en execucion sus aqueste pòrt",
|
||||
"success": "Capitada !",
|
||||
"unable_authenticate": "Impossible de vos autentificar",
|
||||
"websocket_request_expected": "Una requèsta WebSocket èra esperada",
|
||||
"cannot_open_file": "Impossible de dobrir lo fichièr {file} (rason : {error})",
|
||||
"cannot_write_file": "Escritura impossibla del fichièr {file} (rason : {error})",
|
||||
"unknown_error_reading_file": "Error desconeguda en ensajar de legir lo fichièr {file} (rason : {error})",
|
||||
"error_writing_file": "Error en escriure lo fichièr {file} : {error}",
|
||||
"error_removing": "Error en suprimir {path} : {error}",
|
||||
"error_changing_file_permissions": "Error en modificar las permissions per {path} : {error}",
|
||||
"invalid_url": "Url invalida {url} (existís aqueste site ?)",
|
||||
"download_ssl_error": "Error SSL en se connectant a {url}",
|
||||
"download_timeout": "{url} a trigat per respondre, avèm quitat d’esperar.",
|
||||
"download_unknown_error": "Error en telecargar de donadas de {url} : {error}",
|
||||
"download_bad_status_code": "{url} tòrna lo còdi d’estat {code}",
|
||||
"corrupted_json": "Fichièr Json corromput legit de {ressource} (rason : {error})",
|
||||
"corrupted_yaml": "Fichièr YAML corromput legit de {ressource} (rason : {error})",
|
||||
"info": "Info :",
|
||||
"corrupted_toml": "Fichièr TOML corromput en lectura de {ressource} estant (rason : {error})",
|
||||
"warn_the_user_about_waiting_lock": "Una autra comanda YunoHost es en execucion, sèm a esperar qu’acabe abans d’aviar aquesta d’aquí",
|
||||
"warn_the_user_about_waiting_lock_again": "Encara en espèra…",
|
||||
"warn_the_user_that_lock_is_acquired": "l’autra comanda ven d’acabar, ara lançament d’aquesta comanda",
|
||||
"edit_text_question": "{}. Modificar aqueste tèxte ? [yN]: "
|
||||
"cannot_open_file": "Impossible de dobrir lo fichièr {file:s} (rason : {error:s})",
|
||||
"cannot_write_file": "Escritura impossibla del fichièr {file:s} (rason : {error:s})",
|
||||
"unknown_error_reading_file": "Error desconeguda en ensajar de legir lo fichièr {file:s}",
|
||||
"error_writing_file": "Error en escriure lo fichièr {file:s} : {error:s}",
|
||||
"error_removing": "Error en suprimir {path:s} : {error:s}",
|
||||
"error_changing_file_permissions": "Error en modificar las permissions per {path:s} : {error:s}",
|
||||
"invalid_url": "Url invalida {url:s} (existís aqueste site ?)",
|
||||
"download_ssl_error": "Error SSL en se connectant a {url:s}",
|
||||
"download_timeout": "{url:s} a trigat per respondre, avèm quitat d’esperar.",
|
||||
"download_unknown_error": "Error en telecargar de donadas de {url:s} : {error:s}",
|
||||
"download_bad_status_code": "{url:s} tòrna lo còdi d’estat {code:s}",
|
||||
"command_unknown": "Comanda {command:s} desconeguda ?",
|
||||
"corrupted_json": "Fichièr Json corromput legit de {ressource:s} (rason : {error:s})",
|
||||
"corrupted_yaml": "Fichièr YAML corromput legit de {ressource:s} (rason : {error:s})"
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"logged_out": "Wylogowano",
|
||||
"password": "Hasło",
|
||||
"warn_the_user_that_lock_is_acquired": "Inne polecenie właśnie się zakończyło, teraz uruchamiam to polecenie",
|
||||
"warn_the_user_about_waiting_lock_again": "Wciąż czekam…",
|
||||
"warn_the_user_about_waiting_lock": "Kolejne polecenie YunoHost jest obecnie uruchomione, czekamy na jego zakończenie przed uruchomieniem tego",
|
||||
"download_bad_status_code": "{url} zwrócił kod stanu {code}",
|
||||
"download_unknown_error": "Błąd podczas pobierania danych z {url}: {error}",
|
||||
"download_timeout": "{url} potrzebował zbyt dużo czasu na odpowiedź, rezygnacja.",
|
||||
"download_ssl_error": "Błąd SSL podczas łączenia z {url}",
|
||||
"invalid_url": "Nie udało się połączyć z {url}… być może strona nie jest dostępna, lub nie jesteś prawidłowo połączony z Internetem po IPv4/IPv6.",
|
||||
"error_changing_file_permissions": "Błąd podczas zmiany uprawnień dla {path}: {error}",
|
||||
"error_removing": "Błąd podczas usuwania {path}: {error}",
|
||||
"error_writing_file": "Błąd podczas zapisywania pliku {file}: {error}",
|
||||
"corrupted_toml": "Uszkodzony TOML odczytany z {ressource} (reason: {error})",
|
||||
"corrupted_yaml": "Uszkodzony YAML odczytany z {ressource} (reason: {error})",
|
||||
"corrupted_json": "Uszkodzony JSON odczytany z {ressource} (reason: {error})",
|
||||
"unknown_error_reading_file": "Nieznany błąd podczas próby odczytania pliku {file} (przyczyna: {error})",
|
||||
"cannot_write_file": "Nie można zapisać pliku {file} (przyczyna: {error})",
|
||||
"cannot_open_file": "Nie można otworzyć pliku {file} (przyczyna: {error})",
|
||||
"websocket_request_expected": "Oczekiwano żądania WebSocket",
|
||||
"warning": "Ostrzeżenie:",
|
||||
"values_mismatch": "Wartości nie pasują",
|
||||
"unknown_user": "Nieznany użytkownik '{user}'",
|
||||
"unknown_group": "Nieznana grupa '{group}'",
|
||||
"unable_authenticate": "Nie można uwierzytelnić",
|
||||
"success": "Sukces!",
|
||||
"server_already_running": "Serwer już działa na tym porcie",
|
||||
"root_required": "Aby wykonać tę akcję, musisz być rootem",
|
||||
"pattern_not_match": "Nie pasuje do wzoru",
|
||||
"operation_interrupted": "Operacja przerwana",
|
||||
"not_logged_in": "Nie jesteś zalogowany",
|
||||
"logged_in": "Zalogowany",
|
||||
"invalid_usage": "Nieprawidłowe użycie, wprowadź --help, aby wyświetlić pomoc",
|
||||
"invalid_argument": "Nieprawidłowy argument „{argument}”: {error}",
|
||||
"instance_already_running": "Trwa już operacja YunoHost. Zaczekaj na jej zakończenie, zanim uruchomisz kolejną.",
|
||||
"info": "Info:",
|
||||
"folder_exists": "Folder już istnieje: „{path}”",
|
||||
"file_not_exist": "Plik nie istnieje: „{path}”",
|
||||
"error": "Błąd:",
|
||||
"deprecated_command_alias": "„{prog} {old}” jest przestarzałe i zostanie usunięte w przyszłości, zamiast tego użyj „{prog} {new}”",
|
||||
"deprecated_command": "„{prog} {command}” jest przestarzałe i zostanie usunięte w przyszłości",
|
||||
"confirm": "Potwierdź {prompt}",
|
||||
"authentication_required": "Wymagane uwierzytelnienie",
|
||||
"argument_required": "Argument „{argument}” jest wymagany",
|
||||
"edit_text_question": "{}. Zedytować ten tekst? [tN]: "
|
||||
}
|
|
@ -1,47 +1,54 @@
|
|||
{
|
||||
"argument_required": "O argumento '{argument}' é obrigatório",
|
||||
"argument_required": "O argumento {argument} é obrigatório",
|
||||
"authentication_profile_required": "Autenticação requerida para o perfil '{profile}'",
|
||||
"authentication_required": "Autenticação obrigatória",
|
||||
"authentication_required_long": "É preciso autenticar-se para realizar esta ação",
|
||||
"colon": "{}: ",
|
||||
"confirm": "Confirmar {prompt}",
|
||||
"error": "Erro:",
|
||||
"file_exists": "A pasta já existe: '{path}'",
|
||||
"file_not_exist": "O ficheiro não existe: '{path}'",
|
||||
"folder_exists": "A pasta já existe: '{path}'",
|
||||
"instance_already_running": "Já existe uma operação YunoHost em execução. Aguarde o término antes de executar outro.",
|
||||
"folder_not_exist": "A pasta não existe",
|
||||
"instance_already_running": "O serviço já está em execussão",
|
||||
"invalid_argument": "Argumento inválido '{argument}': {error}",
|
||||
"invalid_password": "Senha incorreta",
|
||||
"invalid_usage": "Uso invalido, utilizar --help para ver a ajuda",
|
||||
"ldap_attribute_already_exists": "O atributo '{attribute}' já existe com valor '{value}'",
|
||||
"ldap_operation_error": "Um erro ocorreu durante a operação LDAP",
|
||||
"ldap_server_down": "Não foi possível comunicar com o servidor LDAP",
|
||||
"logged_in": "Sessão iniciada",
|
||||
"logged_out": "Sessão terminada",
|
||||
"not_logged_in": "Não tem sessão iniciada",
|
||||
"operation_interrupted": "Operação cancelada",
|
||||
"password": "Senha",
|
||||
"pattern_not_match": "Não corresponde ao motivo",
|
||||
"permission_denied": "Permissão revogada",
|
||||
"root_required": "Deve ser root (administrador) para realizar esta ação",
|
||||
"server_already_running": "Existe um servidor ativo nessa porta",
|
||||
"success": "Sucesso!",
|
||||
"unable_authenticate": "Não foi possível autenticar",
|
||||
"unable_retrieve_session": "Não foi possível recuperar a sessão",
|
||||
"values_mismatch": "Os valores não coincidem",
|
||||
"warning": "Aviso:",
|
||||
"websocket_request_expected": "Esperado um pedido a WebSocket",
|
||||
"deprecated_command": "'{prog} {command}' está obsoleto e será removido no futuro",
|
||||
"deprecated_command_alias": "'{prog} {old}' está obsoleto e será removido no futuro, em vez disso, usa '{prog} {new}'",
|
||||
"error_see_log": "Ocorreu um erro . Por favor, veja os logs para maiores detalhes, eles estão localizados em /var/log/yunohost/.",
|
||||
"unknown_group": "Grupo '{group}' desconhecido",
|
||||
"unknown_user": "Nome de utilizador '{user}' desconhecido",
|
||||
"cannot_open_file": "Não foi possível abrir o arquivo {file} (reason: {error})",
|
||||
"cannot_write_file": "Não foi possível abrir o arquivo {file} (reason: {error})",
|
||||
"unknown_error_reading_file": "Erro desconhecido ao tentar ler o arquivo {file} (motivo: {error})",
|
||||
"error_writing_file": "Erro ao gravar arquivo {file}: {error}",
|
||||
"error_removing": "Erro ao remover {path}: {error}",
|
||||
"error_changing_file_permissions": "Erro ao alterar as permissões para {path}: {error}",
|
||||
"invalid_url": "URL inválida {url} (Esse site existe ?)",
|
||||
"download_ssl_error": "Erro de SSL ao conectar-se a {url}",
|
||||
"download_timeout": "{url} demorou muito para responder, desistiu.",
|
||||
"download_unknown_error": "Erro quando baixando os dados de {url} : {error}",
|
||||
"download_bad_status_code": "{url} retornou o código de status {code}",
|
||||
"corrupted_json": "JSON corrompido lido do {ressource} (motivo: {error})",
|
||||
"corrupted_yaml": "YAML corrompido lido do {ressource} (motivo: {error})",
|
||||
"warn_the_user_that_lock_is_acquired": "O outro comando acabou de concluir, agora iniciando este comando",
|
||||
"warn_the_user_about_waiting_lock_again": "Ainda esperando…",
|
||||
"warn_the_user_about_waiting_lock": "Outro comando YunoHost está sendo executado agora, estamos aguardando o término antes de executar este",
|
||||
"corrupted_toml": "TOML corrompido lido em {ressource} (motivo: {error})",
|
||||
"info": "Informações:",
|
||||
"edit_text_question": "{}. Editar este texto ? [yN]: "
|
||||
"cannot_open_file": "Não foi possível abrir o arquivo {file:s} (reason: {error:s})",
|
||||
"cannot_write_file": "Não foi possível abrir o arquivo {file:s} (reason: {error:s})",
|
||||
"unknown_error_reading_file": "Erro desconhecido ao tentar ler o arquivo {file:s}",
|
||||
"error_writing_file": "Erro ao gravar arquivo {file:s}: {error:s}",
|
||||
"error_removing": "Erro ao remover {path:s}: {error:s}",
|
||||
"error_changing_file_permissions": "Erro ao alterar as permissões para {path:s}: {error:s}",
|
||||
"invalid_url": "URL inválida {url:s} (does this site exists ?)",
|
||||
"download_ssl_error": "Erro de SSL ao conectar-se a {url:s}",
|
||||
"download_timeout": "{url:s} demorou muito para responder, desistiu.",
|
||||
"download_unknown_error": "Erro quando baixando os dados de {url:s} : {error:s}",
|
||||
"download_bad_status_code": "{url:s} retornou o código de status {code:s}",
|
||||
"command_unknown": "Comando '{command:s}' desconhecido ?",
|
||||
"corrupted_json": "Json corrompido lido do {ressource:s} (motivo: {error:s})",
|
||||
"corrupted_yaml": "Yaml corrompido lido do {ressource:s} (motivo: {error:s})"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,47 +1 @@
|
|||
{
|
||||
"argument_required": "Требуется аргумент «{argument}»",
|
||||
"authentication_required": "Требуется аутентификация",
|
||||
"confirm": "Подтвердить {prompt}",
|
||||
"deprecated_command": "'{prog} {command}' устарела и будет удалена",
|
||||
"deprecated_command_alias": "'{prog} {old}' устарела и будет удалена, вместо неё используйте '{prog} {new}'",
|
||||
"error": "Ошибка:",
|
||||
"file_not_exist": "Файл не существует: '{path}'",
|
||||
"folder_exists": "Каталог уже существует: '{path}'",
|
||||
"invalid_argument": "Неправильный аргумент '{argument}': {error}",
|
||||
"logged_in": "Вы вошли",
|
||||
"logged_out": "Вы вышли из системы",
|
||||
"not_logged_in": "Вы не вошли в систему",
|
||||
"operation_interrupted": "Действие прервано",
|
||||
"password": "Пароль",
|
||||
"pattern_not_match": "Не соответствует образцу",
|
||||
"server_already_running": "Сервер уже запущен на этом порте",
|
||||
"success": "Отлично!",
|
||||
"unable_authenticate": "Аутентификация невозможна",
|
||||
"unknown_group": "Неизвестная '{group}' группа",
|
||||
"unknown_user": "Неизвестный '{user}' пользователь",
|
||||
"values_mismatch": "Неверные значения",
|
||||
"warning": "Внимание :",
|
||||
"websocket_request_expected": "Ожидается запрос WebSocket",
|
||||
"cannot_open_file": "Не могу открыть файл {file} (причина: {error})",
|
||||
"cannot_write_file": "Не могу записать файл {file} (причина: {error})",
|
||||
"unknown_error_reading_file": "Неизвестная ошибка при попытке прочитать файл {file} (причина: {error})",
|
||||
"corrupted_yaml": "Повреждённой YAML получен от {ressource} (причина: {error})",
|
||||
"error_writing_file": "Ошибка при записи файла {file}: {error}",
|
||||
"error_removing": "Ошибка при удалении {path}: {error}",
|
||||
"invalid_url": "Не удалось подключиться к {url}... возможно этот сервис недоступен или вы не подключены к Интернету через IPv4/IPv6.",
|
||||
"download_ssl_error": "Ошибка SSL при соединении с {url}",
|
||||
"download_timeout": "Превышено время ожидания ответа от {url}.",
|
||||
"download_unknown_error": "Ошибка при загрузке данных с {url} : {error}",
|
||||
"instance_already_running": "Операция YunoHost уже запущена. Пожалуйста, подождите, пока он закончится, прежде чем запускать другой.",
|
||||
"root_required": "Чтобы выполнить это действие, вы должны иметь права root",
|
||||
"corrupted_json": "Повреждённый json получен от {ressource} (причина: {error})",
|
||||
"warn_the_user_that_lock_is_acquired": "Другая команда только что завершилась, теперь запускается эта команда",
|
||||
"warn_the_user_about_waiting_lock_again": "Все еще жду...",
|
||||
"warn_the_user_about_waiting_lock": "Сейчас запускается еще одна команда YunoHost, мы ждем ее завершения, прежде чем запустить эту",
|
||||
"download_bad_status_code": "{url} вернул код состояния {code}",
|
||||
"error_changing_file_permissions": "Ошибка при изменении разрешений для {path}: {error}",
|
||||
"corrupted_toml": "Поврежденный TOML, прочитанный из {ressource} (причина: {error})",
|
||||
"invalid_usage": "Неправильное использование, передайте --help, чтобы увидеть помощь",
|
||||
"info": "Информация:",
|
||||
"edit_text_question": "{}. Изменить этот текст? [yN]: "
|
||||
}
|
||||
{}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"authentication_required": "Vyžadované overenie",
|
||||
"confirm": "Potvrdiť {prompt}",
|
||||
"password": "Heslo",
|
||||
"argument_required": "Je vyžadovaný argument '{argument}'",
|
||||
"deprecated_command": "'{prog} {command}' je zastaraný a v ďalších verziách bude odstránený",
|
||||
"deprecated_command_alias": "'{prog} {old}' je zastaraný a v ďalších verziách bude odstránený, použite miesto neho '{prog} {new}'",
|
||||
"edit_text_question": "{}. Upraviť tento text? [yN]: ",
|
||||
"error": "Chyba:",
|
||||
"file_not_exist": "Súbor neexistuje: '{path}'",
|
||||
"folder_exists": "Adresár už existuje: '{path}'",
|
||||
"info": "Informácie:",
|
||||
"instance_already_running": "Práve prebieha iná YunoHost operácia. Pred spustením ďalšej operácie počkajte na jej dokončenie.",
|
||||
"invalid_argument": "Nesprávny argument '{argument}': {error}",
|
||||
"invalid_usage": "Nesprávne použitie, pridajte --help pre zobrazenie pomocníka",
|
||||
"logged_in": "Prihlásený",
|
||||
"logged_out": "Boli ste odhlásený",
|
||||
"not_logged_in": "Nie ste prihlásený",
|
||||
"operation_interrupted": "Operácia bola prerušená",
|
||||
"pattern_not_match": "Nezodpovedá výrazu",
|
||||
"root_required": "Pre vykonanie tejto akcie musíte byť root",
|
||||
"server_already_running": "Na tomto porte už server beží",
|
||||
"success": "Podarilo sa!",
|
||||
"unable_authenticate": "Nie je možné overiť",
|
||||
"unknown_group": "Neznáma skupina '{group}'",
|
||||
"unknown_user": "Neznámy používateľ '{user}'",
|
||||
"values_mismatch": "Hodnoty nesúhlasia",
|
||||
"warning": "Varovanie:",
|
||||
"websocket_request_expected": "Očakávaná WebSocket požiadavka",
|
||||
"cannot_open_file": "Nedá sa otvoriť súbor {file} (príčina: {error})",
|
||||
"cannot_write_file": "Nedá sa zapísať do súboru {file} (príčina: {error})",
|
||||
"unknown_error_reading_file": "Vyskytla sa neznáma chyba pri čítaní súboru {file} (príčina: {error})",
|
||||
"corrupted_json": "Nepodarilo sa načítať JSON {ressource} (príčina: {error})",
|
||||
"corrupted_yaml": "Nepodarilo sa načítať YAML z {ressource} (príčina: {error})",
|
||||
"corrupted_toml": "Nepodarilo sa načítať TOML z {ressource} (príčina: {error})",
|
||||
"error_writing_file": "Chyba pri zápise do súboru {file}: {error}",
|
||||
"error_removing": "Chyba pri odstraňovaní {path}: {error}",
|
||||
"error_changing_file_permissions": "Chyba pri nastavovaní oprávnení pre {path}: {error}",
|
||||
"invalid_url": "Nepodarilo sa pripojiť k {url}… možno je služba vypnutá alebo nemáte fungujúce pripojenie k internetu prostredníctvom IPv4/IPv6.",
|
||||
"download_ssl_error": "SSL chyba počas spojenia s {url}",
|
||||
"download_timeout": "{url} príliš dlho neodpovedá, vzdávam to.",
|
||||
"download_unknown_error": "Chyba pri sťahovaní dát z {url}: {error}",
|
||||
"download_bad_status_code": "{url} vrátil stavový kód {code}",
|
||||
"warn_the_user_about_waiting_lock": "Práve prebieha iná operácia YunoHost, pred spustením čakáme na jej dokončenie",
|
||||
"warn_the_user_about_waiting_lock_again": "Stále čakáme…",
|
||||
"warn_the_user_that_lock_is_acquired": "Predchádzajúca operácia bola dokončená, teraz spúšťame túto"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"warn_the_user_about_waiting_lock_again": "Väntar fortfarande…",
|
||||
"download_bad_status_code": "{url} svarade med statuskod {code}",
|
||||
"download_timeout": "Gav upp eftersom {url} tog för lång tid på sig att svara.",
|
||||
"download_ssl_error": "Ett SSL-fel påträffades vid anslutning till {url}",
|
||||
"cannot_write_file": "Kunde inte skriva till filen {file} (orsak: {error})",
|
||||
"cannot_open_file": "Kunde inte öppna filen {file} (orsak: {error})",
|
||||
"websocket_request_expected": "Förväntade en WebSocket-förfrågan",
|
||||
"warning": "Varning:",
|
||||
"values_mismatch": "Värdena stämmer inte överens",
|
||||
"unknown_user": "Okänd användare '{user}'",
|
||||
"unknown_group": "Okänd grupp '{group}'",
|
||||
"success": "Lyckades!",
|
||||
"server_already_running": "En server använder redan den porten",
|
||||
"root_required": "Du måste vara inloggad som root för att utföra den här åtgärden",
|
||||
"pattern_not_match": "Stämmer inte in på mönstret",
|
||||
"operation_interrupted": "Behandling avbruten",
|
||||
"not_logged_in": "Du är inte inloggad",
|
||||
"logged_in": "Inloggad",
|
||||
"invalid_argument": "Ogiltig parameter '{argument}': {error}",
|
||||
"logged_out": "Utloggad",
|
||||
"info": "Info:",
|
||||
"folder_exists": "Katalogen finns redan: '{path}'",
|
||||
"file_not_exist": "Filen finns inte: '{path}'",
|
||||
"error": "Fel:",
|
||||
"deprecated_command_alias": "'{prog} {old}' rekommenderas inte längre och kommer tas bort i framtiden, använd '{prog} {new}' istället",
|
||||
"deprecated_command": "'{prog} {command}' rekommenderas inte längre och kommer tas bort i framtiden",
|
||||
"confirm": "Bekräfta {prompt}",
|
||||
"argument_required": "Parametern '{argument}' krävs",
|
||||
"password": "Lösenord",
|
||||
"warn_the_user_that_lock_is_acquired": "det andra kommandot har bara slutförts, nu startar du det här kommandot",
|
||||
"warn_the_user_about_waiting_lock": "Ett annat YunoHost-kommando körs just nu, vi väntar på att det ska slutföras innan det här körs",
|
||||
"download_unknown_error": "Fel vid nedladdning av data från {url}: {error}",
|
||||
"invalid_url": "Ogiltig url {url} (finns den här webbplatsen?)",
|
||||
"error_changing_file_permissions": "Fel vid ändring av behörigheter för {path}: {error}",
|
||||
"error_removing": "Fel vid borttagning av {path}: {error}",
|
||||
"error_writing_file": "Fel vid skrivning av fil {file}: {error}",
|
||||
"corrupted_toml": "Korrupt toml läst från {ressource} (anledning: {error})",
|
||||
"corrupted_yaml": "Skadad yaml läst från {ressource} (anledning: {error})",
|
||||
"corrupted_json": "Skadad json läst från {ressource} (anledning: {error})",
|
||||
"unknown_error_reading_file": "Okänt fel vid försök att läsa filen {file} (anledning: {error})",
|
||||
"unable_authenticate": "Det går inte att verifiera",
|
||||
"invalid_usage": "Ogiltig användning, pass --help för att se hjälp",
|
||||
"instance_already_running": "Det finns redan en YunoHost-operation. Vänta tills den är klar innan du kör en annan.",
|
||||
"authentication_required": "Autentisering krävs"
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,47 +1,31 @@
|
|||
{
|
||||
"argument_required": "{argument} argümanı gerekli",
|
||||
"authentication_profile_required": "'{profile}' profili için yetkilendirme gerekli",
|
||||
"authentication_required": "Yetklendirme gerekli",
|
||||
"authentication_required_long": "Bu işlemi yapmak içi yetkilendirme gerekli",
|
||||
"colon": "{}: ",
|
||||
"confirm": "{prompt}'i doğrulayın",
|
||||
"error": "Hata:",
|
||||
"instance_already_running": "Halihazırda bir YunoHost operasyonu var. Lütfen başka bir tane çalıştırmadan önce bitmesini bekleyin.",
|
||||
"error_see_log": "Bir hata oluştu. Detaylar için lütfen loga bakınız",
|
||||
"instance_already_running": "Uygulama zaten çalışıyor",
|
||||
"invalid_argument": "Geçersiz argüman '{argument}': {error}",
|
||||
"invalid_password": "Geçersiz parola",
|
||||
"ldap_attribute_already_exists": "'{attribute}={value}' özelliği zaten mevcut",
|
||||
"ldap_operation_error": "LDAP işlemi sırasında hata oluştu",
|
||||
"ldap_server_down": "LDAP sunucusuna erişilemiyor",
|
||||
"logged_in": "Giriş yapıldı",
|
||||
"logged_out": "Çıkış yapıldı",
|
||||
"not_logged_in": "Giriş yapmadınız",
|
||||
"operation_interrupted": "İşlem yarıda kesildi",
|
||||
"password": "Parola",
|
||||
"pattern_not_match": "İstenen biçimle uyuşmuyor",
|
||||
"permission_denied": "Erişim reddedildi",
|
||||
"root_required": "Bu işlemi yapmak için root olmalısınız",
|
||||
"server_already_running": "Bu portta zaten çalışan bir sunucu var",
|
||||
"success": "İşlem Başarılı!",
|
||||
"unable_authenticate": "Yetkilendirme başarısız",
|
||||
"unable_retrieve_session": "Oturum bilgileri alınamadı",
|
||||
"values_mismatch": "Değerler uyuşmuyor",
|
||||
"warning": "Uyarı:",
|
||||
"websocket_request_expected": "WebSocket isteği gerekli",
|
||||
"warn_the_user_that_lock_is_acquired": "Diğer komut şimdi tamamlandı, şimdi bu komutu başlatıyor",
|
||||
"warn_the_user_about_waiting_lock_again": "Hala bekliyor…",
|
||||
"warn_the_user_about_waiting_lock": "Başka bir YunoHost komutu şu anda çalışıyor, bunu çalıştırmadan önce bitmesini bekliyoruz",
|
||||
"download_bad_status_code": "{url} döndürülen durum kodu {code}",
|
||||
"download_unknown_error": "{url} adresinden veri indirilirken hata oluştu: {error}",
|
||||
"download_timeout": "{url} yanıtlaması çok uzun sürdü, pes etti.",
|
||||
"download_ssl_error": "{url} ağına bağlanırken SSL hatası",
|
||||
"invalid_url": "{url} bağlanılamadı… URL çalışmıyor olabilir veya IPv4/IPv6 internete düzgün bir şekilde bağlı değilsiniz.",
|
||||
"error_changing_file_permissions": "{path} için izinler değiştirilirken hata oluştu: {error}",
|
||||
"error_removing": "{path} kaldırılırken hata oluştu: {error}",
|
||||
"error_writing_file": "{file} dosyası yazılırken hata oluştu: {error}",
|
||||
"corrupted_toml": "{ressource} kaynağından okunan bozuk TOML(nedeni: {error})",
|
||||
"corrupted_yaml": "{ressource} kaynağından bozuk YAML okunuyor (neden: {error})",
|
||||
"corrupted_json": "{ressource} adresinden okunan bozuk json (neden: {error})",
|
||||
"unknown_error_reading_file": "{file} dosyasını okumaya çalışırken bilinmeyen hata (nedeni: {error})",
|
||||
"cannot_write_file": "{file} dosyası yazılamadı (nedeni: {error})",
|
||||
"cannot_open_file": "{file} dosyası açılamadı (nedeni: {error})",
|
||||
"unknown_user": "Bilinmeyen '{user}' kullanıcı",
|
||||
"unknown_group": "Bilinmeyen '{group}' grubu",
|
||||
"invalid_usage": "Geçersiz kullanım, yardım görmek için --help iletin",
|
||||
"info": "Bilgi:",
|
||||
"folder_exists": "Klasör zaten var: '{path}'",
|
||||
"file_not_exist": "Dosya mevcut değil: '{path}'",
|
||||
"deprecated_command_alias": "'{prog} {old}' kullanımdan kaldırıldı ve gelecekte kaldırılacak, bunun yerine '{prog} {new}' kullanın",
|
||||
"deprecated_command": "'{prog} {command}' kullanımdan kaldırıldı ve gelecekte kaldırılacak",
|
||||
"edit_text_question": "{}. Bu metni düzenle ? [yN]: "
|
||||
"websocket_request_expected": "WebSocket isteği gerekli"
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"password": "Пароль",
|
||||
"logged_out": "Ви вийшли з системи",
|
||||
"invalid_url": "Помилка з'єднання із {url}… можливо, служба не працює, або ви неправильно під'єднані до Інтернету в IPv4/IPv6.",
|
||||
"warn_the_user_that_lock_is_acquired": "Інша команда щойно завершилася, тепер запускаємо цю команду",
|
||||
"warn_the_user_about_waiting_lock_again": "Досі очікуємо…",
|
||||
"warn_the_user_about_waiting_lock": "Зараз запускається ще одна команда YunoHost, ми чекаємо її завершення, перш ніж запустити цю",
|
||||
"download_bad_status_code": "{url} повернув код стану {code}",
|
||||
"download_unknown_error": "Помилка під час завантаження даних з {url}: {error}",
|
||||
"download_timeout": "Перевищено час очікування відповіді від {url}.",
|
||||
"download_ssl_error": "Помилка SSL під час з'єднання з {url}",
|
||||
"error_changing_file_permissions": "Помилка під час зміни дозволів для {path}: {error}",
|
||||
"error_removing": "Помилка під час видалення {path}: {error}",
|
||||
"error_writing_file": "Помилка під час запису файлу {file}: {error}",
|
||||
"corrupted_toml": "Пошкоджений TOML, зчитаний з {ressource} (причина: {error})",
|
||||
"corrupted_yaml": "Пошкоджений YAML, зчитаний з {ressource} (причина: {error})",
|
||||
"corrupted_json": "Пошкоджений JSON, зчитаний з {ressource} (причина: {error})",
|
||||
"unknown_error_reading_file": "Невідома помилка під час спроби прочитати файл {file} (причина: {error})",
|
||||
"cannot_write_file": "Не можу записати файл {file} (причина: {error})",
|
||||
"cannot_open_file": "Не можу відкрити файл {file} (причина: {error})",
|
||||
"websocket_request_expected": "Очікується запит WebSocket",
|
||||
"warning": "Попередження:",
|
||||
"values_mismatch": "Неприпустимі значення",
|
||||
"unknown_user": "Невідомий користувач '{user}'",
|
||||
"unknown_group": "Невідома група '{group}'",
|
||||
"unable_authenticate": "Автентифікація неможлива",
|
||||
"success": "Успішно!",
|
||||
"server_already_running": "Сервер вже запущений на цьому порті",
|
||||
"root_required": "Щоб виконати цю дію, ви повинні мати кореневі права (root)",
|
||||
"pattern_not_match": "Не відповідає зразку",
|
||||
"operation_interrupted": "Операцію перервано",
|
||||
"not_logged_in": "Ви не увійшли в систему",
|
||||
"logged_in": "Ви увійшли в систему",
|
||||
"invalid_usage": "Неправильне використання, передайте --help для перегляду довідки",
|
||||
"invalid_argument": "Неправильний аргумент '{argument}': {error}",
|
||||
"instance_already_running": "Операція YunoHost вже запущена. Будь ласка, зачекайте, поки вона закінчиться, перш ніж запускати іншу.",
|
||||
"info": "Відомості:",
|
||||
"folder_exists": "Каталог вже існує: '{path}'",
|
||||
"file_not_exist": "Файл не існує: '{path}'",
|
||||
"error": "Помилка:",
|
||||
"deprecated_command_alias": "'{prog} {old}' застаріла і буде видалена, замість неї використовуйте '{prog} {new}'",
|
||||
"deprecated_command": "'{prog} {command}' застаріла і буде видалена",
|
||||
"confirm": "Підтвердити {prompt}",
|
||||
"authentication_required": "Потрібна автентифікація",
|
||||
"argument_required": "Потрібен аргумент '{argument}'",
|
||||
"edit_text_question": "{}. Редагувати цей текст? [yN]: "
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
VERSION="11.2.1"
|
||||
RELEASE="stable"
|
||||
REPO=$(basename $(git rev-parse --show-toplevel))
|
||||
REPO_URL=$(git remote get-url origin)
|
||||
ME=$(git config --get user.name)
|
||||
EMAIL=$(git config --get user.email)
|
||||
|
||||
LAST_RELEASE=$(git tag --list 'debian/11.*' --sort="v:refname" | tail -n 1)
|
||||
|
||||
echo "$REPO ($VERSION) $RELEASE; urgency=low"
|
||||
echo ""
|
||||
|
||||
git log $LAST_RELEASE.. -n 10000 --first-parent --pretty=tformat:' - %b%s (%h)' \
|
||||
| sed -E "s&Merge .*#([0-9]+).*\$& \([#\1]\(http://github.com/YunoHost/$REPO/pull/\1\)\)&g" \
|
||||
| sed -E "/Co-authored-by: .* <.*>/d" \
|
||||
| grep -v "Translations update from Weblate" \
|
||||
| tac
|
||||
|
||||
TRANSLATIONS=$(git log $LAST_RELEASE... -n 10000 --pretty=format:"%s" \
|
||||
| grep "Translated using Weblate" \
|
||||
| sed -E "s/Translated using Weblate \((.*)\)/\1/g" \
|
||||
| sort | uniq | tr '\n' ', ' | sed -e 's/,$//g' -e 's/,/, /g')
|
||||
[[ -z "$TRANSLATIONS" ]] || echo " - [i18n] Translations updated for $TRANSLATIONS"
|
||||
|
||||
echo ""
|
||||
CONTRIBUTORS=$(git log -n10 --pretty=format:'%Cred%h%Creset %C(bold blue)(%an) %Creset%Cgreen(%cr)%Creset - %s %C(yellow)%d%Creset' --abbrev-commit $LAST_RELEASE... -n 10000 --pretty=format:"%an" \
|
||||
| sort | uniq | grep -v "$ME" | grep -v 'yunohost-bot' | grep -vi 'weblate' \
|
||||
| tr '\n' ', ' | sed -e 's/,$//g' -e 's/,/, /g')
|
||||
[[ -z "$CONTRIBUTORS" ]] || echo " Thanks to all contributors <3 ! ($CONTRIBUTORS)"
|
||||
echo ""
|
||||
echo " -- $ME <$EMAIL> $(date -R)"
|
||||
echo ""
|
||||
|
||||
|
||||
|
||||
# PR links can be converted to regular texts using : sed -E 's@\[(#[0-9]*)\]\([^ )]*\)@\1@g'
|
||||
# Or readded with sed -E 's@#([0-9]*)@[YunoHost#\1](https://github.com/yunohost/yunohost/pull/\1)@g' | sed -E 's@\((\w+)\)@([YunoHost/\1](https://github.com/yunohost/yunohost/commit/\1))@g'
|
|
@ -1,13 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from moulinette.core import (
|
||||
MoulinetteError,
|
||||
Moulinette18n,
|
||||
)
|
||||
from moulinette.core import init_interface, MoulinetteError, MoulinetteSignals, Moulinette18n
|
||||
from moulinette.globals import DATA_DIR, LIB_DIR, LOCALES_DIR, CACHE_DIR
|
||||
|
||||
__title__ = "moulinette"
|
||||
__author__ = ["Yunohost Contributors"]
|
||||
__license__ = "AGPL 3.0"
|
||||
__title__ = 'moulinette'
|
||||
__version__ = '0.1'
|
||||
__author__ = ['Kload',
|
||||
'jlebleu',
|
||||
'titoko',
|
||||
'beudbeud',
|
||||
'npze']
|
||||
__license__ = 'AGPL 3.0'
|
||||
__credits__ = """
|
||||
Copyright (C) 2014 YUNOHOST.ORG
|
||||
|
||||
|
@ -24,97 +27,115 @@ __credits__ = """
|
|||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program; if not, see http://www.gnu.org/licenses
|
||||
"""
|
||||
__all__ = ["init", "api", "cli", "m18n", "MoulinetteError", "Moulinette"]
|
||||
__all__ = [
|
||||
'init', 'api', 'cli', 'm18n',
|
||||
'init_interface', 'MoulinetteError',
|
||||
'DATA_DIR', 'LIB_DIR', 'LOCALES_DIR', 'CACHE_DIR',
|
||||
]
|
||||
|
||||
|
||||
msignals = MoulinetteSignals()
|
||||
msettings = dict()
|
||||
m18n = Moulinette18n()
|
||||
|
||||
|
||||
class classproperty:
|
||||
def __init__(self, f):
|
||||
self.f = f
|
||||
# Package functions
|
||||
|
||||
def __get__(self, obj, owner):
|
||||
return self.f(owner)
|
||||
def init(logging_config=None, **kwargs):
|
||||
"""Package initialization
|
||||
|
||||
Initialize directories and global variables. It must be called
|
||||
before any of package method is used - even the easy access
|
||||
functions.
|
||||
|
||||
class Moulinette:
|
||||
_interface = None
|
||||
Keyword arguments:
|
||||
- logging_config -- A dict containing logging configuration to load
|
||||
- **kwargs -- See core.Package
|
||||
|
||||
def prompt(*args, **kwargs):
|
||||
return Moulinette.interface.prompt(*args, **kwargs)
|
||||
At the end, the global variable 'pkg' will contain a Package
|
||||
instance. See core.Package for available methods and variables.
|
||||
|
||||
def display(*args, **kwargs):
|
||||
return Moulinette.interface.display(*args, **kwargs)
|
||||
"""
|
||||
import sys
|
||||
from moulinette.utils.log import configure_logging
|
||||
|
||||
@classproperty
|
||||
def interface(cls):
|
||||
return cls._interface
|
||||
configure_logging(logging_config)
|
||||
|
||||
# Add library directory to python path
|
||||
sys.path.insert(0, LIB_DIR)
|
||||
|
||||
|
||||
# Easy access to interfaces
|
||||
def api(host="localhost", port=80, routes={}, actionsmap=None, locales_dir=None):
|
||||
|
||||
def api(namespaces, host='localhost', port=80, routes={},
|
||||
use_websocket=True, use_cache=True):
|
||||
"""Web server (API) interface
|
||||
|
||||
Run a HTTP server with the moulinette for an API usage.
|
||||
|
||||
Keyword arguments:
|
||||
- namespaces -- The list of namespaces to use
|
||||
- host -- Server address to bind to
|
||||
- port -- Server port to bind to
|
||||
- routes -- A dict of additional routes to add in the form of
|
||||
{(method, uri): callback}
|
||||
- use_websocket -- Serve via WSGI to handle asynchronous responses
|
||||
- use_cache -- False if it should parse the actions map file
|
||||
instead of using the cached one
|
||||
|
||||
"""
|
||||
from moulinette.interfaces.api import Interface as Api
|
||||
|
||||
m18n.set_locales_dir(locales_dir)
|
||||
|
||||
try:
|
||||
Api(
|
||||
routes=routes,
|
||||
actionsmap=actionsmap,
|
||||
).run(host, port)
|
||||
moulinette = init_interface('api',
|
||||
kwargs={
|
||||
'routes': routes,
|
||||
'use_websocket': use_websocket
|
||||
},
|
||||
actionsmap={
|
||||
'namespaces': namespaces,
|
||||
'use_cache': use_cache
|
||||
}
|
||||
)
|
||||
moulinette.run(host, port)
|
||||
except MoulinetteError as e:
|
||||
import logging
|
||||
|
||||
logging.getLogger("moulinette").error(e.strerror)
|
||||
return 1
|
||||
logging.getLogger(namespaces[0]).error(e.strerror)
|
||||
return e.errno
|
||||
except KeyboardInterrupt:
|
||||
import logging
|
||||
|
||||
logging.getLogger("moulinette").info(m18n.g("operation_interrupted"))
|
||||
logging.getLogger(namespaces[0]).info(m18n.g('operation_interrupted'))
|
||||
return 0
|
||||
|
||||
|
||||
def cli(
|
||||
args, top_parser, output_as=None, timeout=None, actionsmap=None, locales_dir=None
|
||||
):
|
||||
def cli(namespaces, args, use_cache=True, output_as=None,
|
||||
password=None, timeout=None, parser_kwargs={}):
|
||||
"""Command line interface
|
||||
|
||||
Execute an action with the moulinette from the CLI and print its
|
||||
result in a readable format.
|
||||
|
||||
Keyword arguments:
|
||||
- namespaces -- The list of namespaces to use
|
||||
- args -- A list of argument strings
|
||||
- use_cache -- False if it should parse the actions map file
|
||||
instead of using the cached one
|
||||
- output_as -- Output result in another format, see
|
||||
moulinette.interfaces.cli.Interface for possible values
|
||||
- top_parser -- The top parser used to build the ActionsMapParser
|
||||
- password -- The password to use in case of authentication
|
||||
- parser_kwargs -- A dict of arguments to pass to the parser
|
||||
class at construction
|
||||
|
||||
"""
|
||||
from moulinette.interfaces.cli import Interface as Cli
|
||||
|
||||
m18n.set_locales_dir(locales_dir)
|
||||
|
||||
try:
|
||||
load_only_category = args[0] if args and not args[0].startswith("-") else None
|
||||
Cli(
|
||||
top_parser=top_parser,
|
||||
load_only_category=load_only_category,
|
||||
actionsmap=actionsmap,
|
||||
).run(args, output_as=output_as, timeout=timeout)
|
||||
moulinette = init_interface('cli',
|
||||
actionsmap={
|
||||
'namespaces': namespaces,
|
||||
'use_cache': use_cache,
|
||||
'parser_kwargs': parser_kwargs,
|
||||
},
|
||||
)
|
||||
moulinette.run(args, output_as=output_as, password=password, timeout=timeout)
|
||||
except MoulinetteError as e:
|
||||
import logging
|
||||
|
||||
logging.getLogger("moulinette").error(e.strerror)
|
||||
return 1
|
||||
logging.getLogger(namespaces[0]).error(e.strerror)
|
||||
return e.errno
|
||||
return 0
|
||||
|
|
|
@ -2,35 +2,30 @@
|
|||
|
||||
import os
|
||||
import re
|
||||
import errno
|
||||
import logging
|
||||
import glob
|
||||
import pickle as pickle
|
||||
|
||||
from typing import List, Optional
|
||||
import yaml
|
||||
import cPickle as pickle
|
||||
from time import time
|
||||
from collections import OrderedDict
|
||||
from importlib import import_module
|
||||
from functools import cache
|
||||
|
||||
from moulinette import m18n, Moulinette
|
||||
from moulinette.core import (
|
||||
MoulinetteError,
|
||||
MoulinetteLock,
|
||||
MoulinetteValidationError,
|
||||
from moulinette import m18n, msignals
|
||||
from moulinette.cache import open_cachefile
|
||||
from moulinette.globals import CACHE_DIR, DATA_DIR
|
||||
from moulinette.core import (MoulinetteError, MoulinetteLock)
|
||||
from moulinette.interfaces import (
|
||||
BaseActionsMapParser, GLOBAL_SECTION, TO_RETURN_PROP
|
||||
)
|
||||
from moulinette.interfaces import BaseActionsMapParser
|
||||
from moulinette.utils.log import start_action_logging
|
||||
from moulinette.utils.filesystem import read_yaml
|
||||
|
||||
logger = logging.getLogger("moulinette.actionsmap")
|
||||
logger = logging.getLogger('moulinette.actionsmap')
|
||||
|
||||
|
||||
# Extra parameters ----------------------------------------------------
|
||||
|
||||
# Extra parameters definition
|
||||
|
||||
|
||||
class _ExtraParameter:
|
||||
class _ExtraParameter(object):
|
||||
"""
|
||||
Argument parser for an extra parameter.
|
||||
|
||||
|
@ -39,14 +34,22 @@ class _ExtraParameter:
|
|||
|
||||
"""
|
||||
|
||||
name: Optional[str] = None
|
||||
|
||||
"""A list of interface for which the parameter doesn't apply to"""
|
||||
skipped_iface: List[str] = []
|
||||
|
||||
def __init__(self, iface):
|
||||
# TODO: Add conn argument which contains authentification object
|
||||
self.iface = iface
|
||||
|
||||
# Required variables
|
||||
# Each extra parameters classes must overwrite these variables.
|
||||
|
||||
"""The extra parameter name"""
|
||||
name = None
|
||||
|
||||
# Optional variables
|
||||
# Each extra parameters classes can overwrite these variables.
|
||||
|
||||
"""A list of interface for which the parameter doesn't apply"""
|
||||
skipped_iface = []
|
||||
|
||||
# Virtual methods
|
||||
# Each extra parameters classes can implement these methods.
|
||||
|
||||
|
@ -83,29 +86,23 @@ class _ExtraParameter:
|
|||
|
||||
class CommentParameter(_ExtraParameter):
|
||||
name = "comment"
|
||||
skipped_iface = ["api"]
|
||||
skipped_iface = ['api']
|
||||
|
||||
def __call__(self, message, arg_name, arg_value):
|
||||
if arg_value is None:
|
||||
return
|
||||
return Moulinette.display(m18n.n(message))
|
||||
return msignals.display(m18n.n(message))
|
||||
|
||||
@classmethod
|
||||
def validate(klass, value, arg_name):
|
||||
# Deprecated boolean or empty string
|
||||
if isinstance(value, bool) or (isinstance(value, str) and not value):
|
||||
logger.warning(
|
||||
"expecting a non-empty string for extra parameter '%s' of "
|
||||
"argument '%s'",
|
||||
klass.name,
|
||||
arg_name,
|
||||
)
|
||||
logger.warning("expecting a string for extra parameter '%s' of "
|
||||
"argument '%s'", klass.name, arg_name)
|
||||
value = arg_name
|
||||
elif not isinstance(value, str):
|
||||
raise TypeError("parameter value must be a string, got %r" % value)
|
||||
raise TypeError("parameter value must be a string, got %r"
|
||||
% value)
|
||||
return value
|
||||
|
||||
|
||||
class AskParameter(_ExtraParameter):
|
||||
"""
|
||||
Ask for the argument value if possible and needed.
|
||||
|
@ -114,9 +111,8 @@ class AskParameter(_ExtraParameter):
|
|||
when asking the argument value.
|
||||
|
||||
"""
|
||||
|
||||
name = "ask"
|
||||
skipped_iface = ["api"]
|
||||
name = 'ask'
|
||||
skipped_iface = ['api']
|
||||
|
||||
def __call__(self, message, arg_name, arg_value):
|
||||
if arg_value:
|
||||
|
@ -124,7 +120,7 @@ class AskParameter(_ExtraParameter):
|
|||
|
||||
try:
|
||||
# Ask for the argument value
|
||||
return Moulinette.prompt(m18n.n(message))
|
||||
return msignals.prompt(m18n.n(message))
|
||||
except NotImplementedError:
|
||||
return arg_value
|
||||
|
||||
|
@ -132,15 +128,12 @@ class AskParameter(_ExtraParameter):
|
|||
def validate(klass, value, arg_name):
|
||||
# Deprecated boolean or empty string
|
||||
if isinstance(value, bool) or (isinstance(value, str) and not value):
|
||||
logger.warning(
|
||||
"expecting a non-empty string for extra parameter '%s' of "
|
||||
"argument '%s'",
|
||||
klass.name,
|
||||
arg_name,
|
||||
)
|
||||
logger.warning("expecting a string for extra parameter '%s' of "
|
||||
"argument '%s'", klass.name, arg_name)
|
||||
value = arg_name
|
||||
elif not isinstance(value, str):
|
||||
raise TypeError("parameter value must be a string, got %r" % value)
|
||||
raise TypeError("parameter value must be a string, got %r"
|
||||
% value)
|
||||
return value
|
||||
|
||||
|
||||
|
@ -152,8 +145,7 @@ class PasswordParameter(AskParameter):
|
|||
when asking the password.
|
||||
|
||||
"""
|
||||
|
||||
name = "password"
|
||||
name = 'password'
|
||||
|
||||
def __call__(self, message, arg_name, arg_value):
|
||||
if arg_value:
|
||||
|
@ -161,7 +153,7 @@ class PasswordParameter(AskParameter):
|
|||
|
||||
try:
|
||||
# Ask for the password
|
||||
return Moulinette.prompt(m18n.n(message), True, True)
|
||||
return msignals.prompt(m18n.n(message), True, True)
|
||||
except NotImplementedError:
|
||||
return arg_value
|
||||
|
||||
|
@ -174,47 +166,41 @@ class PatternParameter(_ExtraParameter):
|
|||
the message to display if it doesn't match.
|
||||
|
||||
"""
|
||||
|
||||
name = "pattern"
|
||||
name = 'pattern'
|
||||
|
||||
def __call__(self, arguments, arg_name, arg_value):
|
||||
pattern, message = (arguments[0], arguments[1])
|
||||
|
||||
# Use temporarly utf-8 encoded value
|
||||
try:
|
||||
v = str(arg_value, "utf-8")
|
||||
except Exception:
|
||||
v = unicode(arg_value, 'utf-8')
|
||||
except:
|
||||
v = arg_value
|
||||
|
||||
if v and not re.match(pattern, v or "", re.UNICODE):
|
||||
logger.warning(
|
||||
"argument value '%s' for '%s' doesn't match pattern '%s'",
|
||||
v,
|
||||
arg_name,
|
||||
pattern,
|
||||
)
|
||||
if v and not re.match(pattern, v or '', re.UNICODE):
|
||||
logger.debug("argument value '%s' for '%s' doesn't match pattern '%s'",
|
||||
v, arg_name, pattern)
|
||||
|
||||
# Attempt to retrieve message translation
|
||||
msg = m18n.n(message)
|
||||
if msg == message:
|
||||
msg = m18n.g(message)
|
||||
|
||||
raise MoulinetteValidationError(
|
||||
"invalid_argument", argument=arg_name, error=msg
|
||||
)
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.g('invalid_argument',
|
||||
argument=arg_name, error=msg))
|
||||
return arg_value
|
||||
|
||||
@staticmethod
|
||||
def validate(value, arg_name):
|
||||
# Deprecated string type
|
||||
if isinstance(value, str):
|
||||
logger.warning(
|
||||
"expecting a list as extra parameter 'pattern' of " "argument '%s'",
|
||||
arg_name,
|
||||
)
|
||||
value = [value, "pattern_not_match"] # i18n: pattern_not_match
|
||||
logger.warning("expecting a list for extra parameter 'pattern' of "
|
||||
"argument '%s'", arg_name)
|
||||
value = [value, 'pattern_not_match']
|
||||
elif not isinstance(value, list) or len(value) != 2:
|
||||
raise TypeError("parameter value must be a list, got %r" % value)
|
||||
raise TypeError("parameter value must be a list, got %r"
|
||||
% value)
|
||||
return value
|
||||
|
||||
|
||||
|
@ -225,39 +211,36 @@ class RequiredParameter(_ExtraParameter):
|
|||
The value of this parameter must be a boolean which is set to False by
|
||||
default.
|
||||
"""
|
||||
|
||||
name = "required"
|
||||
name = 'required'
|
||||
|
||||
def __call__(self, required, arg_name, arg_value):
|
||||
if required and (arg_value is None or arg_value == ""):
|
||||
logger.warning("argument '%s' is required", arg_name)
|
||||
raise MoulinetteValidationError("argument_required", argument=arg_name)
|
||||
if required and (arg_value is None or arg_value == ''):
|
||||
logger.debug("argument '%s' is required",
|
||||
arg_name)
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.g('argument_required',
|
||||
argument=arg_name))
|
||||
return arg_value
|
||||
|
||||
@staticmethod
|
||||
def validate(value, arg_name):
|
||||
if not isinstance(value, bool):
|
||||
raise TypeError("parameter value must be a boolean, got %r" % value)
|
||||
raise TypeError("parameter value must be a list, got %r"
|
||||
% value)
|
||||
return value
|
||||
|
||||
|
||||
"""
|
||||
The list of available extra parameters classes. It will keep to this list
|
||||
order on argument parsing.
|
||||
|
||||
"""
|
||||
extraparameters_list = [
|
||||
CommentParameter,
|
||||
AskParameter,
|
||||
PasswordParameter,
|
||||
RequiredParameter,
|
||||
PatternParameter,
|
||||
]
|
||||
extraparameters_list = [CommentParameter, AskParameter, PasswordParameter,
|
||||
RequiredParameter, PatternParameter]
|
||||
|
||||
# Extra parameters argument Parser
|
||||
|
||||
|
||||
class ExtraArgumentParser:
|
||||
class ExtraArgumentParser(object):
|
||||
"""
|
||||
Argument validator and parser for the extra parameters.
|
||||
|
||||
|
@ -269,13 +252,14 @@ class ExtraArgumentParser:
|
|||
def __init__(self, iface):
|
||||
self.iface = iface
|
||||
self.extra = OrderedDict()
|
||||
self._extra_params = {"_global": {}}
|
||||
self._extra_params = {GLOBAL_SECTION: {}}
|
||||
|
||||
# Append available extra parameters for the current interface
|
||||
for klass in extraparameters_list:
|
||||
if iface in klass.skipped_iface:
|
||||
continue
|
||||
self.extra[klass.name] = klass
|
||||
logger.debug('extra parameter classes loaded: %s', self.extra.keys())
|
||||
|
||||
def validate(self, arg_name, parameters):
|
||||
"""
|
||||
|
@ -287,7 +271,7 @@ class ExtraArgumentParser:
|
|||
|
||||
"""
|
||||
# Iterate over parameters to validate
|
||||
for p in list(parameters):
|
||||
for p, v in parameters.items():
|
||||
klass = self.extra.get(p, None)
|
||||
if not klass:
|
||||
# Remove unknown parameters
|
||||
|
@ -295,14 +279,11 @@ class ExtraArgumentParser:
|
|||
else:
|
||||
try:
|
||||
# Validate parameter value
|
||||
parameters[p] = klass.validate(parameters[p], arg_name)
|
||||
parameters[p] = klass.validate(v, arg_name)
|
||||
except Exception as e:
|
||||
error_message = (
|
||||
"unable to validate extra parameter '%s' for argument '%s': %s"
|
||||
% (p, arg_name, e)
|
||||
)
|
||||
logger.error(error_message)
|
||||
raise MoulinetteError(error_message, raw_msg=True)
|
||||
logger.error("unable to validate extra parameter '%s' "
|
||||
"for argument '%s': %s", p, arg_name, e)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
|
||||
return parameters
|
||||
|
||||
|
@ -311,7 +292,7 @@ class ExtraArgumentParser:
|
|||
Add extra parameters to apply on an action argument
|
||||
|
||||
Keyword arguments:
|
||||
- tid -- The tuple identifier of the action or _global
|
||||
- tid -- The tuple identifier of the action or GLOBAL_SECTION
|
||||
for global extra parameters
|
||||
- arg_name -- The argument name
|
||||
- parameters -- A dict of extra parameters with their values
|
||||
|
@ -334,7 +315,7 @@ class ExtraArgumentParser:
|
|||
- args -- A dict of argument name associated to their value
|
||||
|
||||
"""
|
||||
extra_args = OrderedDict(self._extra_params.get("_global", {}))
|
||||
extra_args = OrderedDict(self._extra_params.get(GLOBAL_SECTION, {}))
|
||||
extra_args.update(self._extra_params.get(tid, {}))
|
||||
|
||||
# Iterate over action arguments with extra parameters
|
||||
|
@ -367,8 +348,16 @@ class ExtraArgumentParser:
|
|||
|
||||
# Main class ----------------------------------------------------------
|
||||
|
||||
def ordered_yaml_load(stream):
|
||||
class OrderedLoader(yaml.Loader):
|
||||
pass
|
||||
OrderedLoader.add_constructor(
|
||||
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
|
||||
lambda loader, node: OrderedDict(loader.construct_pairs(node)))
|
||||
return yaml.load(stream, OrderedLoader)
|
||||
|
||||
class ActionsMap:
|
||||
|
||||
class ActionsMap(object):
|
||||
"""Validate and process actions defined into an actions map
|
||||
|
||||
The actions map defines the features - and their usage - of an
|
||||
|
@ -376,112 +365,92 @@ class ActionsMap:
|
|||
It is composed by categories which contain one or more action(s).
|
||||
Moreover, the action can have specific argument(s).
|
||||
|
||||
This class allows to manipulate one or several actions maps
|
||||
associated to a namespace. If no namespace is given, it will load
|
||||
all available namespaces.
|
||||
|
||||
Keyword arguments:
|
||||
- top_parser -- A BaseActionsMapParser-derived instance to use for
|
||||
parsing the actions map
|
||||
- load_only_category -- A name of a category that should only be the
|
||||
one loaded because it's been already determined
|
||||
that's the only one relevant ... used for optimization
|
||||
purposes...
|
||||
- parser_class -- The BaseActionsMapParser derived class to use
|
||||
for parsing the actions map
|
||||
- namespaces -- The list of namespaces to use
|
||||
- use_cache -- False if it should parse the actions map file
|
||||
instead of using the cached one
|
||||
- parser_kwargs -- A dict of arguments to pass to the parser
|
||||
class at construction
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, actionsmap_yml, top_parser, load_only_category=None):
|
||||
assert isinstance(top_parser, BaseActionsMapParser), (
|
||||
"Invalid parser class '%s'" % top_parser.__class__.__name__
|
||||
def __init__(self, parser_class, namespaces=[], use_cache=True,
|
||||
parser_kwargs={}):
|
||||
if not issubclass(parser_class, BaseActionsMapParser):
|
||||
raise ValueError("Invalid parser class '%s'" % parser_class.__name__)
|
||||
self.parser_class = parser_class
|
||||
self.use_cache = use_cache
|
||||
|
||||
if len(namespaces) == 0:
|
||||
namespaces = self.get_namespaces()
|
||||
actionsmaps = OrderedDict()
|
||||
|
||||
# Iterate over actions map namespaces
|
||||
for n in namespaces:
|
||||
logger.debug("loading actions map namespace '%s'", n)
|
||||
|
||||
actionsmap_yml = '%s/actionsmap/%s.yml' % (DATA_DIR, n)
|
||||
actionsmap_yml_stat = os.stat(actionsmap_yml)
|
||||
actionsmap_pkl = '%s/actionsmap/%s-%d-%d.pkl' % (
|
||||
CACHE_DIR,
|
||||
n,
|
||||
actionsmap_yml_stat.st_size,
|
||||
actionsmap_yml_stat.st_mtime
|
||||
)
|
||||
|
||||
self.from_cache = False
|
||||
|
||||
logger.debug("loading actions map")
|
||||
|
||||
actionsmap_yml_dir = os.path.dirname(actionsmap_yml)
|
||||
actionsmap_yml_file = os.path.basename(actionsmap_yml)
|
||||
actionsmap_yml_stat = os.stat(actionsmap_yml)
|
||||
|
||||
actionsmap_pkl = f"{actionsmap_yml_dir}/.{actionsmap_yml_file}.{actionsmap_yml_stat.st_size}-{actionsmap_yml_stat.st_mtime}.pkl"
|
||||
|
||||
def generate_cache():
|
||||
logger.debug("generating cache for actions map")
|
||||
|
||||
# Read actions map from yaml file
|
||||
actionsmap = read_yaml(actionsmap_yml)
|
||||
|
||||
if not actionsmap["_global"].get("cache", True):
|
||||
return actionsmap
|
||||
|
||||
# Delete old cache files
|
||||
for old_cache in glob.glob(
|
||||
f"{actionsmap_yml_dir}/.{actionsmap_yml_file}.*.pkl"
|
||||
):
|
||||
os.remove(old_cache)
|
||||
|
||||
# at installation, cachedir might not exists
|
||||
dir_ = os.path.dirname(actionsmap_pkl)
|
||||
if not os.path.isdir(dir_):
|
||||
os.makedirs(dir_)
|
||||
|
||||
# Cache actions map into pickle file
|
||||
with open(actionsmap_pkl, "wb") as f:
|
||||
pickle.dump(actionsmap, f)
|
||||
|
||||
return actionsmap
|
||||
|
||||
if os.path.exists(actionsmap_pkl):
|
||||
if use_cache and os.path.exists(actionsmap_pkl):
|
||||
try:
|
||||
# Attempt to load cache
|
||||
with open(actionsmap_pkl, "rb") as f:
|
||||
actionsmap = pickle.load(f)
|
||||
|
||||
self.from_cache = True
|
||||
with open(actionsmap_pkl) as f:
|
||||
actionsmaps[n] = pickle.load(f)
|
||||
# TODO: Switch to python3 and catch proper exception
|
||||
except (IOError, EOFError):
|
||||
actionsmap = generate_cache()
|
||||
else: # cache file doesn't exists
|
||||
actionsmap = generate_cache()
|
||||
self.use_cache = False
|
||||
actionsmaps = self.generate_cache(namespaces)
|
||||
elif use_cache: # cached file doesn't exists
|
||||
self.use_cache = False
|
||||
actionsmaps = self.generate_cache(namespaces)
|
||||
elif n not in actionsmaps:
|
||||
with open(actionsmap_yml) as f:
|
||||
actionsmaps[n] = ordered_yaml_load(f)
|
||||
|
||||
# If load_only_category is set, and *if* the target category
|
||||
# is in the actionsmap, we'll load only that one.
|
||||
# If we filter it even if it doesn't exist, we'll end up with a
|
||||
# weird help message when we do a typo in the category name..
|
||||
if load_only_category and load_only_category in actionsmap:
|
||||
actionsmap = {
|
||||
k: v
|
||||
for k, v in actionsmap.items()
|
||||
if k in [load_only_category, "_global"]
|
||||
}
|
||||
# Load translations
|
||||
m18n.load_namespace(n)
|
||||
|
||||
# Generate parsers
|
||||
self.extraparser = ExtraArgumentParser(top_parser.interface)
|
||||
self.parser = self._construct_parser(actionsmap, top_parser)
|
||||
self.extraparser = ExtraArgumentParser(parser_class.interface)
|
||||
self._parser = self._construct_parser(actionsmaps, **parser_kwargs)
|
||||
|
||||
@cache
|
||||
def get_authenticator(self, auth_method):
|
||||
if auth_method == "default":
|
||||
auth_method = self.default_authentication
|
||||
@property
|
||||
def parser(self):
|
||||
"""Return the instance of the interface's actions map parser"""
|
||||
return self._parser
|
||||
|
||||
# Load and initialize the authenticator module
|
||||
auth_module = f"{self.namespace}.authenticators.{auth_method}"
|
||||
logger.debug(f"Loading auth module {auth_module}")
|
||||
def get_authenticator(self, profile='default'):
|
||||
"""Get an authenticator instance
|
||||
|
||||
Retrieve the authenticator for the given profile and return a
|
||||
new instance.
|
||||
|
||||
Keyword arguments:
|
||||
- profile -- An authenticator profile name
|
||||
|
||||
Returns:
|
||||
A new _BaseAuthenticator derived instance
|
||||
|
||||
"""
|
||||
try:
|
||||
mod = import_module(auth_module)
|
||||
except ImportError as e:
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
raise MoulinetteError(
|
||||
f"unable to load authenticator {auth_module} : {e}", raw_msg=True
|
||||
)
|
||||
auth = self.parser.get_global_conf('authenticator', profile)[1]
|
||||
except KeyError:
|
||||
raise ValueError("Unknown authenticator profile '%s'" % profile)
|
||||
else:
|
||||
return mod.Authenticator()
|
||||
|
||||
def check_authentication_if_required(self, *args, **kwargs):
|
||||
auth_method = self.parser.auth_method(*args, **kwargs)
|
||||
|
||||
if auth_method is None:
|
||||
return
|
||||
|
||||
authenticator = self.get_authenticator(auth_method)
|
||||
Moulinette.interface.authenticate(authenticator)
|
||||
return auth()
|
||||
|
||||
def process(self, args, timeout=None, **kwargs):
|
||||
"""
|
||||
|
@ -494,222 +463,237 @@ class ActionsMap:
|
|||
- **kwargs -- Additional interface arguments
|
||||
|
||||
"""
|
||||
|
||||
# Perform authentication if needed
|
||||
self.check_authentication_if_required(args, **kwargs)
|
||||
|
||||
# Parse arguments
|
||||
arguments = vars(self.parser.parse_args(args, **kwargs))
|
||||
|
||||
# Retrieve tid and parse arguments with extra parameters
|
||||
tid = arguments.pop("_tid")
|
||||
tid = arguments.pop('_tid')
|
||||
arguments = self.extraparser.parse_args(tid, arguments)
|
||||
|
||||
want_to_take_lock = self.parser.want_to_take_lock(args, **kwargs)
|
||||
# Return immediately if a value is defined
|
||||
if TO_RETURN_PROP in arguments:
|
||||
return arguments.get(TO_RETURN_PROP)
|
||||
|
||||
# Retrieve action information
|
||||
if len(tid) == 4:
|
||||
namespace, category, subcategory, action = tid
|
||||
func_name = "{}_{}_{}".format(
|
||||
category,
|
||||
subcategory.replace("-", "_"),
|
||||
action.replace("-", "_"),
|
||||
)
|
||||
full_action_name = "{}.{}.{}.{}".format(
|
||||
namespace,
|
||||
category,
|
||||
subcategory,
|
||||
action,
|
||||
)
|
||||
func_name = '%s_%s_%s' % (category, subcategory.replace('-', '_'), action.replace('-', '_'))
|
||||
full_action_name = "%s.%s.%s.%s" % (namespace, category, subcategory, action)
|
||||
else:
|
||||
assert len(tid) == 3
|
||||
namespace, category, action = tid
|
||||
subcategory = None
|
||||
func_name = "{}_{}".format(category, action.replace("-", "_"))
|
||||
full_action_name = "{}.{}.{}".format(namespace, category, action)
|
||||
func_name = '%s_%s' % (category, action.replace('-', '_'))
|
||||
full_action_name = "%s.%s.%s" % (namespace, category, action)
|
||||
|
||||
# Lock the moulinette for the namespace
|
||||
with MoulinetteLock(namespace, timeout, self.enable_lock and want_to_take_lock):
|
||||
with MoulinetteLock(namespace, timeout):
|
||||
start = time()
|
||||
try:
|
||||
mod = __import__(
|
||||
"{}.{}".format(namespace, category),
|
||||
globals=globals(),
|
||||
level=0,
|
||||
fromlist=[func_name],
|
||||
)
|
||||
logger.debug(
|
||||
"loading python module %s took %.3fs",
|
||||
"{}.{}".format(namespace, category),
|
||||
time() - start,
|
||||
)
|
||||
mod = __import__('%s.%s' % (namespace, category),
|
||||
globals=globals(), level=0,
|
||||
fromlist=[func_name])
|
||||
logger.debug('loading python module %s took %.3fs',
|
||||
'%s.%s' % (namespace, category), time() - start)
|
||||
func = getattr(mod, func_name)
|
||||
except (AttributeError, ImportError) as e:
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
error_message = "unable to load function {}.{} because: {}".format(
|
||||
namespace,
|
||||
func_name,
|
||||
e,
|
||||
)
|
||||
logger.exception(error_message)
|
||||
raise MoulinetteError(error_message, raw_msg=True)
|
||||
except (AttributeError, ImportError):
|
||||
logger.exception("unable to load function %s.%s",
|
||||
namespace, func_name)
|
||||
raise MoulinetteError(errno.EIO, m18n.g('error_see_log'))
|
||||
else:
|
||||
log_id = start_action_logging()
|
||||
if logger.isEnabledFor(logging.DEBUG):
|
||||
# Log arguments in debug mode only for safety reasons
|
||||
logger.debug(
|
||||
"processing action [%s]: %s with args=%s",
|
||||
log_id,
|
||||
full_action_name,
|
||||
arguments,
|
||||
)
|
||||
logger.info('processing action [%s]: %s with args=%s',
|
||||
log_id, full_action_name, arguments)
|
||||
else:
|
||||
logger.debug("processing action [%s]: %s", log_id, full_action_name)
|
||||
logger.info('processing action [%s]: %s',
|
||||
log_id, full_action_name)
|
||||
|
||||
# Load translation and process the action
|
||||
m18n.load_namespace(namespace)
|
||||
start = time()
|
||||
try:
|
||||
return func(**arguments)
|
||||
finally:
|
||||
stop = time()
|
||||
logger.debug("action [%s] executed in %.3fs", log_id, stop - start)
|
||||
logger.debug('action [%s] executed in %.3fs',
|
||||
log_id, stop - start)
|
||||
|
||||
@staticmethod
|
||||
def get_namespaces():
|
||||
"""
|
||||
Retrieve available actions map namespaces
|
||||
|
||||
Returns:
|
||||
A list of available namespaces
|
||||
|
||||
"""
|
||||
namespaces = []
|
||||
|
||||
for f in os.listdir('%s/actionsmap' % DATA_DIR):
|
||||
if f.endswith('.yml'):
|
||||
namespaces.append(f[:-4])
|
||||
return namespaces
|
||||
|
||||
@classmethod
|
||||
def generate_cache(klass, namespaces=None):
|
||||
"""
|
||||
Generate cache for the actions map's file(s)
|
||||
|
||||
Keyword arguments:
|
||||
- namespaces -- A list of namespaces to generate cache for
|
||||
|
||||
Returns:
|
||||
A dict of actions map for each namespaces
|
||||
|
||||
"""
|
||||
actionsmaps = {}
|
||||
if not namespaces:
|
||||
namespaces = klass.get_namespaces()
|
||||
|
||||
# Iterate over actions map namespaces
|
||||
for n in namespaces:
|
||||
logger.debug("generating cache for actions map namespace '%s'", n)
|
||||
|
||||
# Read actions map from yaml file
|
||||
am_file = '%s/actionsmap/%s.yml' % (DATA_DIR, n)
|
||||
with open(am_file, 'r') as f:
|
||||
actionsmaps[n] = ordered_yaml_load(f)
|
||||
|
||||
# at installation, cachedir might not exists
|
||||
if os.path.exists('%s/actionsmap/' % CACHE_DIR):
|
||||
# clean old cached files
|
||||
for i in os.listdir('%s/actionsmap/' % CACHE_DIR):
|
||||
if i.endswith(".pkl"):
|
||||
os.remove('%s/actionsmap/%s' % (CACHE_DIR, i))
|
||||
|
||||
# Cache actions map into pickle file
|
||||
am_file_stat = os.stat(am_file)
|
||||
|
||||
pkl = '%s-%d-%d.pkl' % (n, am_file_stat.st_size, am_file_stat.st_mtime)
|
||||
|
||||
with open_cachefile(pkl, 'w', subdir='actionsmap') as f:
|
||||
pickle.dump(actionsmaps[n], f)
|
||||
|
||||
return actionsmaps
|
||||
|
||||
# Private methods
|
||||
|
||||
def _construct_parser(self, actionsmap, top_parser):
|
||||
def _construct_parser(self, actionsmaps, **kwargs):
|
||||
"""
|
||||
Construct the parser with the actions map
|
||||
|
||||
Keyword arguments:
|
||||
- actionsmap -- A dictionnary of categories/actions/arguments list
|
||||
- top_parser -- A BaseActionsMapParser-derived instance to use for
|
||||
parsing the actions map
|
||||
- actionsmaps -- A dict of multi-level dictionnary of
|
||||
categories/actions/arguments list for each namespaces
|
||||
- **kwargs -- Additionnal arguments to pass at the parser
|
||||
class instantiation
|
||||
|
||||
Returns:
|
||||
An interface relevant's parser object
|
||||
|
||||
"""
|
||||
# Get extra parameters
|
||||
if self.use_cache:
|
||||
validate_extra = False
|
||||
else:
|
||||
validate_extra = True
|
||||
|
||||
logger.debug("building parser...")
|
||||
start = time()
|
||||
|
||||
interface_type = top_parser.interface
|
||||
|
||||
# If loading from cache, extra were already checked when cache was
|
||||
# loaded ? Not sure about this ... old code is a bit mysterious...
|
||||
validate_extra = not self.from_cache
|
||||
# Instantiate parser
|
||||
#
|
||||
# this either returns:
|
||||
# * moulinette.interfaces.cli.ActionsMapParser
|
||||
# * moulinette.interfaces.api.ActionsMapParser
|
||||
top_parser = self.parser_class(**kwargs)
|
||||
|
||||
# namespace, actionsmap is a tuple where:
|
||||
#
|
||||
# * namespace define the top "name", for us it will always be
|
||||
# "yunohost" and there well be only this one
|
||||
# * actionsmap is the actual actionsmap that we care about
|
||||
|
||||
for namespace, actionsmap in actionsmaps.items():
|
||||
# Retrieve global parameters
|
||||
_global = actionsmap.pop("_global", {})
|
||||
_global = actionsmap.pop('_global', {})
|
||||
|
||||
self.namespace = _global["namespace"]
|
||||
self.enable_lock = _global.get("lock", True)
|
||||
self.default_authentication = _global["authentication"][interface_type]
|
||||
# Set the global configuration to use for the parser.
|
||||
top_parser.set_global_conf(_global['configuration'])
|
||||
|
||||
if top_parser.has_global_parser():
|
||||
top_parser.add_global_arguments(_global['arguments'])
|
||||
|
||||
# category_name is stuff like "user", "domain", "hooks"...
|
||||
# category_values is the values of this category (like actions)
|
||||
for category_name, category_values in actionsmap.items():
|
||||
actions = category_values.pop("actions", {})
|
||||
subcategories = category_values.pop("subcategories", {})
|
||||
|
||||
if "actions" in category_values:
|
||||
actions = category_values.pop('actions')
|
||||
else:
|
||||
actions = {}
|
||||
|
||||
if "subcategories" in category_values:
|
||||
subcategories = category_values.pop('subcategories')
|
||||
else:
|
||||
subcategories = {}
|
||||
|
||||
# Get category parser
|
||||
category_parser = top_parser.add_category_parser(
|
||||
category_name, **category_values
|
||||
)
|
||||
category_parser = top_parser.add_category_parser(category_name,
|
||||
**category_values)
|
||||
|
||||
# action_name is like "list" of "domain list"
|
||||
# action_options are the values
|
||||
for action_name, action_options in actions.items():
|
||||
arguments = action_options.pop("arguments", {})
|
||||
authentication = action_options.pop("authentication", {})
|
||||
tid = (self.namespace, category_name, action_name)
|
||||
arguments = action_options.pop('arguments', {})
|
||||
tid = (namespace, category_name, action_name)
|
||||
|
||||
# Get action parser
|
||||
action_parser = category_parser.add_action_parser(
|
||||
action_name, tid, **action_options
|
||||
)
|
||||
action_parser = category_parser.add_action_parser(action_name,
|
||||
tid,
|
||||
**action_options)
|
||||
|
||||
if action_parser is None: # No parser for the action
|
||||
continue
|
||||
|
||||
# Store action identifier and add arguments
|
||||
action_parser.set_defaults(_tid=tid)
|
||||
action_parser.add_arguments(
|
||||
arguments,
|
||||
action_parser.add_arguments(arguments,
|
||||
extraparser=self.extraparser,
|
||||
format_arg_names=top_parser.format_arg_names,
|
||||
validate_extra=validate_extra,
|
||||
)
|
||||
validate_extra=validate_extra)
|
||||
|
||||
action_parser.authentication = self.default_authentication
|
||||
if interface_type in authentication:
|
||||
action_parser.authentication = authentication[interface_type]
|
||||
|
||||
# Disable the locking mechanism for all actions that are 'GET' actions on the api
|
||||
routes = action_options.get("api")
|
||||
routes = [routes] if isinstance(routes, str) else routes
|
||||
if routes and all(route.startswith("GET ") for route in routes):
|
||||
action_parser.want_to_take_lock = False
|
||||
else:
|
||||
action_parser.want_to_take_lock = True
|
||||
if 'configuration' in action_options:
|
||||
category_parser.set_conf(tid, action_options['configuration'])
|
||||
|
||||
# subcategory_name is like "cert" in "domain cert status"
|
||||
# subcategory_values is the values of this subcategory (like actions)
|
||||
for subcategory_name, subcategory_values in subcategories.items():
|
||||
actions = subcategory_values.pop("actions")
|
||||
|
||||
actions = subcategory_values.pop('actions')
|
||||
|
||||
# Get subcategory parser
|
||||
subcategory_parser = category_parser.add_subcategory_parser(
|
||||
subcategory_name, **subcategory_values
|
||||
)
|
||||
subcategory_parser = category_parser.add_subcategory_parser(subcategory_name, **subcategory_values)
|
||||
|
||||
# action_name is like "status" of "domain cert status"
|
||||
# action_options are the values
|
||||
for action_name, action_options in actions.items():
|
||||
arguments = action_options.pop("arguments", {})
|
||||
authentication = action_options.pop("authentication", {})
|
||||
tid = (self.namespace, category_name, subcategory_name, action_name)
|
||||
arguments = action_options.pop('arguments', {})
|
||||
tid = (namespace, category_name, subcategory_name, action_name)
|
||||
|
||||
try:
|
||||
# Get action parser
|
||||
action_parser = subcategory_parser.add_action_parser(
|
||||
action_name, tid, **action_options
|
||||
)
|
||||
action_parser = subcategory_parser.add_action_parser(action_name, tid, **action_options)
|
||||
except AttributeError:
|
||||
# No parser for the action
|
||||
continue
|
||||
|
||||
if action_parser is None: # No parser for the action
|
||||
continue
|
||||
|
||||
# Store action identifier and add arguments
|
||||
action_parser.set_defaults(_tid=tid)
|
||||
action_parser.add_arguments(
|
||||
arguments,
|
||||
action_parser.add_arguments(arguments,
|
||||
extraparser=self.extraparser,
|
||||
format_arg_names=top_parser.format_arg_names,
|
||||
validate_extra=validate_extra,
|
||||
)
|
||||
validate_extra=validate_extra)
|
||||
|
||||
action_parser.authentication = self.default_authentication
|
||||
if interface_type in authentication:
|
||||
action_parser.authentication = authentication[interface_type]
|
||||
if 'configuration' in action_options:
|
||||
category_parser.set_conf(tid, action_options['configuration'])
|
||||
|
||||
# Disable the locking mechanism for all actions that are 'GET' actions on the api
|
||||
routes = action_options.get("api")
|
||||
routes = [routes] if isinstance(routes, str) else routes
|
||||
if routes and all(route.startswith("GET ") for route in routes):
|
||||
action_parser.want_to_take_lock = False
|
||||
else:
|
||||
action_parser.want_to_take_lock = True
|
||||
|
||||
logger.debug("building parser took %.3fs", time() - start)
|
||||
return top_parser
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from moulinette.core import MoulinetteError, MoulinetteAuthenticationError
|
||||
|
||||
logger = logging.getLogger("moulinette.authenticator")
|
||||
|
||||
|
||||
# Base Class -----------------------------------------------------------
|
||||
|
||||
|
||||
class BaseAuthenticator:
|
||||
"""Authenticator base representation
|
||||
|
||||
Each authenticators must implement an Authenticator class derived
|
||||
from this class which must overrides virtual properties and methods.
|
||||
It is used to authenticate and manage session. It implements base
|
||||
methods to authenticate with credentials or a session token.
|
||||
|
||||
Authenticators configurations are identified by a profile name which
|
||||
must be given on instantiation - with the corresponding vendor
|
||||
configuration of the authenticator.
|
||||
|
||||
"""
|
||||
|
||||
# Virtual methods
|
||||
# Each authenticator classes must implement these methods.
|
||||
|
||||
def authenticate_credentials(self, credentials):
|
||||
try:
|
||||
# Attempt to authenticate
|
||||
auth_info = self._authenticate_credentials(credentials) or {}
|
||||
except MoulinetteError:
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.exception(f"authentication {self.name} failed because '{e}'")
|
||||
raise MoulinetteAuthenticationError("unable_authenticate")
|
||||
|
||||
return auth_info
|
164
moulinette/authenticators/__init__.py
Normal file
164
moulinette/authenticators/__init__.py
Normal file
|
@ -0,0 +1,164 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import errno
|
||||
import gnupg
|
||||
import logging
|
||||
|
||||
from moulinette import m18n
|
||||
from moulinette.cache import open_cachefile
|
||||
from moulinette.core import MoulinetteError
|
||||
|
||||
logger = logging.getLogger('moulinette.authenticator')
|
||||
|
||||
|
||||
# Base Class -----------------------------------------------------------
|
||||
|
||||
class BaseAuthenticator(object):
|
||||
"""Authenticator base representation
|
||||
|
||||
Each authenticators must implement an Authenticator class derived
|
||||
from this class which must overrides virtual properties and methods.
|
||||
It is used to authenticate and manage session. It implements base
|
||||
methods to authenticate with a password or a session token.
|
||||
|
||||
Authenticators configurations are identified by a profile name which
|
||||
must be given on instantiation - with the corresponding vendor
|
||||
configuration of the authenticator.
|
||||
|
||||
Keyword arguments:
|
||||
- name -- The authenticator profile name
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, name):
|
||||
self._name = name
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the authenticator instance"""
|
||||
return self._name
|
||||
|
||||
# Virtual properties
|
||||
# Each authenticator classes must implement these properties.
|
||||
|
||||
"""The vendor name of the authenticator"""
|
||||
vendor = None
|
||||
|
||||
@property
|
||||
def is_authenticated(self):
|
||||
"""Either the instance is authenticated or not"""
|
||||
raise NotImplementedError("derived class '%s' must override this property" %
|
||||
self.__class__.__name__)
|
||||
|
||||
# Virtual methods
|
||||
# Each authenticator classes must implement these methods.
|
||||
|
||||
def authenticate(self, password=None):
|
||||
"""Attempt to authenticate
|
||||
|
||||
Attempt to authenticate with given password. It should raise an
|
||||
AuthenticationError exception if authentication fails.
|
||||
|
||||
Keyword arguments:
|
||||
- password -- A clear text password
|
||||
|
||||
"""
|
||||
raise NotImplementedError("derived class '%s' must override this method" %
|
||||
self.__class__.__name__)
|
||||
|
||||
# Authentication methods
|
||||
|
||||
def __call__(self, password=None, token=None):
|
||||
"""Attempt to authenticate
|
||||
|
||||
Attempt to authenticate either with password or with session
|
||||
token if 'password' is None. If the authentication succeed, the
|
||||
instance is returned and the session is registered for the token
|
||||
if 'token' and 'password' are given.
|
||||
The token is composed by the session identifier and a session
|
||||
hash - to use for encryption - as a 2-tuple.
|
||||
|
||||
Keyword arguments:
|
||||
- password -- A clear text password
|
||||
- token -- The session token in the form of (id, hash)
|
||||
|
||||
Returns:
|
||||
The authenticated instance
|
||||
|
||||
"""
|
||||
if self.is_authenticated:
|
||||
return self
|
||||
store_session = True if password and token else False
|
||||
|
||||
if token:
|
||||
try:
|
||||
# Extract id and hash from token
|
||||
s_id, s_hash = token
|
||||
except TypeError:
|
||||
logger.error("unable to extract token parts from '%s'", token)
|
||||
if password is None:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
|
||||
logger.info("session will not be stored")
|
||||
store_session = False
|
||||
else:
|
||||
if password is None:
|
||||
# Retrieve session
|
||||
password = self._retrieve_session(s_id, s_hash)
|
||||
|
||||
try:
|
||||
# Attempt to authenticate
|
||||
self.authenticate(password)
|
||||
except MoulinetteError:
|
||||
raise
|
||||
except:
|
||||
logger.exception("authentication (name: '%s', vendor: '%s') fails",
|
||||
self.name, self.vendor)
|
||||
raise MoulinetteError(errno.EACCES, m18n.g('unable_authenticate'))
|
||||
|
||||
# Store session
|
||||
if store_session:
|
||||
try:
|
||||
self._store_session(s_id, s_hash, password)
|
||||
except:
|
||||
logger.exception("unable to store session")
|
||||
else:
|
||||
logger.debug("session has been stored")
|
||||
|
||||
return self
|
||||
|
||||
# Private methods
|
||||
|
||||
def _open_sessionfile(self, session_id, mode='r'):
|
||||
"""Open a session file for this instance in given mode"""
|
||||
return open_cachefile('%s.asc' % session_id, mode,
|
||||
subdir='session/%s' % self.name)
|
||||
|
||||
def _store_session(self, session_id, session_hash, password):
|
||||
"""Store a session and its associated password"""
|
||||
gpg = gnupg.GPG()
|
||||
gpg.encoding = 'utf-8'
|
||||
with self._open_sessionfile(session_id, 'w') as f:
|
||||
f.write(str(gpg.encrypt(password, None, symmetric=True,
|
||||
passphrase=session_hash)))
|
||||
|
||||
def _retrieve_session(self, session_id, session_hash):
|
||||
"""Retrieve a session and return its associated password"""
|
||||
try:
|
||||
with self._open_sessionfile(session_id, 'r') as f:
|
||||
enc_pwd = f.read()
|
||||
except IOError:
|
||||
logger.debug("unable to retrieve session", exc_info=1)
|
||||
raise MoulinetteError(errno.ENOENT,
|
||||
m18n.g('unable_retrieve_session'))
|
||||
else:
|
||||
gpg = gnupg.GPG()
|
||||
gpg.encoding = 'utf-8'
|
||||
|
||||
decrypted = gpg.decrypt(enc_pwd, passphrase=session_hash)
|
||||
if decrypted.ok is not True:
|
||||
logger.error("unable to decrypt password for the session: %s",
|
||||
decrypted.status)
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.g('unable_retrieve_session'))
|
||||
return decrypted.data
|
246
moulinette/authenticators/ldap.py
Normal file
246
moulinette/authenticators/ldap.py
Normal file
|
@ -0,0 +1,246 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# TODO: Use Python3 to remove this fix!
|
||||
from __future__ import absolute_import
|
||||
import errno
|
||||
import logging
|
||||
import random
|
||||
import string
|
||||
import crypt
|
||||
import ldap
|
||||
import ldap.modlist as modlist
|
||||
|
||||
from moulinette import m18n
|
||||
from moulinette.core import MoulinetteError
|
||||
from moulinette.authenticators import BaseAuthenticator
|
||||
|
||||
logger = logging.getLogger('moulinette.authenticator.ldap')
|
||||
|
||||
|
||||
# LDAP Class Implementation --------------------------------------------
|
||||
|
||||
class Authenticator(BaseAuthenticator):
|
||||
"""LDAP Authenticator
|
||||
|
||||
Initialize a LDAP connexion for the given arguments. It attempts to
|
||||
authenticate a user if 'user_rdn' is given - by associating user_rdn
|
||||
and base_dn - and provides extra methods to manage opened connexion.
|
||||
|
||||
Keyword arguments:
|
||||
- uri -- The LDAP server URI
|
||||
- base_dn -- The base dn
|
||||
- user_rdn -- The user rdn to authenticate
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, name, uri, base_dn, user_rdn=None):
|
||||
logger.debug("initialize authenticator '%s' with: uri='%s', "
|
||||
"base_dn='%s', user_rdn='%s'", name, uri, base_dn, user_rdn)
|
||||
super(Authenticator, self).__init__(name)
|
||||
|
||||
self.uri = uri
|
||||
self.basedn = base_dn
|
||||
if user_rdn:
|
||||
self.userdn = '%s,%s' % (user_rdn, base_dn)
|
||||
self.con = None
|
||||
else:
|
||||
# Initialize anonymous usage
|
||||
self.userdn = ''
|
||||
self.authenticate(None)
|
||||
|
||||
def __del__(self):
|
||||
"""Disconnect and free ressources"""
|
||||
if self.con:
|
||||
self.con.unbind_s()
|
||||
|
||||
# Implement virtual properties
|
||||
|
||||
vendor = 'ldap'
|
||||
|
||||
@property
|
||||
def is_authenticated(self):
|
||||
if self.con is None:
|
||||
return False
|
||||
try:
|
||||
# Retrieve identity
|
||||
who = self.con.whoami_s()
|
||||
except Exception as e:
|
||||
logger.warning("Error during ldap authentication process: %s", e)
|
||||
return False
|
||||
else:
|
||||
if who[3:] == self.userdn:
|
||||
return True
|
||||
return False
|
||||
|
||||
# Implement virtual methods
|
||||
|
||||
def authenticate(self, password):
|
||||
try:
|
||||
con = ldap.initialize(self.uri)
|
||||
if self.userdn:
|
||||
con.simple_bind_s(self.userdn, password)
|
||||
else:
|
||||
con.simple_bind_s()
|
||||
except ldap.INVALID_CREDENTIALS:
|
||||
raise MoulinetteError(errno.EACCES, m18n.g('invalid_password'))
|
||||
except ldap.SERVER_DOWN:
|
||||
logger.exception('unable to reach the server to authenticate')
|
||||
raise MoulinetteError(169, m18n.g('ldap_server_down'))
|
||||
else:
|
||||
self.con = con
|
||||
self._ensure_password_uses_strong_hash(password)
|
||||
|
||||
def _ensure_password_uses_strong_hash(self, password):
|
||||
# XXX this has been copy pasted from YunoHost, should we put that into moulinette?
|
||||
def _hash_user_password(password):
|
||||
char_set = string.ascii_uppercase + string.ascii_lowercase + string.digits + "./"
|
||||
salt = ''.join([random.SystemRandom().choice(char_set) for x in range(16)])
|
||||
salt = '$6$' + salt + '$'
|
||||
return '{CRYPT}' + crypt.crypt(str(password), salt)
|
||||
|
||||
hashed_password = self.search("cn=admin,dc=yunohost,dc=org",
|
||||
attrs=["userPassword"])[0]
|
||||
|
||||
# post-install situation, password is not already set
|
||||
if "userPassword" not in hashed_password or not hashed_password["userPassword"]:
|
||||
return
|
||||
|
||||
# we aren't using sha-512 but something else that is weaker, proceed to upgrade
|
||||
if not hashed_password["userPassword"][0].startswith("{CRYPT}$6$"):
|
||||
self.update("cn=admin", {
|
||||
"userPassword": _hash_user_password(password),
|
||||
})
|
||||
|
||||
# Additional LDAP methods
|
||||
# TODO: Review these methods
|
||||
|
||||
def search(self, base=None, filter='(objectClass=*)', attrs=['dn']):
|
||||
"""Search in LDAP base
|
||||
|
||||
Perform an LDAP search operation with given arguments and return
|
||||
results as a list.
|
||||
|
||||
Keyword arguments:
|
||||
- base -- The dn to search into
|
||||
- filter -- A string representation of the filter to apply
|
||||
- attrs -- A list of attributes to fetch
|
||||
|
||||
Returns:
|
||||
A list of all results
|
||||
|
||||
"""
|
||||
if not base:
|
||||
base = self.basedn
|
||||
|
||||
try:
|
||||
result = self.con.search_s(base, ldap.SCOPE_SUBTREE, filter, attrs)
|
||||
except Exception as e:
|
||||
logger.exception("error during LDAP search operation with: base='%s', "
|
||||
"filter='%s', attrs=%s and exception %s", base, filter, attrs, e)
|
||||
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||
|
||||
result_list = []
|
||||
if not attrs or 'dn' not in attrs:
|
||||
result_list = [entry for dn, entry in result]
|
||||
else:
|
||||
for dn, entry in result:
|
||||
entry['dn'] = [dn]
|
||||
result_list.append(entry)
|
||||
return result_list
|
||||
|
||||
def add(self, rdn, attr_dict):
|
||||
"""
|
||||
Add LDAP entry
|
||||
|
||||
Keyword arguments:
|
||||
rdn -- DN without domain
|
||||
attr_dict -- Dictionnary of attributes/values to add
|
||||
|
||||
Returns:
|
||||
Boolean | MoulinetteError
|
||||
|
||||
"""
|
||||
dn = rdn + ',' + self.basedn
|
||||
ldif = modlist.addModlist(attr_dict)
|
||||
|
||||
try:
|
||||
self.con.add_s(dn, ldif)
|
||||
except Exception as e:
|
||||
logger.exception("error during LDAP add operation with: rdn='%s', "
|
||||
"attr_dict=%s and exception %s", rdn, attr_dict, e)
|
||||
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||
else:
|
||||
return True
|
||||
|
||||
def remove(self, rdn):
|
||||
"""
|
||||
Remove LDAP entry
|
||||
|
||||
Keyword arguments:
|
||||
rdn -- DN without domain
|
||||
|
||||
Returns:
|
||||
Boolean | MoulinetteError
|
||||
|
||||
"""
|
||||
dn = rdn + ',' + self.basedn
|
||||
try:
|
||||
self.con.delete_s(dn)
|
||||
except Exception as e:
|
||||
logger.exception("error during LDAP delete operation with: rdn='%s' and exception %s", rdn, e)
|
||||
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||
else:
|
||||
return True
|
||||
|
||||
def update(self, rdn, attr_dict, new_rdn=False):
|
||||
"""
|
||||
Modify LDAP entry
|
||||
|
||||
Keyword arguments:
|
||||
rdn -- DN without domain
|
||||
attr_dict -- Dictionnary of attributes/values to add
|
||||
new_rdn -- New RDN for modification
|
||||
|
||||
Returns:
|
||||
Boolean | MoulinetteError
|
||||
|
||||
"""
|
||||
dn = rdn + ',' + self.basedn
|
||||
actual_entry = self.search(base=dn, attrs=None)
|
||||
ldif = modlist.modifyModlist(actual_entry[0], attr_dict, ignore_oldexistent=1)
|
||||
|
||||
try:
|
||||
if new_rdn:
|
||||
self.con.rename_s(dn, new_rdn)
|
||||
dn = new_rdn + ',' + self.basedn
|
||||
|
||||
self.con.modify_ext_s(dn, ldif)
|
||||
except Exception as e:
|
||||
logger.exception("error during LDAP update operation with: rdn='%s', "
|
||||
"attr_dict=%s, new_rdn=%s and exception: %s", rdn, attr_dict,
|
||||
new_rdn, e)
|
||||
raise MoulinetteError(169, m18n.g('ldap_operation_error'))
|
||||
else:
|
||||
return True
|
||||
|
||||
def validate_uniqueness(self, value_dict):
|
||||
"""
|
||||
Check uniqueness of values
|
||||
|
||||
Keyword arguments:
|
||||
value_dict -- Dictionnary of attributes/values to check
|
||||
|
||||
Returns:
|
||||
Boolean | MoulinetteError
|
||||
|
||||
"""
|
||||
for attr, value in value_dict.items():
|
||||
if not self.search(filter=attr + '=' + value):
|
||||
continue
|
||||
else:
|
||||
logger.info("attribute '%s' with value '%s' is not unique",
|
||||
attr, value)
|
||||
raise MoulinetteError(errno.EEXIST,
|
||||
m18n.g('ldap_attribute_already_exists',
|
||||
attribute=attr, value=value))
|
||||
return True
|
43
moulinette/cache.py
Normal file
43
moulinette/cache.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
|
||||
from moulinette.globals import CACHE_DIR
|
||||
|
||||
|
||||
def get_cachedir(subdir='', make_dir=True):
|
||||
"""Get the path to a cache directory
|
||||
|
||||
Return the path to the cache directory from an optional
|
||||
subdirectory and create it if needed.
|
||||
|
||||
Keyword arguments:
|
||||
- subdir -- A cache subdirectory
|
||||
- make_dir -- False to not make directory if it not exists
|
||||
|
||||
"""
|
||||
path = os.path.join(CACHE_DIR, subdir)
|
||||
|
||||
if make_dir and not os.path.isdir(path):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
|
||||
def open_cachefile(filename, mode='r', **kwargs):
|
||||
"""Open a cache file and return a stream
|
||||
|
||||
Attempt to open in 'mode' the cache file 'filename' from the
|
||||
default cache directory and in the subdirectory 'subdir' if
|
||||
given. Directories are created if needed and a stream is
|
||||
returned if the file can be written.
|
||||
|
||||
Keyword arguments:
|
||||
- filename -- The cache filename
|
||||
- mode -- The mode in which the file is opened
|
||||
- **kwargs -- Optional arguments for get_cachedir
|
||||
|
||||
"""
|
||||
# Set make_dir if not given
|
||||
kwargs['make_dir'] = kwargs.get('make_dir',
|
||||
True if mode[0] == 'w' else False)
|
||||
return open('%s/%s' % (get_cachedir(**kwargs), filename), mode)
|
|
@ -3,21 +3,23 @@
|
|||
import os
|
||||
import time
|
||||
import json
|
||||
import errno
|
||||
import logging
|
||||
import psutil
|
||||
|
||||
from importlib import import_module
|
||||
|
||||
import moulinette
|
||||
|
||||
logger = logging.getLogger("moulinette.core")
|
||||
from moulinette.globals import LOCALES_DIR, LIB_DIR
|
||||
from moulinette.cache import get_cachedir
|
||||
|
||||
|
||||
def during_unittests_run():
|
||||
return "TESTS_RUN" in os.environ
|
||||
logger = logging.getLogger('moulinette.core')
|
||||
|
||||
|
||||
# Internationalization -------------------------------------------------
|
||||
|
||||
|
||||
class Translator:
|
||||
class Translator(object):
|
||||
"""Internationalization class
|
||||
|
||||
Provide an internationalization mechanism based on JSON files to
|
||||
|
@ -29,16 +31,15 @@ class Translator:
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, locale_dir, default_locale="en"):
|
||||
def __init__(self, locale_dir, default_locale='en'):
|
||||
self.locale_dir = locale_dir
|
||||
self.locale = default_locale
|
||||
self._translations = {}
|
||||
|
||||
# Attempt to load default translations
|
||||
if not self._load_translations(default_locale):
|
||||
logger.error(
|
||||
f"unable to load locale '{default_locale}' from '{locale_dir}'. Does the file '{locale_dir}/{default_locale}.json' exists?",
|
||||
)
|
||||
logger.error("unable to load locale '%s' from '%s'",
|
||||
default_locale, locale_dir)
|
||||
self.default_locale = default_locale
|
||||
|
||||
def get_locales(self):
|
||||
|
@ -46,7 +47,7 @@ class Translator:
|
|||
locales = []
|
||||
|
||||
for f in os.listdir(self.locale_dir):
|
||||
if f.endswith(".json"):
|
||||
if f.endswith('.json'):
|
||||
# TODO: Validate locale
|
||||
locales.append(f[:-5])
|
||||
return locales
|
||||
|
@ -66,11 +67,8 @@ class Translator:
|
|||
"""
|
||||
if locale not in self._translations:
|
||||
if not self._load_translations(locale):
|
||||
logger.debug(
|
||||
"unable to load locale '%s' from '%s'",
|
||||
self.default_locale,
|
||||
self.locale_dir,
|
||||
)
|
||||
logger.debug("unable to load locale '%s' from '%s'",
|
||||
self.default_locale, self.locale_dir)
|
||||
|
||||
# Revert to default locale
|
||||
self.locale = self.default_locale
|
||||
|
@ -80,9 +78,6 @@ class Translator:
|
|||
self.locale = locale
|
||||
return True
|
||||
|
||||
def key_exists(self, key):
|
||||
return key in self._translations[self.default_locale]
|
||||
|
||||
def translate(self, key, *args, **kwargs):
|
||||
"""Retrieve proper translation for a key
|
||||
|
||||
|
@ -96,52 +91,23 @@ class Translator:
|
|||
failed_to_format = False
|
||||
if key in self._translations.get(self.locale, {}):
|
||||
try:
|
||||
return self._translations[self.locale][key].format(*args, **kwargs)
|
||||
except Exception as e:
|
||||
unformatted_string = self._translations[self.locale][key]
|
||||
error_message = (
|
||||
"Failed to format translated string '%s': '%s' with arguments '%s' and '%s, raising error: %s(%s) (don't panic this is just a warning)"
|
||||
% (key, unformatted_string, args, kwargs, e.__class__.__name__, e)
|
||||
)
|
||||
|
||||
if not during_unittests_run():
|
||||
logger.warning(error_message)
|
||||
else:
|
||||
raise Exception(error_message)
|
||||
|
||||
return self._translations[self.locale][key].encode('utf-8').format(*args, **kwargs)
|
||||
except KeyError as e:
|
||||
logger.exception("Failed to format translated string '%s' with error: %s" % (key, e))
|
||||
failed_to_format = True
|
||||
|
||||
if failed_to_format or (
|
||||
self.default_locale != self.locale
|
||||
and key in self._translations.get(self.default_locale, {})
|
||||
):
|
||||
if failed_to_format or (self.default_locale != self.locale and key in self._translations.get(self.default_locale, {})):
|
||||
logger.info("untranslated key '%s' for locale '%s'",
|
||||
key, self.locale)
|
||||
|
||||
try:
|
||||
return self._translations[self.default_locale][key].format(
|
||||
*args, **kwargs
|
||||
)
|
||||
except Exception as e:
|
||||
unformatted_string = self._translations[self.default_locale][key]
|
||||
error_message = (
|
||||
"Failed to format translatable string '%s': '%s' with arguments '%s' and '%s', raising error: %s(%s) (don't panic this is just a warning)"
|
||||
% (key, unformatted_string, args, kwargs, e.__class__.__name__, e)
|
||||
)
|
||||
if not during_unittests_run():
|
||||
logger.warning(error_message)
|
||||
else:
|
||||
raise Exception(error_message)
|
||||
|
||||
return self._translations[self.default_locale][key]
|
||||
|
||||
error_message = (
|
||||
"unable to retrieve string to translate with key '%s' for default locale 'locales/%s.json' file (don't panic this is just a warning)"
|
||||
% (key, self.default_locale)
|
||||
)
|
||||
|
||||
if not during_unittests_run():
|
||||
logger.warning(error_message)
|
||||
else:
|
||||
raise Exception(error_message)
|
||||
return self._translations[self.default_locale][key].encode('utf-8').format(*args, **kwargs)
|
||||
except KeyError as e:
|
||||
logger.exception("Failed to format translatable string '%s' with error: %s" % (key, e))
|
||||
return self._translations[self.locale][key].encode('utf-8')
|
||||
|
||||
logger.exception("unable to retrieve key '%s' for default locale '%s'",
|
||||
key, self.default_locale)
|
||||
return key
|
||||
|
||||
def _load_translations(self, locale, overwrite=False):
|
||||
|
@ -162,8 +128,8 @@ class Translator:
|
|||
return True
|
||||
|
||||
try:
|
||||
with open(f"{self.locale_dir}/{locale}.json", "r", encoding="utf-8") as f:
|
||||
j = json.load(f)
|
||||
with open('%s/%s.json' % (self.locale_dir, locale), 'r') as f:
|
||||
j = json.load(f, 'utf-8')
|
||||
except IOError:
|
||||
return False
|
||||
else:
|
||||
|
@ -171,7 +137,7 @@ class Translator:
|
|||
return True
|
||||
|
||||
|
||||
class Moulinette18n:
|
||||
class Moulinette18n(object):
|
||||
"""Internationalization service for the moulinette
|
||||
|
||||
Manage internationalization and access to the proper keys translation
|
||||
|
@ -183,28 +149,46 @@ class Moulinette18n:
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, default_locale="en"):
|
||||
def __init__(self, default_locale='en'):
|
||||
self.default_locale = default_locale
|
||||
self.locale = default_locale
|
||||
|
||||
# Init global translator
|
||||
global_locale_dir = "/usr/share/moulinette/locales"
|
||||
if during_unittests_run():
|
||||
global_locale_dir = os.path.dirname(__file__) + "/../locales"
|
||||
self._global = Translator(LOCALES_DIR, default_locale)
|
||||
|
||||
self._global = Translator(global_locale_dir, default_locale)
|
||||
# Define namespace related variables
|
||||
self._namespaces = {}
|
||||
self._current_namespace = None
|
||||
|
||||
def set_locales_dir(self, locales_dir):
|
||||
self.translator = Translator(locales_dir, self.default_locale)
|
||||
def load_namespace(self, namespace):
|
||||
"""Load the namespace to use
|
||||
|
||||
Load and set translations of a given namespace. Those translations
|
||||
are accessible with Moulinette18n.n().
|
||||
|
||||
Keyword arguments:
|
||||
- namespace -- The namespace to load
|
||||
|
||||
"""
|
||||
if namespace not in self._namespaces:
|
||||
# Create new Translator object
|
||||
translator = Translator('%s/%s/locales' % (LIB_DIR, namespace),
|
||||
self.default_locale)
|
||||
translator.set_locale(self.locale)
|
||||
self._namespaces[namespace] = translator
|
||||
|
||||
# Set current namespace
|
||||
self._current_namespace = namespace
|
||||
|
||||
def set_locale(self, locale):
|
||||
"""Set the locale to use"""
|
||||
|
||||
self.locale = locale
|
||||
self._global.set_locale(locale)
|
||||
self.translator.set_locale(locale)
|
||||
|
||||
def g(self, key: str, *args, **kwargs) -> str:
|
||||
self._global.set_locale(locale)
|
||||
for n in self._namespaces.values():
|
||||
n.set_locale(locale)
|
||||
|
||||
def g(self, key, *args, **kwargs):
|
||||
"""Retrieve proper translation for a moulinette key
|
||||
|
||||
Attempt to retrieve value for a key from moulinette translations
|
||||
|
@ -216,7 +200,7 @@ class Moulinette18n:
|
|||
"""
|
||||
return self._global.translate(key, *args, **kwargs)
|
||||
|
||||
def n(self, key: str, *args, **kwargs) -> str:
|
||||
def n(self, key, *args, **kwargs):
|
||||
"""Retrieve proper translation for a moulinette key
|
||||
|
||||
Attempt to retrieve value for a key from current loaded namespace
|
||||
|
@ -227,47 +211,212 @@ class Moulinette18n:
|
|||
- key -- The key to translate
|
||||
|
||||
"""
|
||||
return self.translator.translate(key, *args, **kwargs)
|
||||
return self._namespaces[self._current_namespace].translate(key, *args, **kwargs)
|
||||
|
||||
def key_exists(self, key: str) -> bool:
|
||||
"""Check if a key exists in the translation files
|
||||
|
||||
class MoulinetteSignals(object):
|
||||
"""Signals connector for the moulinette
|
||||
|
||||
Allow to easily connect signals from the moulinette to handlers. A
|
||||
signal is emitted by calling the relevant method which call the
|
||||
handler.
|
||||
For the moment, a return value can be requested by a signal to its
|
||||
connected handler - make them not real-signals.
|
||||
|
||||
Keyword arguments:
|
||||
- key -- The key to translate
|
||||
- kwargs -- A dict of {signal: handler} to connect
|
||||
|
||||
"""
|
||||
return self.translator.key_exists(key)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
# Initialize handlers
|
||||
for s in self.signals:
|
||||
self.clear_handler(s)
|
||||
|
||||
# Iterate over signals to connect
|
||||
for s, h in kwargs.items():
|
||||
self.set_handler(s, h)
|
||||
|
||||
def set_handler(self, signal, handler):
|
||||
"""Set the handler for a signal"""
|
||||
if signal not in self.signals:
|
||||
logger.error("unknown signal '%s'", signal)
|
||||
return
|
||||
setattr(self, '_%s' % signal, handler)
|
||||
|
||||
def clear_handler(self, signal):
|
||||
"""Clear the handler of a signal"""
|
||||
if signal not in self.signals:
|
||||
logger.error("unknown signal '%s'", signal)
|
||||
return
|
||||
setattr(self, '_%s' % signal, self._notimplemented)
|
||||
|
||||
# Signals definitions
|
||||
|
||||
"""The list of available signals"""
|
||||
signals = {'authenticate', 'prompt', 'display'}
|
||||
|
||||
def authenticate(self, authenticator, help):
|
||||
"""Process the authentication
|
||||
|
||||
Attempt to authenticate to the given authenticator and return
|
||||
it.
|
||||
It is called when authentication is needed (e.g. to process an
|
||||
action).
|
||||
|
||||
Keyword arguments:
|
||||
- authenticator -- The authenticator object to use
|
||||
- help -- The translation key of the authenticator's help message
|
||||
|
||||
Returns:
|
||||
The authenticator object
|
||||
|
||||
"""
|
||||
if authenticator.is_authenticated:
|
||||
return authenticator
|
||||
return self._authenticate(authenticator, help)
|
||||
|
||||
def prompt(self, message, is_password=False, confirm=False):
|
||||
"""Prompt for a value
|
||||
|
||||
Prompt the interface for a parameter value which is a password
|
||||
if 'is_password' and must be confirmed if 'confirm'.
|
||||
Is is called when a parameter value is needed and when the
|
||||
current interface should allow user interaction (e.g. to parse
|
||||
extra parameter 'ask' in the cli).
|
||||
|
||||
Keyword arguments:
|
||||
- message -- The message to display
|
||||
- is_password -- True if the parameter is a password
|
||||
- confirm -- True if the value must be confirmed
|
||||
|
||||
Returns:
|
||||
The collected value
|
||||
|
||||
"""
|
||||
return self._prompt(message, is_password, confirm)
|
||||
|
||||
def display(self, message, style='info'):
|
||||
"""Display a message
|
||||
|
||||
Display a message with a given style to the user.
|
||||
It is called when a message should be printed to the user if the
|
||||
current interface allows user interaction (e.g. print a success
|
||||
message to the user).
|
||||
|
||||
Keyword arguments:
|
||||
- message -- The message to display
|
||||
- style -- The type of the message. Possible values are:
|
||||
info, success, warning
|
||||
|
||||
"""
|
||||
try:
|
||||
self._display(message, style)
|
||||
except NotImplementedError:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def _notimplemented(*args, **kwargs):
|
||||
raise NotImplementedError("this signal is not handled")
|
||||
|
||||
|
||||
# Interfaces & Authenticators management -------------------------------
|
||||
|
||||
def init_interface(name, kwargs={}, actionsmap={}):
|
||||
"""Return a new interface instance
|
||||
|
||||
Retrieve the given interface module and return a new instance of its
|
||||
Interface class. It is initialized with arguments 'kwargs' and
|
||||
connected to 'actionsmap' if it's an ActionsMap object, otherwise
|
||||
a new ActionsMap instance will be initialized with arguments
|
||||
'actionsmap'.
|
||||
|
||||
Keyword arguments:
|
||||
- name -- The interface name
|
||||
- kwargs -- A dict of arguments to pass to Interface
|
||||
- actionsmap -- Either an ActionsMap instance or a dict of
|
||||
arguments to pass to ActionsMap
|
||||
|
||||
"""
|
||||
from moulinette.actionsmap import ActionsMap
|
||||
|
||||
try:
|
||||
mod = import_module('moulinette.interfaces.%s' % name)
|
||||
except ImportError:
|
||||
logger.exception("unable to load interface '%s'", name)
|
||||
raise MoulinetteError(errno.EINVAL, moulinette.m18n.g('error_see_log'))
|
||||
else:
|
||||
try:
|
||||
# Retrieve interface classes
|
||||
parser = mod.ActionsMapParser
|
||||
interface = mod.Interface
|
||||
except AttributeError:
|
||||
logger.exception("unable to retrieve classes of interface '%s'", name)
|
||||
raise MoulinetteError(errno.EIO, moulinette.m18n.g('error_see_log'))
|
||||
|
||||
# Instantiate or retrieve ActionsMap
|
||||
if isinstance(actionsmap, dict):
|
||||
amap = ActionsMap(actionsmap.pop('parser', parser), **actionsmap)
|
||||
elif isinstance(actionsmap, ActionsMap):
|
||||
amap = actionsmap
|
||||
else:
|
||||
logger.error("invalid actionsmap value %r", actionsmap)
|
||||
raise MoulinetteError(errno.EINVAL, moulinette.m18n.g('error_see_log'))
|
||||
|
||||
return interface(amap, **kwargs)
|
||||
|
||||
|
||||
def init_authenticator((vendor, name), kwargs={}):
|
||||
"""Return a new authenticator instance
|
||||
|
||||
Retrieve the given authenticator vendor and return a new instance of
|
||||
its Authenticator class for the given profile.
|
||||
|
||||
Keyword arguments:
|
||||
- vendor -- The authenticator vendor name
|
||||
- name -- The authenticator profile name
|
||||
- kwargs -- A dict of arguments for the authenticator profile
|
||||
|
||||
"""
|
||||
try:
|
||||
mod = import_module('moulinette.authenticators.%s' % vendor)
|
||||
except ImportError:
|
||||
logger.exception("unable to load authenticator vendor '%s'", vendor)
|
||||
raise MoulinetteError(errno.EINVAL, moulinette.m18n.g('error_see_log'))
|
||||
else:
|
||||
return mod.Authenticator(name, **kwargs)
|
||||
|
||||
|
||||
def clean_session(session_id, profiles=[]):
|
||||
"""Clean a session cache
|
||||
|
||||
Remove cache for the session 'session_id' and for profiles in
|
||||
'profiles' or for all of them if the list is empty.
|
||||
|
||||
Keyword arguments:
|
||||
- session_id -- The session id to clean
|
||||
- profiles -- A list of profiles to clean
|
||||
|
||||
"""
|
||||
sessiondir = get_cachedir('session')
|
||||
if not profiles:
|
||||
profiles = os.listdir(sessiondir)
|
||||
|
||||
for p in profiles:
|
||||
try:
|
||||
os.unlink(os.path.join(sessiondir, p, '%s.asc' % session_id))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
# Moulinette core classes ----------------------------------------------
|
||||
|
||||
|
||||
class MoulinetteError(Exception):
|
||||
http_code = 500
|
||||
|
||||
class MoulinetteError(OSError):
|
||||
"""Moulinette base exception"""
|
||||
|
||||
def __init__(self, key, raw_msg=False, *args, **kwargs):
|
||||
if raw_msg:
|
||||
msg = key
|
||||
else:
|
||||
msg = moulinette.m18n.g(key, *args, **kwargs)
|
||||
super(MoulinetteError, self).__init__(msg)
|
||||
self.strerror = msg
|
||||
|
||||
def content(self) -> str:
|
||||
return self.strerror
|
||||
pass
|
||||
|
||||
|
||||
class MoulinetteValidationError(MoulinetteError):
|
||||
http_code = 400
|
||||
|
||||
|
||||
class MoulinetteAuthenticationError(MoulinetteError):
|
||||
http_code = 401
|
||||
|
||||
|
||||
class MoulinetteLock:
|
||||
class MoulinetteLock(object):
|
||||
"""Locker for a moulinette instance
|
||||
|
||||
It provides a lock mechanism for a given moulinette instance. It can
|
||||
|
@ -282,15 +431,12 @@ class MoulinetteLock:
|
|||
|
||||
"""
|
||||
|
||||
base_lockfile = "/var/run/moulinette_%s.lock"
|
||||
|
||||
def __init__(self, namespace, timeout=None, enable_lock=True, interval=0.5):
|
||||
def __init__(self, namespace, timeout=None, interval=.5):
|
||||
self.namespace = namespace
|
||||
self.timeout = timeout
|
||||
self.interval = interval
|
||||
self.enable_lock = enable_lock
|
||||
|
||||
self._lockfile = self.base_lockfile % namespace
|
||||
self._lockfile = '/var/run/moulinette_%s.lock' % namespace
|
||||
self._stale_checked = False
|
||||
self._locked = False
|
||||
|
||||
|
@ -304,16 +450,8 @@ class MoulinetteLock:
|
|||
"""
|
||||
start_time = time.time()
|
||||
|
||||
# for UX reason, we are going to warn the user that we are waiting for
|
||||
# another yunohost command to end, otherwise the user is very confused
|
||||
# and don't understand that and think yunohost is broken
|
||||
# we are going to warn the user after 15 seconds of waiting time then
|
||||
# after 15*4 seconds, then 15*4*4 seconds...
|
||||
warning_treshold = 15
|
||||
|
||||
logger.debug("acquiring lock...")
|
||||
|
||||
while True:
|
||||
|
||||
lock_pids = self._lock_PIDs()
|
||||
|
||||
if self._is_son_of(lock_pids):
|
||||
|
@ -327,34 +465,18 @@ class MoulinetteLock:
|
|||
# Check locked process still exist and take lock if it doesnt
|
||||
# FIXME : what do in the context of multiple locks :|
|
||||
first_lock = lock_pids[0]
|
||||
if not os.path.exists(os.path.join("/proc", str(first_lock), "exe")):
|
||||
logger.debug("stale lock file found")
|
||||
if not os.path.exists(os.path.join('/proc', str(first_lock), 'exe')):
|
||||
logger.debug('stale lock file found')
|
||||
self._lock()
|
||||
break
|
||||
|
||||
if self.timeout is not None and (time.time() - start_time) > self.timeout:
|
||||
raise MoulinetteError("instance_already_running")
|
||||
|
||||
# warn the user if it's been too much time since they are waiting
|
||||
if (time.time() - start_time) > warning_treshold:
|
||||
if warning_treshold == 15:
|
||||
logger.warning(
|
||||
moulinette.m18n.g("warn_the_user_about_waiting_lock")
|
||||
)
|
||||
else:
|
||||
logger.warning(
|
||||
moulinette.m18n.g("warn_the_user_about_waiting_lock_again")
|
||||
)
|
||||
warning_treshold *= 4
|
||||
|
||||
raise MoulinetteError(errno.EBUSY,
|
||||
moulinette.m18n.g('instance_already_running'))
|
||||
# Wait before checking again
|
||||
time.sleep(self.interval)
|
||||
|
||||
# we have warned the user that we were waiting, for better UX also them
|
||||
# that we have stop waiting and that the command is processing now
|
||||
if warning_treshold != 15:
|
||||
logger.warning(moulinette.m18n.g("warn_the_user_that_lock_is_acquired"))
|
||||
logger.debug("lock has been acquired")
|
||||
logger.debug('lock has been acquired')
|
||||
self._locked = True
|
||||
|
||||
def release(self):
|
||||
|
@ -364,36 +486,34 @@ class MoulinetteLock:
|
|||
|
||||
"""
|
||||
if self._locked:
|
||||
if os.path.exists(self._lockfile):
|
||||
os.unlink(self._lockfile)
|
||||
else:
|
||||
logger.warning(
|
||||
"Uhoh, somehow the lock %s did not exist ..." % self._lockfile
|
||||
)
|
||||
logger.debug("lock has been released")
|
||||
logger.debug('lock has been released')
|
||||
self._locked = False
|
||||
|
||||
def _lock(self):
|
||||
try:
|
||||
with open(self._lockfile, "w") as f:
|
||||
with open(self._lockfile, 'w') as f:
|
||||
f.write(str(os.getpid()))
|
||||
except IOError:
|
||||
raise MoulinetteError("root_required")
|
||||
raise MoulinetteError(
|
||||
errno.EPERM, '%s. %s.'.format(
|
||||
moulinette.m18n.g('permission_denied'),
|
||||
moulinette.m18n.g('root_required')))
|
||||
|
||||
def _lock_PIDs(self):
|
||||
|
||||
if not os.path.isfile(self._lockfile):
|
||||
return []
|
||||
|
||||
with open(self._lockfile) as f:
|
||||
lock_pids = f.read().strip().split("\n")
|
||||
lock_pids = f.read().strip().split('\n')
|
||||
|
||||
# Make sure to convert those pids to integers
|
||||
lock_pids = [int(pid) for pid in lock_pids if pid.strip() != ""]
|
||||
lock_pids = [int(pid) for pid in lock_pids if pid.strip() != '']
|
||||
|
||||
return lock_pids
|
||||
|
||||
def _is_son_of(self, lock_pids):
|
||||
import psutil
|
||||
|
||||
if lock_pids == []:
|
||||
return False
|
||||
|
@ -413,7 +533,7 @@ class MoulinetteLock:
|
|||
return False
|
||||
|
||||
def __enter__(self):
|
||||
if self.enable_lock and not self._locked:
|
||||
if not self._locked:
|
||||
self.acquire()
|
||||
return self
|
||||
|
||||
|
|
4
moulinette/globals.py
Normal file
4
moulinette/globals.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
DATA_DIR = '/usr/share/moulinette'
|
||||
LIB_DIR = '/usr/lib/moulinette'
|
||||
LOCALES_DIR = '/usr/share/moulinette/locale'
|
||||
CACHE_DIR = '/var/cache/moulinette'
|
|
@ -1,23 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import os
|
||||
import errno
|
||||
import logging
|
||||
import argparse
|
||||
import copy
|
||||
import datetime
|
||||
from collections import OrderedDict
|
||||
from json.encoder import JSONEncoder
|
||||
from typing import Optional
|
||||
from collections import deque, OrderedDict
|
||||
|
||||
from moulinette import m18n
|
||||
from moulinette import msignals, msettings, m18n
|
||||
from moulinette.core import (init_authenticator, MoulinetteError)
|
||||
|
||||
logger = logging.getLogger("moulinette.interface")
|
||||
logger = logging.getLogger('moulinette.interface')
|
||||
|
||||
GLOBAL_SECTION = '_global'
|
||||
TO_RETURN_PROP = '_to_return'
|
||||
CALLBACKS_PROP = '_callbacks'
|
||||
|
||||
|
||||
# Base Class -----------------------------------------------------------
|
||||
|
||||
|
||||
class BaseActionsMapParser:
|
||||
class BaseActionsMapParser(object):
|
||||
"""Actions map's base Parser
|
||||
|
||||
Each interfaces must implement an ActionsMapParser class derived
|
||||
|
@ -32,20 +35,28 @@ class BaseActionsMapParser:
|
|||
"""
|
||||
|
||||
def __init__(self, parent=None, **kwargs):
|
||||
if not parent:
|
||||
logger.debug("initializing base actions map parser for %s", self.interface)
|
||||
if parent:
|
||||
self._o = parent
|
||||
else:
|
||||
logger.debug('initializing base actions map parser for %s',
|
||||
self.interface)
|
||||
msettings['interface'] = self.interface
|
||||
|
||||
self._o = self
|
||||
self._global_conf = {}
|
||||
self._conf = {}
|
||||
|
||||
# Virtual properties
|
||||
# Each parser classes must implement these properties.
|
||||
|
||||
"""The name of the interface for which it is the parser"""
|
||||
interface: Optional[str] = None
|
||||
interface = None
|
||||
|
||||
# Virtual methods
|
||||
# Each parser classes must implement these methods.
|
||||
|
||||
@staticmethod
|
||||
def format_arg_names(name, full):
|
||||
def format_arg_names(self, name, full):
|
||||
"""Format argument name
|
||||
|
||||
Format agument name depending on its 'full' parameter and return
|
||||
|
@ -60,7 +71,8 @@ class BaseActionsMapParser:
|
|||
A list of option strings
|
||||
|
||||
"""
|
||||
raise NotImplementedError("derived class must override this method")
|
||||
raise NotImplementedError("derived class '%s' must override this method" %
|
||||
self.__class__.__name__)
|
||||
|
||||
def has_global_parser(self):
|
||||
return False
|
||||
|
@ -74,9 +86,8 @@ class BaseActionsMapParser:
|
|||
An ArgumentParser based object
|
||||
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"derived class '%s' must override this method" % self.__class__.__name__
|
||||
)
|
||||
raise NotImplementedError("derived class '%s' must override this method" %
|
||||
self.__class__.__name__)
|
||||
|
||||
def add_category_parser(self, name, **kwargs):
|
||||
"""Add a parser for a category
|
||||
|
@ -90,9 +101,8 @@ class BaseActionsMapParser:
|
|||
A BaseParser based object
|
||||
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"derived class '%s' must override this method" % self.__class__.__name__
|
||||
)
|
||||
raise NotImplementedError("derived class '%s' must override this method" %
|
||||
self.__class__.__name__)
|
||||
|
||||
def add_action_parser(self, name, tid, **kwargs):
|
||||
"""Add a parser for an action
|
||||
|
@ -107,23 +117,8 @@ class BaseActionsMapParser:
|
|||
An ArgumentParser based object
|
||||
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"derived class '%s' must override this method" % self.__class__.__name__
|
||||
)
|
||||
|
||||
def auth_method(self, *args, **kwargs):
|
||||
"""Check if authentication is required to run the requested action
|
||||
|
||||
Keyword arguments:
|
||||
- args -- Arguments string or dict (TODO)
|
||||
|
||||
Returns:
|
||||
False, or the authentication profile required
|
||||
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"derived class '%s' must override this method" % self.__class__.__name__
|
||||
)
|
||||
raise NotImplementedError("derived class '%s' must override this method" %
|
||||
self.__class__.__name__)
|
||||
|
||||
def parse_args(self, args, **kwargs):
|
||||
"""Parse arguments
|
||||
|
@ -138,13 +133,309 @@ class BaseActionsMapParser:
|
|||
The populated namespace
|
||||
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"derived class '%s' must override this method" % self.__class__.__name__
|
||||
)
|
||||
raise NotImplementedError("derived class '%s' must override this method" %
|
||||
self.__class__.__name__)
|
||||
|
||||
# Arguments helpers
|
||||
|
||||
def prepare_action_namespace(self, tid, namespace=None):
|
||||
"""Prepare the namespace for a given action"""
|
||||
# Validate tid and namespace
|
||||
if not isinstance(tid, tuple) and \
|
||||
(namespace is None or not hasattr(namespace, TO_RETURN_PROP)):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('invalid_usage'))
|
||||
elif not tid:
|
||||
tid = GLOBAL_SECTION
|
||||
|
||||
# Prepare namespace
|
||||
if namespace is None:
|
||||
namespace = argparse.Namespace()
|
||||
namespace._tid = tid
|
||||
|
||||
# Perform authentication if needed
|
||||
if self.get_conf(tid, 'authenticate'):
|
||||
auth_conf, cls = self.get_conf(tid, 'authenticator')
|
||||
|
||||
# TODO: Catch errors
|
||||
auth = msignals.authenticate(cls(), **auth_conf)
|
||||
if not auth.is_authenticated:
|
||||
raise MoulinetteError(errno.EACCES,
|
||||
m18n.g('authentication_required_long'))
|
||||
if self.get_conf(tid, 'argument_auth') and \
|
||||
self.get_conf(tid, 'authenticate') == 'all':
|
||||
namespace.auth = auth
|
||||
|
||||
return namespace
|
||||
|
||||
# Configuration access
|
||||
|
||||
@property
|
||||
def global_conf(self):
|
||||
"""Return the global configuration of the parser"""
|
||||
return self._o._global_conf
|
||||
|
||||
def get_global_conf(self, name, profile='default'):
|
||||
"""Get the global value of a configuration
|
||||
|
||||
Return the formated global value of the configuration 'name' for
|
||||
the given profile. If the configuration doesn't provide profile,
|
||||
the formated default value is returned.
|
||||
|
||||
Keyword arguments:
|
||||
- name -- The configuration name
|
||||
- profile -- The profile of the configuration
|
||||
|
||||
"""
|
||||
if name == 'authenticator':
|
||||
value = self.global_conf[name][profile]
|
||||
else:
|
||||
value = self.global_conf[name]
|
||||
return self._format_conf(name, value)
|
||||
|
||||
def set_global_conf(self, configuration):
|
||||
"""Set global configuration
|
||||
|
||||
Set the global configuration to use for the parser.
|
||||
|
||||
Keyword arguments:
|
||||
- configuration -- The global configuration
|
||||
|
||||
"""
|
||||
self._o._global_conf.update(self._validate_conf(configuration, True))
|
||||
|
||||
def get_conf(self, action, name):
|
||||
"""Get the value of an action configuration
|
||||
|
||||
Return the formated value of configuration 'name' for the action
|
||||
identified by 'action'. If the configuration for the action is
|
||||
not set, the default one is returned.
|
||||
|
||||
Keyword arguments:
|
||||
- action -- An action identifier
|
||||
- name -- The configuration name
|
||||
|
||||
"""
|
||||
try:
|
||||
value = self._o._conf[action][name]
|
||||
except KeyError:
|
||||
return self.get_global_conf(name)
|
||||
else:
|
||||
return self._format_conf(name, value)
|
||||
|
||||
def set_conf(self, action, configuration):
|
||||
"""Set configuration for an action
|
||||
|
||||
Set the configuration to use for a given action identified by
|
||||
'action' which is specific to the parser.
|
||||
|
||||
Keyword arguments:
|
||||
- action -- The action identifier
|
||||
- configuration -- The configuration for the action
|
||||
|
||||
"""
|
||||
self._o._conf[action] = self._validate_conf(configuration)
|
||||
|
||||
def _validate_conf(self, configuration, is_global=False):
|
||||
"""Validate configuration for the parser
|
||||
|
||||
Return the validated configuration for the interface's actions
|
||||
map parser.
|
||||
|
||||
Keyword arguments:
|
||||
- configuration -- The configuration to pre-format
|
||||
|
||||
"""
|
||||
# TODO: Create a class with a validator method for each configuration
|
||||
conf = {}
|
||||
|
||||
# -- 'authenficate'
|
||||
try:
|
||||
ifaces = configuration['authenticate']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
if ifaces == 'all':
|
||||
conf['authenticate'] = ifaces
|
||||
elif ifaces is False:
|
||||
conf['authenticate'] = False
|
||||
elif isinstance(ifaces, list):
|
||||
# Store only if authentication is needed
|
||||
conf['authenticate'] = True if self.interface in ifaces else False
|
||||
else:
|
||||
logger.error("expecting 'all', 'False' or a list for "
|
||||
"configuration 'authenticate', got %r", ifaces)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
|
||||
# -- 'authenticator'
|
||||
try:
|
||||
auth = configuration['authenticator']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
if not is_global and isinstance(auth, str):
|
||||
try:
|
||||
# Store needed authenticator profile
|
||||
conf['authenticator'] = self.global_conf['authenticator'][auth]
|
||||
except KeyError:
|
||||
logger.error("requesting profile '%s' which is undefined in "
|
||||
"global configuration of 'authenticator'", auth)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
elif is_global and isinstance(auth, dict):
|
||||
if len(auth) == 0:
|
||||
logger.warning('no profile defined in global configuration '
|
||||
"for 'authenticator'")
|
||||
else:
|
||||
auths = {}
|
||||
for auth_name, auth_conf in auth.items():
|
||||
# Add authenticator profile as a 3-tuple
|
||||
# (identifier, configuration, parameters) with
|
||||
# - identifier: the authenticator vendor and its
|
||||
# profile name as a 2-tuple
|
||||
# - configuration: a dict of additional global
|
||||
# configuration (i.e. 'help')
|
||||
# - parameters: a dict of arguments for the
|
||||
# authenticator profile
|
||||
auths[auth_name] = ((auth_conf.get('vendor'), auth_name),
|
||||
{'help': auth_conf.get('help', None)},
|
||||
auth_conf.get('parameters', {}))
|
||||
conf['authenticator'] = auths
|
||||
else:
|
||||
logger.error("expecting a dict of profile(s) or a profile name "
|
||||
"for configuration 'authenticator', got %r", auth)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
|
||||
# -- 'argument_auth'
|
||||
try:
|
||||
arg_auth = configuration['argument_auth']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
if isinstance(arg_auth, bool):
|
||||
conf['argument_auth'] = arg_auth
|
||||
else:
|
||||
logger.error("expecting a boolean for configuration "
|
||||
"'argument_auth', got %r", arg_auth)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
|
||||
# -- 'lock'
|
||||
try:
|
||||
lock = configuration['lock']
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
if isinstance(lock, bool):
|
||||
conf['lock'] = lock
|
||||
else:
|
||||
logger.error("expecting a boolean for configuration 'lock', "
|
||||
"got %r", lock)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
|
||||
return conf
|
||||
|
||||
def _format_conf(self, name, value):
|
||||
"""Format a configuration value
|
||||
|
||||
Return the formated value of the configuration 'name' from its
|
||||
given value.
|
||||
|
||||
Keyword arguments:
|
||||
- name -- The name of the configuration
|
||||
- value -- The value to format
|
||||
|
||||
"""
|
||||
if name == 'authenticator' and value:
|
||||
(identifier, configuration, parameters) = value
|
||||
|
||||
# Return global configuration and an authenticator
|
||||
# instanciator as a 2-tuple
|
||||
return (configuration,
|
||||
lambda: init_authenticator(identifier, parameters))
|
||||
|
||||
return value
|
||||
|
||||
|
||||
class BaseInterface(object):
|
||||
"""Moulinette's base Interface
|
||||
|
||||
Each interfaces must implement an Interface class derived from this
|
||||
class which must overrides virtual properties and methods.
|
||||
It is used to provide a user interface for an actions map.
|
||||
|
||||
Keyword arguments:
|
||||
- actionsmap -- The ActionsMap instance to connect to
|
||||
|
||||
"""
|
||||
# TODO: Add common interface methods and try to standardize default ones
|
||||
|
||||
def __init__(self, actionsmap):
|
||||
raise NotImplementedError("derived class '%s' must override this method" %
|
||||
self.__class__.__name__)
|
||||
|
||||
|
||||
# Argument parser ------------------------------------------------------
|
||||
|
||||
class _CallbackAction(argparse.Action):
|
||||
|
||||
def __init__(self,
|
||||
option_strings,
|
||||
dest,
|
||||
nargs=0,
|
||||
callback={},
|
||||
default=argparse.SUPPRESS,
|
||||
help=None):
|
||||
if not callback or 'method' not in callback:
|
||||
raise ValueError('callback must be provided with at least '
|
||||
'a method key')
|
||||
super(_CallbackAction, self).__init__(
|
||||
option_strings=option_strings,
|
||||
dest=dest,
|
||||
nargs=nargs,
|
||||
default=default,
|
||||
help=help)
|
||||
self.callback_method = callback.get('method')
|
||||
self.callback_kwargs = callback.get('kwargs', {})
|
||||
self.callback_return = callback.get('return', False)
|
||||
logger.debug("registering new callback action '{0}' to {1}".format(
|
||||
self.callback_method, option_strings))
|
||||
|
||||
@property
|
||||
def callback(self):
|
||||
if not hasattr(self, '_callback'):
|
||||
self._retrieve_callback()
|
||||
return self._callback
|
||||
|
||||
def _retrieve_callback(self):
|
||||
# Attempt to retrieve callback method
|
||||
mod_name, func_name = (self.callback_method).rsplit('.', 1)
|
||||
try:
|
||||
mod = __import__(mod_name, globals=globals(), level=0,
|
||||
fromlist=[func_name])
|
||||
func = getattr(mod, func_name)
|
||||
except (AttributeError, ImportError):
|
||||
raise ValueError('unable to import method {0}'.format(
|
||||
self.callback_method))
|
||||
self._callback = func
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
parser.enqueue_callback(namespace, self, values)
|
||||
if self.callback_return:
|
||||
setattr(namespace, TO_RETURN_PROP, {})
|
||||
|
||||
def execute(self, namespace, values):
|
||||
try:
|
||||
# Execute callback and get returned value
|
||||
value = self.callback(namespace, values, **self.callback_kwargs)
|
||||
except:
|
||||
logger.exception("cannot get value from callback method "
|
||||
"'{0}'".format(self.callback_method))
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
else:
|
||||
if value:
|
||||
if self.callback_return:
|
||||
setattr(namespace, TO_RETURN_PROP, value)
|
||||
else:
|
||||
setattr(namespace, self.dest, value)
|
||||
|
||||
|
||||
class _ExtendedSubParsersAction(argparse._SubParsersAction):
|
||||
"""Subparsers with extended properties for argparse
|
||||
|
@ -161,25 +452,23 @@ class _ExtendedSubParsersAction(argparse._SubParsersAction):
|
|||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
required = kwargs.pop("required", False)
|
||||
required = kwargs.pop('required', False)
|
||||
super(_ExtendedSubParsersAction, self).__init__(*args, **kwargs)
|
||||
|
||||
self.required = required
|
||||
self._deprecated_command_map = {}
|
||||
|
||||
def add_parser(self, name, type_=None, **kwargs):
|
||||
hide_in_help = kwargs.pop("hide_in_help", False)
|
||||
deprecated = kwargs.pop("deprecated", False)
|
||||
deprecated_alias = kwargs.pop("deprecated_alias", [])
|
||||
deprecated = kwargs.pop('deprecated', False)
|
||||
deprecated_alias = kwargs.pop('deprecated_alias', [])
|
||||
|
||||
if deprecated:
|
||||
self._deprecated_command_map[name] = None
|
||||
if 'help' in kwargs:
|
||||
del kwargs['help']
|
||||
|
||||
if deprecated or hide_in_help:
|
||||
if "help" in kwargs:
|
||||
del kwargs["help"]
|
||||
|
||||
parser = super(_ExtendedSubParsersAction, self).add_parser(name, **kwargs)
|
||||
parser = super(_ExtendedSubParsersAction, self).add_parser(
|
||||
name, **kwargs)
|
||||
|
||||
# Append each deprecated command alias name
|
||||
for command in deprecated_alias:
|
||||
|
@ -201,61 +490,78 @@ class _ExtendedSubParsersAction(argparse._SubParsersAction):
|
|||
else:
|
||||
# Warn the user about deprecated command
|
||||
if correct_name is None:
|
||||
logger.warning(
|
||||
m18n.g("deprecated_command", prog=parser.prog, command=parser_name)
|
||||
)
|
||||
logger.warning(m18n.g('deprecated_command', prog=parser.prog,
|
||||
command=parser_name))
|
||||
else:
|
||||
logger.warning(
|
||||
m18n.g(
|
||||
"deprecated_command_alias",
|
||||
old=parser_name,
|
||||
new=correct_name,
|
||||
prog=parser.prog,
|
||||
)
|
||||
)
|
||||
logger.warning(m18n.g('deprecated_command_alias',
|
||||
old=parser_name, new=correct_name,
|
||||
prog=parser.prog))
|
||||
values[0] = correct_name
|
||||
|
||||
return super(_ExtendedSubParsersAction, self).__call__(
|
||||
parser, namespace, values, option_string
|
||||
)
|
||||
parser, namespace, values, option_string)
|
||||
|
||||
|
||||
class ExtendedArgumentParser(argparse.ArgumentParser):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ExtendedArgumentParser, self).__init__(
|
||||
formatter_class=PositionalsFirstHelpFormatter, *args, **kwargs
|
||||
)
|
||||
super(ExtendedArgumentParser, self).__init__(formatter_class=PositionalsFirstHelpFormatter,
|
||||
*args, **kwargs)
|
||||
|
||||
# Register additional actions
|
||||
self.register("action", "parsers", _ExtendedSubParsersAction)
|
||||
self.register('action', 'callback', _CallbackAction)
|
||||
self.register('action', 'parsers', _ExtendedSubParsersAction)
|
||||
|
||||
def add_arguments(
|
||||
self, arguments, extraparser, format_arg_names=None, validate_extra=True
|
||||
):
|
||||
def enqueue_callback(self, namespace, callback, values):
|
||||
queue = self._get_callbacks_queue(namespace)
|
||||
queue.append((callback, values))
|
||||
|
||||
def dequeue_callbacks(self, namespace):
|
||||
queue = self._get_callbacks_queue(namespace, False)
|
||||
for _i in xrange(len(queue)):
|
||||
c, v = queue.popleft()
|
||||
# FIXME: break dequeue if callback returns
|
||||
c.execute(namespace, v)
|
||||
try:
|
||||
delattr(namespace, CALLBACKS_PROP)
|
||||
except:
|
||||
pass
|
||||
|
||||
def _get_callbacks_queue(self, namespace, create=True):
|
||||
try:
|
||||
queue = getattr(namespace, CALLBACKS_PROP)
|
||||
except AttributeError:
|
||||
if create:
|
||||
queue = deque()
|
||||
setattr(namespace, CALLBACKS_PROP, queue)
|
||||
else:
|
||||
queue = list()
|
||||
return queue
|
||||
|
||||
def add_arguments(self, arguments, extraparser, format_arg_names=None, validate_extra=True):
|
||||
for argument_name, argument_options in arguments.items():
|
||||
# will adapt arguments name for cli or api context
|
||||
names = format_arg_names(
|
||||
str(argument_name), argument_options.pop("full", None)
|
||||
)
|
||||
names = format_arg_names(str(argument_name),
|
||||
argument_options.pop('full', None))
|
||||
|
||||
if "type" in argument_options:
|
||||
argument_options["type"] = eval(argument_options["type"])
|
||||
argument_options['type'] = eval(argument_options['type'])
|
||||
|
||||
if "extra" in argument_options:
|
||||
extra = argument_options.pop("extra")
|
||||
extra = argument_options.pop('extra')
|
||||
argument_dest = self.add_argument(*names, **argument_options).dest
|
||||
extraparser.add_argument(
|
||||
self.get_default("_tid"), argument_dest, extra, validate_extra
|
||||
)
|
||||
extraparser.add_argument(self.get_default("_tid"),
|
||||
argument_dest, extra, validate_extra)
|
||||
continue
|
||||
|
||||
self.add_argument(*names, **argument_options)
|
||||
|
||||
def _get_nargs_pattern(self, action):
|
||||
if action.nargs == argparse.PARSER and not action.required:
|
||||
return "([-AO]*)"
|
||||
return '([-AO]*)'
|
||||
else:
|
||||
return super(ExtendedArgumentParser, self)._get_nargs_pattern(action)
|
||||
return super(ExtendedArgumentParser, self)._get_nargs_pattern(
|
||||
action)
|
||||
|
||||
def _get_values(self, action, arg_strings):
|
||||
if action.nargs == argparse.PARSER and not action.required:
|
||||
|
@ -265,7 +571,8 @@ class ExtendedArgumentParser(argparse.ArgumentParser):
|
|||
else:
|
||||
value = argparse.SUPPRESS
|
||||
else:
|
||||
value = super(ExtendedArgumentParser, self)._get_values(action, arg_strings)
|
||||
value = super(ExtendedArgumentParser, self)._get_values(
|
||||
action, arg_strings)
|
||||
return value
|
||||
|
||||
# Adapted from :
|
||||
|
@ -274,54 +581,41 @@ class ExtendedArgumentParser(argparse.ArgumentParser):
|
|||
formatter = self._get_formatter()
|
||||
|
||||
# usage
|
||||
formatter.add_usage(self.usage, self._actions, self._mutually_exclusive_groups)
|
||||
formatter.add_usage(self.usage, self._actions,
|
||||
self._mutually_exclusive_groups)
|
||||
|
||||
# description
|
||||
formatter.add_text(self.description)
|
||||
|
||||
# positionals, optionals and user-defined groups
|
||||
for action_group in self._action_groups:
|
||||
|
||||
# Dirty hack to separate 'subcommands'
|
||||
# into 'actions' and 'subcategories'
|
||||
if action_group.title == "subcommands":
|
||||
|
||||
# Make a copy of the "action group actions"...
|
||||
choice_actions = action_group._group_actions[0]._choices_actions
|
||||
actions_subparser = copy.copy(action_group._group_actions[0])
|
||||
subcategories_subparser = copy.copy(action_group._group_actions[0])
|
||||
|
||||
# Filter "action"-type and "subcategory"-type commands
|
||||
actions_subparser.choices = OrderedDict(
|
||||
[
|
||||
(k, v)
|
||||
for k, v in actions_subparser.choices.items()
|
||||
if v.type == "action"
|
||||
]
|
||||
)
|
||||
subcategories_subparser.choices = OrderedDict(
|
||||
[
|
||||
(k, v)
|
||||
for k, v in subcategories_subparser.choices.items()
|
||||
if v.type == "subcategory"
|
||||
]
|
||||
)
|
||||
actions_subparser.choices = OrderedDict([(k, v) for k, v in actions_subparser.choices.items() if v.type == "action"])
|
||||
subcategories_subparser.choices = OrderedDict([(k, v) for k, v in subcategories_subparser.choices.items() if v.type == "subcategory"])
|
||||
|
||||
actions_choices = actions_subparser.choices.keys()
|
||||
subcategories_choices = subcategories_subparser.choices.keys()
|
||||
|
||||
actions_subparser._choices_actions = [
|
||||
c for c in choice_actions if c.dest in actions_choices
|
||||
]
|
||||
subcategories_subparser._choices_actions = [
|
||||
c for c in choice_actions if c.dest in subcategories_choices
|
||||
]
|
||||
actions_subparser._choices_actions = [c for c in choice_actions if c.dest in actions_choices]
|
||||
subcategories_subparser._choices_actions = [c for c in choice_actions if c.dest in subcategories_choices]
|
||||
|
||||
# Display each section (actions and subcategories)
|
||||
if actions_choices:
|
||||
if actions_choices != []:
|
||||
formatter.start_section("actions")
|
||||
formatter.add_arguments([actions_subparser])
|
||||
formatter.end_section()
|
||||
|
||||
if subcategories_choices:
|
||||
if subcategories_choices != []:
|
||||
formatter.start_section("subcategories")
|
||||
formatter.add_arguments([subcategories_subparser])
|
||||
formatter.end_section()
|
||||
|
@ -348,10 +642,11 @@ class ExtendedArgumentParser(argparse.ArgumentParser):
|
|||
# and fix is inspired from here :
|
||||
# https://stackoverflow.com/questions/26985650/argparse-do-not-catch-positional-arguments-with-nargs/26986546#26986546
|
||||
class PositionalsFirstHelpFormatter(argparse.HelpFormatter):
|
||||
|
||||
def _format_usage(self, usage, actions, groups, prefix):
|
||||
if prefix is None:
|
||||
# TWEAK : not using gettext here...
|
||||
prefix = "usage: "
|
||||
prefix = 'usage: '
|
||||
|
||||
# if usage is specified, use that
|
||||
if usage is not None:
|
||||
|
@ -359,11 +654,11 @@ class PositionalsFirstHelpFormatter(argparse.HelpFormatter):
|
|||
|
||||
# if no optionals or positionals are available, usage is just prog
|
||||
elif usage is None and not actions:
|
||||
usage = "%(prog)s" % dict(prog=self._prog)
|
||||
usage = '%(prog)s' % dict(prog=self._prog)
|
||||
|
||||
# if optionals and positionals are available, calculate usage
|
||||
elif usage is None:
|
||||
prog = "%(prog)s" % dict(prog=self._prog)
|
||||
prog = '%(prog)s' % dict(prog=self._prog)
|
||||
|
||||
# split optionals from positionals
|
||||
optionals = []
|
||||
|
@ -378,19 +673,20 @@ class PositionalsFirstHelpFormatter(argparse.HelpFormatter):
|
|||
format = self._format_actions_usage
|
||||
# TWEAK here : positionals first
|
||||
action_usage = format(positionals + optionals, groups)
|
||||
usage = " ".join([s for s in [prog, action_usage] if s])
|
||||
usage = ' '.join([s for s in [prog, action_usage] if s])
|
||||
|
||||
# wrap the usage parts if it's too long
|
||||
text_width = self._width - self._current_indent
|
||||
if len(prefix) + len(usage) > text_width:
|
||||
|
||||
# break usage into wrappable parts
|
||||
part_regexp = r"\(.*?\)+|\[.*?\]+|\S+"
|
||||
part_regexp = r'\(.*?\)+|\[.*?\]+|\S+'
|
||||
opt_usage = format(optionals, groups)
|
||||
pos_usage = format(positionals, groups)
|
||||
opt_parts = re.findall(part_regexp, opt_usage)
|
||||
pos_parts = re.findall(part_regexp, pos_usage)
|
||||
assert " ".join(opt_parts) == opt_usage
|
||||
assert " ".join(pos_parts) == pos_usage
|
||||
assert ' '.join(opt_parts) == opt_usage
|
||||
assert ' '.join(pos_parts) == pos_usage
|
||||
|
||||
# helper for wrapping lines
|
||||
def get_lines(parts, indent, prefix=None):
|
||||
|
@ -402,20 +698,20 @@ class PositionalsFirstHelpFormatter(argparse.HelpFormatter):
|
|||
line_len = len(indent) - 1
|
||||
for part in parts:
|
||||
if line_len + 1 + len(part) > text_width:
|
||||
lines.append(indent + " ".join(line))
|
||||
lines.append(indent + ' '.join(line))
|
||||
line = []
|
||||
line_len = len(indent) - 1
|
||||
line.append(part)
|
||||
line_len += len(part) + 1
|
||||
if line:
|
||||
lines.append(indent + " ".join(line))
|
||||
lines.append(indent + ' '.join(line))
|
||||
if prefix is not None:
|
||||
lines[0] = lines[0][len(indent) :]
|
||||
lines[0] = lines[0][len(indent):]
|
||||
return lines
|
||||
|
||||
# if prog is short, follow it with optionals or positionals
|
||||
if len(prefix) + len(prog) <= 0.75 * text_width:
|
||||
indent = " " * (len(prefix) + len(prog) + 1)
|
||||
indent = ' ' * (len(prefix) + len(prog) + 1)
|
||||
# START TWEAK : pos_parts first, then opt_parts
|
||||
if pos_parts:
|
||||
lines = get_lines([prog] + pos_parts, indent, prefix)
|
||||
|
@ -428,7 +724,7 @@ class PositionalsFirstHelpFormatter(argparse.HelpFormatter):
|
|||
|
||||
# if prog is long, put it on its own line
|
||||
else:
|
||||
indent = " " * len(prefix)
|
||||
indent = ' ' * len(prefix)
|
||||
parts = pos_parts + opt_parts
|
||||
lines = get_lines(parts, indent)
|
||||
if len(lines) > 1:
|
||||
|
@ -439,42 +735,7 @@ class PositionalsFirstHelpFormatter(argparse.HelpFormatter):
|
|||
lines = [prog] + lines
|
||||
|
||||
# join lines into usage
|
||||
usage = "\n".join(lines)
|
||||
usage = '\n'.join(lines)
|
||||
|
||||
# prefix with 'usage:'
|
||||
return "{}{}\n\n".format(prefix, usage)
|
||||
|
||||
|
||||
class JSONExtendedEncoder(JSONEncoder):
|
||||
"""Extended JSON encoder
|
||||
|
||||
Extend default JSON encoder to recognize more types and classes. It will
|
||||
never raise an exception if the object can't be encoded and return its repr
|
||||
instead.
|
||||
|
||||
The following objects and types are supported:
|
||||
- set: converted into list
|
||||
|
||||
"""
|
||||
|
||||
def default(self, o):
|
||||
import pytz # Lazy loading, this takes like 3+ sec on a RPi2 ?!
|
||||
|
||||
"""Return a serializable object"""
|
||||
# Convert compatible containers into list
|
||||
if isinstance(o, set) or (hasattr(o, "__iter__") and hasattr(o, "next")):
|
||||
return list(o)
|
||||
|
||||
# Display the date in its iso format ISO-8601 Internet Profile (RFC 3339)
|
||||
if isinstance(o, datetime.date):
|
||||
if o.tzinfo is None:
|
||||
o = o.replace(tzinfo=pytz.utc)
|
||||
return o.isoformat()
|
||||
|
||||
# Return the repr for object that json can't encode
|
||||
logger.warning(
|
||||
"cannot properly encode in JSON the object %s, " "returned repr is: %r",
|
||||
type(o),
|
||||
o,
|
||||
)
|
||||
return repr(o)
|
||||
return '%s%s\n\n' % (prefix, usage)
|
||||
|
|
|
@ -1,73 +1,34 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
import errno
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
from json import dumps as json_encode
|
||||
from tempfile import mkdtemp
|
||||
from shutil import rmtree
|
||||
|
||||
from gevent import sleep
|
||||
from gevent.queue import Queue
|
||||
from geventwebsocket import WebSocketError
|
||||
|
||||
from bottle import request, response, Bottle, HTTPResponse, FileUpload
|
||||
from bottle import abort
|
||||
from bottle import run, request, response, Bottle, HTTPResponse
|
||||
|
||||
from moulinette import m18n, Moulinette
|
||||
from moulinette.actionsmap import ActionsMap
|
||||
from moulinette.core import (
|
||||
MoulinetteError,
|
||||
MoulinetteValidationError,
|
||||
MoulinetteAuthenticationError,
|
||||
)
|
||||
from moulinette import msignals, m18n, DATA_DIR
|
||||
from moulinette.core import MoulinetteError, clean_session
|
||||
from moulinette.interfaces import (
|
||||
BaseActionsMapParser,
|
||||
ExtendedArgumentParser,
|
||||
JSONExtendedEncoder,
|
||||
BaseActionsMapParser, BaseInterface, ExtendedArgumentParser,
|
||||
)
|
||||
from moulinette.utils import log
|
||||
from moulinette.utils.serialize import JSONExtendedEncoder
|
||||
from moulinette.utils.text import random_ascii
|
||||
|
||||
logger = log.getLogger("moulinette.interface.api")
|
||||
logger = log.getLogger('moulinette.interface.api')
|
||||
|
||||
|
||||
# API helpers ----------------------------------------------------------
|
||||
# We define a global variable to manage in a dirty way the upload...
|
||||
UPLOAD_DIR = None
|
||||
|
||||
CSRF_TYPES = {"text/plain", "application/x-www-form-urlencoded", "multipart/form-data"}
|
||||
|
||||
|
||||
def is_csrf():
|
||||
"""Checks is this is a CSRF request."""
|
||||
|
||||
if request.method != "POST":
|
||||
return False
|
||||
if request.content_type is None:
|
||||
return True
|
||||
content_type = request.content_type.lower().split(";")[0]
|
||||
if content_type not in CSRF_TYPES:
|
||||
return False
|
||||
|
||||
return request.headers.get("X-Requested-With") is None
|
||||
|
||||
|
||||
# Protection against CSRF
|
||||
def filter_csrf(callback):
|
||||
def wrapper(*args, **kwargs):
|
||||
if is_csrf():
|
||||
abort(403, "CSRF protection")
|
||||
else:
|
||||
return callback(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
class LogQueues(dict):
|
||||
"""Map of session ids to queue."""
|
||||
|
||||
"""Map of session id to queue."""
|
||||
pass
|
||||
|
||||
|
||||
|
@ -80,21 +41,11 @@ class APIQueueHandler(logging.Handler):
|
|||
def __init__(self):
|
||||
logging.Handler.__init__(self)
|
||||
self.queues = LogQueues()
|
||||
# actionsmap is actually set during the interface's init ...
|
||||
self.actionsmap = None
|
||||
|
||||
def emit(self, record):
|
||||
# Prevent triggering this function while moulinette
|
||||
# is being initialized with --debug
|
||||
if not self.actionsmap or len(request.cookies) == 0:
|
||||
return
|
||||
|
||||
profile = request.params.get("profile", self.actionsmap.default_authentication)
|
||||
authenticator = self.actionsmap.get_authenticator(profile)
|
||||
|
||||
s_id = authenticator.get_session_cookie(raise_if_no_session_exists=False)["id"]
|
||||
sid = request.get_cookie('session.id')
|
||||
try:
|
||||
queue = self.queues[s_id]
|
||||
queue = self.queues[sid]
|
||||
except KeyError:
|
||||
# Session is not initialized, abandon.
|
||||
return
|
||||
|
@ -106,7 +57,7 @@ class APIQueueHandler(logging.Handler):
|
|||
sleep(0)
|
||||
|
||||
|
||||
class _HTTPArgumentParser:
|
||||
class _HTTPArgumentParser(object):
|
||||
"""Argument parser for HTTP requests
|
||||
|
||||
Object for parsing HTTP requests into Python objects. It is based
|
||||
|
@ -116,14 +67,13 @@ class _HTTPArgumentParser:
|
|||
|
||||
def __init__(self):
|
||||
# Initialize the ArgumentParser object
|
||||
self._parser = ExtendedArgumentParser(
|
||||
usage="", prefix_chars="@", add_help=False
|
||||
)
|
||||
self._parser = ExtendedArgumentParser(usage='',
|
||||
prefix_chars='@',
|
||||
add_help=False)
|
||||
self._parser.error = self._error
|
||||
|
||||
self._positional = [] # list(arg_name)
|
||||
self._optional = {} # dict({arg_name: option_strings})
|
||||
self._upload_dir = None
|
||||
|
||||
def set_defaults(self, **kwargs):
|
||||
return self._parser.set_defaults(**kwargs)
|
||||
|
@ -131,24 +81,20 @@ class _HTTPArgumentParser:
|
|||
def get_default(self, dest):
|
||||
return self._parser.get_default(dest)
|
||||
|
||||
def add_arguments(
|
||||
self, arguments, extraparser, format_arg_names=None, validate_extra=True
|
||||
):
|
||||
def add_arguments(self, arguments, extraparser, format_arg_names=None, validate_extra=True):
|
||||
for argument_name, argument_options in arguments.items():
|
||||
# will adapt arguments name for cli or api context
|
||||
names = format_arg_names(
|
||||
str(argument_name), argument_options.pop("full", None)
|
||||
)
|
||||
names = format_arg_names(str(argument_name),
|
||||
argument_options.pop('full', None))
|
||||
|
||||
if "type" in argument_options:
|
||||
argument_options["type"] = eval(argument_options["type"])
|
||||
argument_options['type'] = eval(argument_options['type'])
|
||||
|
||||
if "extra" in argument_options:
|
||||
extra = argument_options.pop("extra")
|
||||
extra = argument_options.pop('extra')
|
||||
argument_dest = self.add_argument(*names, **argument_options).dest
|
||||
extraparser.add_argument(
|
||||
self.get_default("_tid"), argument_dest, extra, validate_extra
|
||||
)
|
||||
extraparser.add_argument(self.get_default("_tid"),
|
||||
argument_dest, extra, validate_extra)
|
||||
continue
|
||||
|
||||
self.add_argument(*names, **argument_options)
|
||||
|
@ -158,9 +104,9 @@ class _HTTPArgumentParser:
|
|||
|
||||
# Append newly created action
|
||||
if len(action.option_strings) == 0:
|
||||
self._positional.append(action)
|
||||
self._positional.append(action.dest)
|
||||
else:
|
||||
self._optional[action.dest] = action
|
||||
self._optional[action.dest] = action.option_strings
|
||||
|
||||
return action
|
||||
|
||||
|
@ -168,26 +114,11 @@ class _HTTPArgumentParser:
|
|||
arg_strings = []
|
||||
|
||||
# Append an argument to the current one
|
||||
def append(arg_strings, value, action):
|
||||
option_string = None
|
||||
if len(action.option_strings) > 0:
|
||||
option_string = action.option_strings[0]
|
||||
|
||||
if isinstance(value, bool) or isinstance(action.const, bool):
|
||||
def append(arg_strings, value, option_string=None):
|
||||
if isinstance(value, bool):
|
||||
# Append the option string only
|
||||
if option_string is not None and value != 0:
|
||||
arg_strings.append(option_string)
|
||||
elif isinstance(value, FileUpload) and (
|
||||
isinstance(action.type, argparse.FileType) or action.type == open
|
||||
):
|
||||
# Upload the file in a temp directory
|
||||
global UPLOAD_DIR
|
||||
if UPLOAD_DIR is None:
|
||||
UPLOAD_DIR = mkdtemp(prefix="moulinette_upload_")
|
||||
value.save(UPLOAD_DIR)
|
||||
if option_string is not None:
|
||||
arg_strings.append(option_string)
|
||||
arg_strings.append(UPLOAD_DIR + "/" + value.filename)
|
||||
elif isinstance(value, str):
|
||||
if option_string is not None:
|
||||
arg_strings.append(option_string)
|
||||
|
@ -203,39 +134,36 @@ class _HTTPArgumentParser:
|
|||
if isinstance(v, str):
|
||||
arg_strings.append(v)
|
||||
else:
|
||||
logger.warning(
|
||||
"unsupported argument value type %r "
|
||||
"in %s for option string %s",
|
||||
v,
|
||||
value,
|
||||
option_string,
|
||||
)
|
||||
logger.warning("unsupported argument value type %r "
|
||||
"in %s for option string %s", v, value,
|
||||
option_string)
|
||||
else:
|
||||
logger.warning(
|
||||
"unsupported argument type %r for option " "string %s",
|
||||
value,
|
||||
option_string,
|
||||
)
|
||||
logger.warning("unsupported argument type %r for option "
|
||||
"string %s", value, option_string)
|
||||
|
||||
return arg_strings
|
||||
|
||||
# Iterate over positional arguments
|
||||
for action in self._positional:
|
||||
if action.dest in args:
|
||||
arg_strings = append(arg_strings, args[action.dest], action)
|
||||
for dest in self._positional:
|
||||
if dest in args:
|
||||
arg_strings = append(arg_strings, args[dest])
|
||||
|
||||
# Iterate over optional arguments
|
||||
for dest, action in self._optional.items():
|
||||
for dest, opt in self._optional.items():
|
||||
if dest in args:
|
||||
arg_strings = append(arg_strings, args[dest], action)
|
||||
arg_strings = append(arg_strings, args[dest], opt[0])
|
||||
|
||||
return self._parser.parse_args(arg_strings, namespace)
|
||||
|
||||
def dequeue_callbacks(self, *args, **kwargs):
|
||||
return self._parser.dequeue_callbacks(*args, **kwargs)
|
||||
|
||||
def _error(self, message):
|
||||
raise MoulinetteValidationError(message, raw_msg=True)
|
||||
# TODO: Raise a proper exception
|
||||
raise MoulinetteError(1, message)
|
||||
|
||||
|
||||
class _ActionsMapPlugin:
|
||||
class _ActionsMapPlugin(object):
|
||||
"""Actions map Bottle Plugin
|
||||
|
||||
Process relevant action for the request using the actions map and
|
||||
|
@ -243,15 +171,24 @@ class _ActionsMapPlugin:
|
|||
|
||||
Keyword arguments:
|
||||
- actionsmap -- An ActionsMap instance
|
||||
- use_websocket -- If true, install a WebSocket on /messages in order
|
||||
to serve messages coming from the 'display' signal
|
||||
|
||||
"""
|
||||
|
||||
name = "actionsmap"
|
||||
name = 'actionsmap'
|
||||
api = 2
|
||||
|
||||
def __init__(self, actionsmap, log_queues={}):
|
||||
def __init__(self, actionsmap, use_websocket, log_queues={}):
|
||||
# Connect signals to handlers
|
||||
msignals.set_handler('authenticate', self._do_authenticate)
|
||||
if use_websocket:
|
||||
msignals.set_handler('display', self._do_display)
|
||||
|
||||
self.actionsmap = actionsmap
|
||||
self.use_websocket = use_websocket
|
||||
self.log_queues = log_queues
|
||||
# TODO: Save and load secrets?
|
||||
self.secrets = {}
|
||||
|
||||
def setup(self, app):
|
||||
"""Setup plugin on the application
|
||||
|
@ -262,33 +199,45 @@ class _ActionsMapPlugin:
|
|||
- app -- The application instance
|
||||
|
||||
"""
|
||||
# Login wrapper
|
||||
def _login(callback):
|
||||
def wrapper():
|
||||
kwargs = {}
|
||||
try:
|
||||
kwargs['password'] = request.POST['password']
|
||||
except KeyError:
|
||||
raise HTTPBadRequestResponse("Missing password parameter")
|
||||
try:
|
||||
kwargs['profile'] = request.POST['profile']
|
||||
except KeyError:
|
||||
pass
|
||||
return callback(**kwargs)
|
||||
return wrapper
|
||||
|
||||
# Logout wrapper
|
||||
def _logout(callback):
|
||||
def wrapper():
|
||||
kwargs = {}
|
||||
try:
|
||||
kwargs['profile'] = request.POST.get('profile')
|
||||
except KeyError:
|
||||
pass
|
||||
return callback(**kwargs)
|
||||
return wrapper
|
||||
|
||||
# Append authentication routes
|
||||
app.route(
|
||||
"/login",
|
||||
name="login",
|
||||
method="POST",
|
||||
callback=self.login,
|
||||
skip=["actionsmap"],
|
||||
)
|
||||
app.route(
|
||||
"/logout",
|
||||
name="logout",
|
||||
method="GET",
|
||||
callback=self.logout,
|
||||
skip=["actionsmap"],
|
||||
)
|
||||
app.route('/login', name='login', method='POST',
|
||||
callback=self.login, skip=['actionsmap'], apply=_login)
|
||||
app.route('/logout', name='logout', method='GET',
|
||||
callback=self.logout, skip=['actionsmap'], apply=_logout)
|
||||
|
||||
# Append messages route
|
||||
app.route(
|
||||
"/messages",
|
||||
name="messages",
|
||||
callback=self.messages,
|
||||
skip=["actionsmap"],
|
||||
)
|
||||
if self.use_websocket:
|
||||
app.route('/messages', name='messages',
|
||||
callback=self.messages, skip=['actionsmap'])
|
||||
|
||||
# Append routes from the actions map
|
||||
for m, p in self.actionsmap.parser.routes:
|
||||
for (m, p) in self.actionsmap.parser.routes:
|
||||
app.route(p, method=m, callback=self.process)
|
||||
|
||||
def apply(self, callback, context):
|
||||
|
@ -302,7 +251,6 @@ class _ActionsMapPlugin:
|
|||
context -- An instance of Route
|
||||
|
||||
"""
|
||||
|
||||
def _format(value):
|
||||
if isinstance(value, list) and len(value) == 1:
|
||||
return value[0]
|
||||
|
@ -313,17 +261,14 @@ class _ActionsMapPlugin:
|
|||
# Format boolean params
|
||||
for a in args:
|
||||
params[a] = True
|
||||
|
||||
# Append other request params
|
||||
req_params = list(request.params.dict.items())
|
||||
# TODO test special chars in filename
|
||||
req_params += list(request.files.dict.items())
|
||||
for k, v in req_params:
|
||||
for k, v in request.params.dict.items():
|
||||
v = _format(v)
|
||||
if k not in params.keys():
|
||||
try:
|
||||
curr_v = params[k]
|
||||
except KeyError:
|
||||
params[k] = v
|
||||
else:
|
||||
curr_v = params[k]
|
||||
# Append param value to the list
|
||||
if not isinstance(curr_v, list):
|
||||
curr_v = [curr_v]
|
||||
|
@ -336,73 +281,85 @@ class _ActionsMapPlugin:
|
|||
|
||||
# Process the action
|
||||
return callback((request.method, context.rule), params)
|
||||
|
||||
return wrapper
|
||||
|
||||
# Routes callbacks
|
||||
|
||||
def login(self):
|
||||
"""Log in to an authenticator
|
||||
def login(self, password, profile='default'):
|
||||
"""Log in to an authenticator profile
|
||||
|
||||
Attempt to authenticate to the default authenticator and
|
||||
Attempt to authenticate to a given authenticator profile and
|
||||
register it with the current session - a new one will be created
|
||||
if needed.
|
||||
|
||||
Keyword arguments:
|
||||
- password -- A clear text password
|
||||
- profile -- The authenticator profile name to log in
|
||||
|
||||
"""
|
||||
|
||||
if "credentials" not in request.params:
|
||||
raise HTTPResponse("Missing credentials parameter", 400)
|
||||
credentials = request.params["credentials"]
|
||||
|
||||
profile = request.params.get("profile", self.actionsmap.default_authentication)
|
||||
authenticator = self.actionsmap.get_authenticator(profile)
|
||||
# Retrieve session values
|
||||
s_id = request.get_cookie('session.id') or random_ascii()
|
||||
try:
|
||||
s_secret = self.secrets[s_id]
|
||||
except KeyError:
|
||||
s_hashes = {}
|
||||
else:
|
||||
s_hashes = request.get_cookie('session.hashes',
|
||||
secret=s_secret) or {}
|
||||
s_hash = random_ascii()
|
||||
|
||||
try:
|
||||
auth_infos = authenticator.authenticate_credentials(credentials)
|
||||
# Attempt to authenticate
|
||||
auth = self.actionsmap.get_authenticator(profile)
|
||||
auth(password, token=(s_id, s_hash))
|
||||
except MoulinetteError as e:
|
||||
if len(s_hashes) > 0:
|
||||
try:
|
||||
self.logout()
|
||||
except Exception:
|
||||
self.logout(profile)
|
||||
except:
|
||||
pass
|
||||
raise HTTPResponse(e.strerror, 401)
|
||||
raise error_to_response(e)
|
||||
else:
|
||||
authenticator.set_session_cookie(auth_infos)
|
||||
return m18n.g("logged_in")
|
||||
# Update dicts with new values
|
||||
s_hashes[profile] = s_hash
|
||||
self.secrets[s_id] = s_secret = random_ascii()
|
||||
|
||||
# This is called before each time a route is going to be processed
|
||||
def authenticate(self, authenticator):
|
||||
response.set_cookie('session.id', s_id, secure=True)
|
||||
response.set_cookie('session.hashes', s_hashes, secure=True,
|
||||
secret=s_secret)
|
||||
return m18n.g('logged_in')
|
||||
|
||||
def logout(self, profile=None):
|
||||
"""Log out from an authenticator profile
|
||||
|
||||
Attempt to unregister a given profile - or all by default - from
|
||||
the current session.
|
||||
|
||||
Keyword arguments:
|
||||
- profile -- The authenticator profile name to log out
|
||||
|
||||
"""
|
||||
s_id = request.get_cookie('session.id')
|
||||
try:
|
||||
session_infos = authenticator.get_session_cookie()
|
||||
except Exception:
|
||||
msg = m18n.g("authentication_required")
|
||||
raise HTTPResponse(msg, 401)
|
||||
|
||||
return session_infos
|
||||
|
||||
def logout(self):
|
||||
profile = request.params.get("profile", self.actionsmap.default_authentication)
|
||||
authenticator = self.actionsmap.get_authenticator(profile)
|
||||
|
||||
try:
|
||||
authenticator.get_session_cookie()
|
||||
except Exception:
|
||||
raise HTTPResponse(m18n.g("not_logged_in"), 401)
|
||||
del self.secrets[s_id]
|
||||
except KeyError:
|
||||
raise HTTPUnauthorizedResponse(m18n.g('not_logged_in'))
|
||||
else:
|
||||
# TODO: Clean the session for profile only
|
||||
# Delete cookie and clean the session
|
||||
authenticator.delete_session_cookie()
|
||||
return m18n.g("logged_out")
|
||||
response.set_cookie('session.hashes', '', max_age=-1)
|
||||
clean_session(s_id)
|
||||
return m18n.g('logged_out')
|
||||
|
||||
def messages(self):
|
||||
"""Listen to the messages WebSocket stream
|
||||
|
||||
Retrieve the WebSocket stream and send to it each messages displayed by
|
||||
the display method. They are JSON encoded as a dict { style: message }.
|
||||
the core.MoulinetteSignals.display signal. They are JSON encoded as a
|
||||
dict { style: message }.
|
||||
|
||||
"""
|
||||
|
||||
profile = request.params.get("profile", self.actionsmap.default_authentication)
|
||||
authenticator = self.actionsmap.get_authenticator(profile)
|
||||
|
||||
s_id = authenticator.get_session_cookie()["id"]
|
||||
s_id = request.get_cookie('session.id')
|
||||
try:
|
||||
queue = self.log_queues[s_id]
|
||||
except KeyError:
|
||||
|
@ -410,9 +367,9 @@ class _ActionsMapPlugin:
|
|||
queue = Queue()
|
||||
self.log_queues[s_id] = queue
|
||||
|
||||
wsock = request.environ.get("wsgi.websocket")
|
||||
wsock = request.environ.get('wsgi.websocket')
|
||||
if not wsock:
|
||||
raise HTTPResponse(m18n.g("websocket_request_expected"), 500)
|
||||
raise HTTPErrorResponse(m18n.g('websocket_request_expected'))
|
||||
|
||||
while True:
|
||||
item = queue.get()
|
||||
|
@ -445,49 +402,60 @@ class _ActionsMapPlugin:
|
|||
- arguments -- A dict of arguments for the route
|
||||
|
||||
"""
|
||||
|
||||
try:
|
||||
ret = self.actionsmap.process(arguments, timeout=30, route=_route)
|
||||
except MoulinetteError as e:
|
||||
raise moulinette_error_to_http_response(e)
|
||||
raise error_to_response(e)
|
||||
except Exception as e:
|
||||
if isinstance(e, HTTPResponse):
|
||||
raise e
|
||||
import traceback
|
||||
|
||||
tb = traceback.format_exc()
|
||||
logs = {"route": _route, "arguments": arguments, "traceback": tb}
|
||||
return HTTPResponse(json_encode(logs), 500)
|
||||
logs = {"route": _route,
|
||||
"arguments": arguments,
|
||||
"traceback": tb}
|
||||
return HTTPErrorResponse(json_encode(logs))
|
||||
else:
|
||||
return format_for_response(ret)
|
||||
finally:
|
||||
# Clean upload directory
|
||||
# FIXME do that in a better way
|
||||
global UPLOAD_DIR
|
||||
if UPLOAD_DIR is not None:
|
||||
rmtree(UPLOAD_DIR, True)
|
||||
UPLOAD_DIR = None
|
||||
|
||||
# Close opened WebSocket by putting StopIteration in the queue
|
||||
profile = request.params.get(
|
||||
"profile", self.actionsmap.default_authentication
|
||||
)
|
||||
authenticator = self.actionsmap.get_authenticator(profile)
|
||||
try:
|
||||
s_id = authenticator.get_session_cookie()["id"]
|
||||
queue = self.log_queues[s_id]
|
||||
except MoulinetteAuthenticationError:
|
||||
pass
|
||||
queue = self.log_queues[request.get_cookie('session.id')]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
queue.put(StopIteration)
|
||||
|
||||
def display(self, message, style="info"):
|
||||
profile = request.params.get("profile", self.actionsmap.default_authentication)
|
||||
authenticator = self.actionsmap.get_authenticator(profile)
|
||||
s_id = authenticator.get_session_cookie(raise_if_no_session_exists=False)["id"]
|
||||
# Signals handlers
|
||||
|
||||
def _do_authenticate(self, authenticator, help):
|
||||
"""Process the authentication
|
||||
|
||||
Handle the core.MoulinetteSignals.authenticate signal.
|
||||
|
||||
"""
|
||||
s_id = request.get_cookie('session.id')
|
||||
try:
|
||||
s_secret = self.secrets[s_id]
|
||||
s_hash = request.get_cookie('session.hashes',
|
||||
secret=s_secret, default={})[authenticator.name]
|
||||
except KeyError:
|
||||
if authenticator.name == 'default':
|
||||
msg = m18n.g('authentication_required')
|
||||
else:
|
||||
msg = m18n.g('authentication_profile_required',
|
||||
profile=authenticator.name)
|
||||
raise HTTPUnauthorizedResponse(msg)
|
||||
else:
|
||||
return authenticator(token=(s_id, s_hash))
|
||||
|
||||
def _do_display(self, message, style):
|
||||
"""Display a message
|
||||
|
||||
Handle the core.MoulinetteSignals.display signal.
|
||||
|
||||
"""
|
||||
s_id = request.get_cookie('session.id')
|
||||
try:
|
||||
queue = self.log_queues[s_id]
|
||||
except KeyError:
|
||||
|
@ -500,49 +468,79 @@ class _ActionsMapPlugin:
|
|||
# populate the new message in the queue
|
||||
sleep(0)
|
||||
|
||||
def prompt(self, *args, **kwargs):
|
||||
raise NotImplementedError("Prompt is not implemented for this interface")
|
||||
|
||||
|
||||
# HTTP Responses -------------------------------------------------------
|
||||
|
||||
class HTTPOKResponse(HTTPResponse):
|
||||
|
||||
def moulinette_error_to_http_response(error):
|
||||
content = error.content()
|
||||
if isinstance(content, dict):
|
||||
return HTTPResponse(
|
||||
json_encode(content),
|
||||
error.http_code,
|
||||
headers={"Content-type": "application/json"},
|
||||
)
|
||||
def __init__(self, output=''):
|
||||
super(HTTPOKResponse, self).__init__(output, 200)
|
||||
|
||||
|
||||
class HTTPBadRequestResponse(HTTPResponse):
|
||||
|
||||
def __init__(self, output=''):
|
||||
super(HTTPBadRequestResponse, self).__init__(output, 400)
|
||||
|
||||
|
||||
class HTTPUnauthorizedResponse(HTTPResponse):
|
||||
|
||||
def __init__(self, output=''):
|
||||
super(HTTPUnauthorizedResponse, self).__init__(output, 401)
|
||||
|
||||
|
||||
class HTTPForbiddenResponse(HTTPResponse):
|
||||
|
||||
def __init__(self, output=''):
|
||||
super(HTTPForbiddenResponse, self).__init__(output, 403)
|
||||
|
||||
|
||||
class HTTPErrorResponse(HTTPResponse):
|
||||
|
||||
def __init__(self, output=''):
|
||||
super(HTTPErrorResponse, self).__init__(output, 500)
|
||||
|
||||
|
||||
def error_to_response(error):
|
||||
"""Convert a MoulinetteError to relevant HTTP response."""
|
||||
if error.errno == errno.EPERM:
|
||||
return HTTPForbiddenResponse(error.strerror)
|
||||
elif error.errno == errno.EACCES:
|
||||
return HTTPUnauthorizedResponse(error.strerror)
|
||||
# Client-side error
|
||||
elif error.errno in [errno.ENOENT, errno.ESRCH, errno.ENXIO, errno.EEXIST,
|
||||
errno.ENODEV, errno.EINVAL, errno.ENOPKG, errno.EDESTADDRREQ]:
|
||||
return HTTPBadRequestResponse(error.strerror)
|
||||
# Server-side error
|
||||
elif error.errno in [errno.EIO, errno.EBUSY, errno.ENODATA, errno.EINTR,
|
||||
errno.ENETUNREACH]:
|
||||
return HTTPErrorResponse(error.strerror)
|
||||
else:
|
||||
return HTTPResponse(content, error.http_code)
|
||||
logger.debug('unknown relevant response for error [%s] %s',
|
||||
error.errno, error.strerror)
|
||||
return HTTPErrorResponse(error.strerror)
|
||||
|
||||
|
||||
def format_for_response(content):
|
||||
"""Format the resulted content of a request for the HTTP response."""
|
||||
if request.method == "POST":
|
||||
if request.method == 'POST':
|
||||
response.status = 201 # Created
|
||||
elif request.method == "GET":
|
||||
elif request.method == 'GET':
|
||||
response.status = 200 # Ok
|
||||
else:
|
||||
# Return empty string if no content
|
||||
if content is None or len(content) == 0:
|
||||
response.status = 204 # No Content
|
||||
return ""
|
||||
return ''
|
||||
response.status = 200
|
||||
|
||||
if isinstance(content, HTTPResponse):
|
||||
return content
|
||||
|
||||
# Return JSON-style response
|
||||
response.content_type = "application/json"
|
||||
response.content_type = 'application/json'
|
||||
return json_encode(content, cls=JSONExtendedEncoder)
|
||||
|
||||
|
||||
# API Classes Implementation -------------------------------------------
|
||||
|
||||
|
||||
class ActionsMapParser(BaseActionsMapParser):
|
||||
"""Actions map's Parser for the API
|
||||
|
||||
|
@ -555,7 +553,7 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
super(ActionsMapParser, self).__init__(parent)
|
||||
|
||||
self._parsers = {} # dict({(method, path): _HTTPArgumentParser})
|
||||
self._route_re = re.compile(r"(GET|POST|PUT|DELETE) (/\S+)")
|
||||
self._route_re = re.compile(r'(GET|POST|PUT|DELETE) (/\S+)')
|
||||
|
||||
@property
|
||||
def routes(self):
|
||||
|
@ -564,19 +562,19 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
|
||||
# Implement virtual properties
|
||||
|
||||
interface = "api"
|
||||
interface = 'api'
|
||||
|
||||
# Implement virtual methods
|
||||
|
||||
@staticmethod
|
||||
def format_arg_names(name, full):
|
||||
if name[0] != "-":
|
||||
if name[0] != '-':
|
||||
return [name]
|
||||
if full:
|
||||
return [full.replace("--", "@", 1)]
|
||||
if name.startswith("--"):
|
||||
return [name.replace("--", "@", 1)]
|
||||
return [name.replace("-", "@", 1)]
|
||||
return [full.replace('--', '@', 1)]
|
||||
if name.startswith('--'):
|
||||
return [name.replace('--', '@', 1)]
|
||||
return [name.replace('-', '@', 1)]
|
||||
|
||||
def add_category_parser(self, name, **kwargs):
|
||||
return self
|
||||
|
@ -605,9 +603,8 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
try:
|
||||
keys.append(self._extract_route(r))
|
||||
except ValueError as e:
|
||||
logger.warning(
|
||||
"cannot add api route '%s' for " "action %s: %s", r, tid, e
|
||||
)
|
||||
logger.warning("cannot add api route '%s' for "
|
||||
"action %s: %s", r, tid, e)
|
||||
continue
|
||||
if len(keys) == 0:
|
||||
raise ValueError("no valid api route found")
|
||||
|
@ -622,45 +619,39 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
# Return the created parser
|
||||
return parser
|
||||
|
||||
def auth_method(self, _, route):
|
||||
try:
|
||||
# Retrieve the tid for the route
|
||||
_, parser = self._parsers[route]
|
||||
except KeyError as e:
|
||||
error_message = "no argument parser found for route '{}': {}".format(
|
||||
route, e
|
||||
)
|
||||
logger.error(error_message)
|
||||
raise MoulinetteValidationError(error_message, raw_msg=True)
|
||||
|
||||
return parser.authentication
|
||||
|
||||
def want_to_take_lock(self, _, route):
|
||||
_, parser = self._parsers[route]
|
||||
|
||||
return getattr(parser, "want_to_take_lock", True)
|
||||
|
||||
def parse_args(self, args, **kwargs):
|
||||
def parse_args(self, args, route, **kwargs):
|
||||
"""Parse arguments
|
||||
|
||||
Keyword arguments:
|
||||
- route -- The action route as a 2-tuple (method, path)
|
||||
|
||||
"""
|
||||
route = kwargs["route"]
|
||||
try:
|
||||
# Retrieve the parser for the route
|
||||
_, parser = self._parsers[route]
|
||||
except KeyError as e:
|
||||
error_message = "no argument parser found for route '{}': {}".format(
|
||||
route, e
|
||||
)
|
||||
logger.error(error_message)
|
||||
raise MoulinetteValidationError(error_message, raw_msg=True)
|
||||
# Retrieve the tid and the parser for the route
|
||||
tid, parser = self._parsers[route]
|
||||
except KeyError:
|
||||
logger.error("no argument parser found for route '%s'", route)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
ret = argparse.Namespace()
|
||||
|
||||
# Perform authentication if needed
|
||||
if self.get_conf(tid, 'authenticate'):
|
||||
# TODO: Clean this hard fix and find a way to set an authenticator
|
||||
# to use for the api only
|
||||
# auth_conf, klass = self.get_conf(tid, 'authenticator')
|
||||
auth_conf, klass = self.get_global_conf('authenticator', 'default')
|
||||
|
||||
# TODO: Catch errors
|
||||
auth = msignals.authenticate(klass(), **auth_conf)
|
||||
if not auth.is_authenticated:
|
||||
raise MoulinetteError(errno.EACCES, m18n.g('authentication_required_long'))
|
||||
if self.get_conf(tid, 'argument_auth') and \
|
||||
self.get_conf(tid, 'authenticate') == 'all':
|
||||
ret.auth = auth
|
||||
|
||||
# TODO: Catch errors?
|
||||
ret = parser.parse_args(args, ret)
|
||||
parser.dequeue_callbacks(ret)
|
||||
return ret
|
||||
|
||||
# Private methods
|
||||
|
@ -686,30 +677,31 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
return key
|
||||
|
||||
|
||||
class Interface:
|
||||
class Interface(BaseInterface):
|
||||
"""Application Programming Interface for the moulinette
|
||||
|
||||
Initialize a HTTP server which serves the API connected to a given
|
||||
actions map.
|
||||
|
||||
Keyword arguments:
|
||||
- actionsmap -- The ActionsMap instance to connect to
|
||||
- routes -- A dict of additional routes to add in the form of
|
||||
{(method, path): callback}
|
||||
- use_websocket -- Serve via WSGI to handle asynchronous responses
|
||||
- log_queues -- A LogQueues object or None to retrieve it from
|
||||
registered logging handlers
|
||||
|
||||
"""
|
||||
|
||||
type = "api"
|
||||
|
||||
def __init__(self, routes={}, actionsmap=None):
|
||||
actionsmap = ActionsMap(actionsmap, ActionsMapParser())
|
||||
def __init__(self, actionsmap, routes={}, use_websocket=True,
|
||||
log_queues=None):
|
||||
self.use_websocket = use_websocket
|
||||
|
||||
# Attempt to retrieve log queues from an APIQueueHandler
|
||||
if log_queues is None:
|
||||
handler = log.getHandlersByClass(APIQueueHandler, limit=1)
|
||||
if handler:
|
||||
log_queues = handler.queues
|
||||
handler.actionsmap = actionsmap
|
||||
|
||||
# TODO: Return OK to 'OPTIONS' xhr requests (l173)
|
||||
app = Bottle(autojson=True)
|
||||
|
@ -717,44 +709,36 @@ class Interface:
|
|||
# Wrapper which sets proper header
|
||||
def apiheader(callback):
|
||||
def wrapper(*args, **kwargs):
|
||||
response.set_header("Access-Control-Allow-Origin", "*")
|
||||
response.set_header('Access-Control-Allow-Origin', '*')
|
||||
return callback(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
|
||||
# Attempt to retrieve and set locale
|
||||
def api18n(callback):
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
locale = request.params.pop("locale")
|
||||
locale = request.params.pop('locale')
|
||||
except KeyError:
|
||||
locale = m18n.default_locale
|
||||
m18n.set_locale(locale)
|
||||
return callback(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
return callback
|
||||
|
||||
# Install plugins
|
||||
app.install(filter_csrf)
|
||||
app.install(apiheader)
|
||||
app.install(api18n)
|
||||
actionsmapplugin = _ActionsMapPlugin(actionsmap, log_queues)
|
||||
app.install(actionsmapplugin)
|
||||
app.install(_ActionsMapPlugin(actionsmap, use_websocket, log_queues))
|
||||
|
||||
self.authenticate = actionsmapplugin.authenticate
|
||||
self.display = actionsmapplugin.display
|
||||
self.prompt = actionsmapplugin.prompt
|
||||
# Append default routes
|
||||
# app.route(['/api', '/api/<category:re:[a-z]+>'], method='GET',
|
||||
# callback=self.doc, skip=['actionsmap'])
|
||||
|
||||
# Append additional routes
|
||||
# TODO: Add optional authentication to those routes?
|
||||
for (m, p), c in routes.items():
|
||||
app.route(p, method=m, callback=c, skip=["actionsmap"])
|
||||
app.route(p, method=m, callback=c, skip=['actionsmap'])
|
||||
|
||||
self._app = app
|
||||
|
||||
Moulinette._interface = self
|
||||
|
||||
def run(self, host="localhost", port=80):
|
||||
def run(self, host='localhost', port=80):
|
||||
"""Run the moulinette
|
||||
|
||||
Start a server instance on the given port to serve moulinette
|
||||
|
@ -765,26 +749,43 @@ class Interface:
|
|||
- port -- Server port to bind to
|
||||
|
||||
"""
|
||||
|
||||
logger.debug(
|
||||
"starting the server instance in %s:%d",
|
||||
host,
|
||||
port,
|
||||
)
|
||||
logger.debug("starting the server instance in %s:%d with websocket=%s",
|
||||
host, port, self.use_websocket)
|
||||
|
||||
try:
|
||||
if self.use_websocket:
|
||||
from gevent.pywsgi import WSGIServer
|
||||
from geventwebsocket.handler import WebSocketHandler
|
||||
|
||||
server = WSGIServer((host, port), self._app, handler_class=WebSocketHandler)
|
||||
server = WSGIServer((host, port), self._app,
|
||||
handler_class=WebSocketHandler)
|
||||
server.serve_forever()
|
||||
else:
|
||||
run(self._app, host=host, port=port)
|
||||
except IOError as e:
|
||||
error_message = "unable to start the server instance on %s:%d: %s" % (
|
||||
host,
|
||||
port,
|
||||
e,
|
||||
)
|
||||
logger.exception(error_message)
|
||||
logger.exception("unable to start the server instance on %s:%d",
|
||||
host, port)
|
||||
if e.args[0] == errno.EADDRINUSE:
|
||||
raise MoulinetteError("server_already_running")
|
||||
raise MoulinetteError(error_message)
|
||||
raise MoulinetteError(errno.EADDRINUSE,
|
||||
m18n.g('server_already_running'))
|
||||
raise MoulinetteError(errno.EIO, m18n.g('error_see_log'))
|
||||
|
||||
# Routes handlers
|
||||
|
||||
def doc(self, category=None):
|
||||
"""
|
||||
Get API documentation for a category (all by default)
|
||||
|
||||
Keyword argument:
|
||||
category -- Name of the category
|
||||
|
||||
"""
|
||||
if category is None:
|
||||
with open('%s/../doc/resources.json' % DATA_DIR) as f:
|
||||
return f.read()
|
||||
|
||||
try:
|
||||
with open('%s/../doc/%s.json' % (DATA_DIR, category)) as f:
|
||||
return f.read()
|
||||
except IOError:
|
||||
return None
|
||||
|
|
|
@ -2,70 +2,39 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
import errno
|
||||
import getpass
|
||||
import locale
|
||||
import logging
|
||||
import argparse
|
||||
import tempfile
|
||||
from argparse import SUPPRESS
|
||||
from collections import OrderedDict
|
||||
from datetime import date, datetime
|
||||
from subprocess import call
|
||||
|
||||
from moulinette import m18n, Moulinette
|
||||
from moulinette.actionsmap import ActionsMap
|
||||
from moulinette.core import MoulinetteError, MoulinetteValidationError
|
||||
import argcomplete
|
||||
|
||||
from moulinette import msignals, m18n
|
||||
from moulinette.core import MoulinetteError
|
||||
from moulinette.interfaces import (
|
||||
BaseActionsMapParser,
|
||||
ExtendedArgumentParser,
|
||||
JSONExtendedEncoder,
|
||||
BaseActionsMapParser, BaseInterface, ExtendedArgumentParser,
|
||||
)
|
||||
from moulinette.utils import log
|
||||
|
||||
# Monkeypatch _get_action_name function because there is an annoying bug
|
||||
# Explained here: https://bugs.python.org/issue29298
|
||||
# Fixed by: https://github.com/python/cpython/pull/3680
|
||||
# To reproduce the bug, just launch a command line without action
|
||||
# For example:
|
||||
# yunohost firewall
|
||||
# It should display:
|
||||
# usage: yunohost firewall {list,reload,allow,disallow,upnp,stop} ... [-h]
|
||||
# yunohost firewall: error: the following arguments are required: {list,reload,allow,disallow,upnp,stop}
|
||||
# But it display instead:
|
||||
# Error: unable to parse arguments 'firewall' because: sequence item 0: expected str instance, NoneType found
|
||||
|
||||
|
||||
def monkey_get_action_name(argument):
|
||||
if argument is None:
|
||||
return None
|
||||
elif argument.option_strings:
|
||||
return "/".join(argument.option_strings)
|
||||
elif argument.metavar not in (None, argparse.SUPPRESS):
|
||||
return argument.metavar
|
||||
elif argument.dest not in (None, argparse.SUPPRESS):
|
||||
return argument.dest
|
||||
elif argument.choices:
|
||||
return "{" + ",".join(argument.choices) + "}"
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
argparse._get_action_name = monkey_get_action_name
|
||||
|
||||
logger = log.getLogger("moulinette.cli")
|
||||
logger = log.getLogger('moulinette.cli')
|
||||
|
||||
|
||||
# CLI helpers ----------------------------------------------------------
|
||||
|
||||
CLI_COLOR_TEMPLATE = "\033[{:d}m\033[1m"
|
||||
END_CLI_COLOR = "\033[m"
|
||||
CLI_COLOR_TEMPLATE = '\033[{:d}m\033[1m'
|
||||
END_CLI_COLOR = '\033[m'
|
||||
|
||||
colors_codes = {
|
||||
"red": CLI_COLOR_TEMPLATE.format(31),
|
||||
"green": CLI_COLOR_TEMPLATE.format(32),
|
||||
"yellow": CLI_COLOR_TEMPLATE.format(33),
|
||||
"blue": CLI_COLOR_TEMPLATE.format(34),
|
||||
"purple": CLI_COLOR_TEMPLATE.format(35),
|
||||
"cyan": CLI_COLOR_TEMPLATE.format(36),
|
||||
"white": CLI_COLOR_TEMPLATE.format(37),
|
||||
'red': CLI_COLOR_TEMPLATE.format(31),
|
||||
'green': CLI_COLOR_TEMPLATE.format(32),
|
||||
'yellow': CLI_COLOR_TEMPLATE.format(33),
|
||||
'blue': CLI_COLOR_TEMPLATE.format(34),
|
||||
'purple': CLI_COLOR_TEMPLATE.format(35),
|
||||
'cyan': CLI_COLOR_TEMPLATE.format(36),
|
||||
'white': CLI_COLOR_TEMPLATE.format(37),
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,7 +49,7 @@ def colorize(astr, color):
|
|||
|
||||
"""
|
||||
if os.isatty(1):
|
||||
return "{:s}{:s}{:s}".format(colors_codes[color], astr, END_CLI_COLOR)
|
||||
return '{:s}{:s}{:s}'.format(colors_codes[color], astr, END_CLI_COLOR)
|
||||
else:
|
||||
return astr
|
||||
|
||||
|
@ -120,37 +89,11 @@ def plain_print_dict(d, depth=0):
|
|||
print("{}{}".format("#" * (depth + 1), k))
|
||||
plain_print_dict(v, depth + 1)
|
||||
else:
|
||||
if isinstance(d, unicode):
|
||||
d = d.encode('utf-8')
|
||||
print(d)
|
||||
|
||||
|
||||
def pretty_date(_date):
|
||||
"""Display a date in the current time zone without ms and tzinfo
|
||||
|
||||
Argument:
|
||||
- date -- The date or datetime to display
|
||||
"""
|
||||
import pytz # Lazy loading, this takes like 3+ sec on a RPi2 ?!
|
||||
|
||||
# Deduce system timezone
|
||||
nowutc = datetime.now(tz=pytz.utc)
|
||||
nowtz = datetime.now()
|
||||
nowtz = nowtz.replace(tzinfo=pytz.utc)
|
||||
offsetHour = nowutc - nowtz
|
||||
offsetHour = int(round(offsetHour.total_seconds() / 3600))
|
||||
localtz = "Etc/GMT%+d" % offsetHour
|
||||
|
||||
# Transform naive date into UTC date
|
||||
if _date.tzinfo is None:
|
||||
_date = _date.replace(tzinfo=pytz.utc)
|
||||
|
||||
# Convert UTC date into system locale date
|
||||
_date = _date.astimezone(pytz.timezone(localtz))
|
||||
if isinstance(_date, datetime):
|
||||
return _date.strftime("%Y-%m-%d %H:%M:%S")
|
||||
else:
|
||||
return _date.strftime("%Y-%m-%d")
|
||||
|
||||
|
||||
def pretty_print_dict(d, depth=0):
|
||||
"""Print in a pretty way a dictionary recursively
|
||||
|
||||
|
@ -166,7 +109,7 @@ def pretty_print_dict(d, depth=0):
|
|||
keys = sorted(keys)
|
||||
for k in keys:
|
||||
v = d[k]
|
||||
k = colorize(str(k), "purple")
|
||||
k = colorize(str(k), 'purple')
|
||||
if isinstance(v, (tuple, set)):
|
||||
v = list(v)
|
||||
if isinstance(v, list) and len(v) == 1:
|
||||
|
@ -182,31 +125,25 @@ def pretty_print_dict(d, depth=0):
|
|||
elif isinstance(value, dict):
|
||||
pretty_print_dict({key: value}, depth + 1)
|
||||
else:
|
||||
if isinstance(v, date):
|
||||
v = pretty_date(v)
|
||||
if isinstance(value, unicode):
|
||||
value = value.encode('utf-8')
|
||||
print("{:s}- {}".format(" " * (depth + 1), value))
|
||||
else:
|
||||
if isinstance(v, date):
|
||||
v = pretty_date(v)
|
||||
if isinstance(v, unicode):
|
||||
v = v.encode('utf-8')
|
||||
print("{:s}{}: {}".format(" " * depth, k, v))
|
||||
|
||||
|
||||
def get_locale():
|
||||
"""Return current user eocale"""
|
||||
try:
|
||||
"""Return current user locale"""
|
||||
lang = locale.getdefaultlocale()[0]
|
||||
except Exception:
|
||||
# In some edge case the locale lib fails ...
|
||||
# c.f. https://forum.yunohost.org/t/error-when-trying-to-enter-user-information-in-admin-panel/11390/11
|
||||
lang = os.getenv("LANG")
|
||||
if not lang:
|
||||
return ""
|
||||
return ''
|
||||
return lang[:2]
|
||||
|
||||
|
||||
# CLI Classes Implementation -------------------------------------------
|
||||
|
||||
|
||||
class TTYHandler(logging.StreamHandler):
|
||||
"""TTY log handler
|
||||
|
||||
|
@ -223,18 +160,17 @@ class TTYHandler(logging.StreamHandler):
|
|||
stderr. Otherwise, they are sent to stdout.
|
||||
|
||||
"""
|
||||
|
||||
LEVELS_COLOR = {
|
||||
log.NOTSET: "white",
|
||||
log.DEBUG: "white",
|
||||
log.INFO: "cyan",
|
||||
log.SUCCESS: "green",
|
||||
log.WARNING: "yellow",
|
||||
log.ERROR: "red",
|
||||
log.CRITICAL: "red",
|
||||
log.NOTSET: 'white',
|
||||
log.DEBUG: 'white',
|
||||
log.INFO: 'cyan',
|
||||
log.SUCCESS: 'green',
|
||||
log.WARNING: 'yellow',
|
||||
log.ERROR: 'red',
|
||||
log.CRITICAL: 'red',
|
||||
}
|
||||
|
||||
def __init__(self, message_key="fmessage"):
|
||||
def __init__(self, message_key='fmessage'):
|
||||
logging.StreamHandler.__init__(self)
|
||||
self.message_key = message_key
|
||||
|
||||
|
@ -242,15 +178,16 @@ class TTYHandler(logging.StreamHandler):
|
|||
"""Enhance message with level and colors if supported."""
|
||||
msg = record.getMessage()
|
||||
if self.supports_color():
|
||||
level = ""
|
||||
level = ''
|
||||
if self.level <= log.DEBUG:
|
||||
# add level name before message
|
||||
level = "%s " % record.levelname
|
||||
elif record.levelname in ["SUCCESS", "WARNING", "ERROR", "INFO"]:
|
||||
level = '%s ' % record.levelname
|
||||
elif record.levelname in ['SUCCESS', 'WARNING', 'ERROR', 'INFO']:
|
||||
# add translated level name before message
|
||||
level = "%s " % m18n.g(record.levelname.lower())
|
||||
color = self.LEVELS_COLOR.get(record.levelno, "white")
|
||||
msg = "{}{}{}{}".format(colors_codes[color], level, END_CLI_COLOR, msg)
|
||||
level = '%s ' % m18n.g(record.levelname.lower())
|
||||
color = self.LEVELS_COLOR.get(record.levelno, 'white')
|
||||
msg = '{0}{1}{2}{3}'.format(
|
||||
colors_codes[color], level, END_CLI_COLOR, msg)
|
||||
if self.formatter:
|
||||
# use user-defined formatter
|
||||
record.__dict__[self.message_key] = msg
|
||||
|
@ -267,7 +204,7 @@ class TTYHandler(logging.StreamHandler):
|
|||
|
||||
def supports_color(self):
|
||||
"""Check whether current stream supports color."""
|
||||
if hasattr(self.stream, "isatty") and self.stream.isatty():
|
||||
if hasattr(self.stream, 'isatty') and self.stream.isatty():
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -286,13 +223,13 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self, parent=None, parser=None, subparser_kwargs=None, top_parser=None
|
||||
):
|
||||
def __init__(self, parent=None, parser=None, subparser_kwargs=None,
|
||||
top_parser=None, **kwargs):
|
||||
super(ActionsMapParser, self).__init__(parent)
|
||||
|
||||
if subparser_kwargs is None:
|
||||
subparser_kwargs = {"title": "categories", "required": False}
|
||||
subparser_kwargs = {'title': "categories", 'required': False}
|
||||
|
||||
self._parser = parser or ExtendedArgumentParser()
|
||||
self._subparsers = self._parser.add_subparsers(**subparser_kwargs)
|
||||
self.global_parser = parent.global_parser if parent else None
|
||||
|
@ -302,18 +239,18 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
|
||||
# Append each top parser action to the global group
|
||||
for action in top_parser._actions:
|
||||
action.dest = argparse.SUPPRESS
|
||||
action.dest = SUPPRESS
|
||||
self.global_parser._add_action(action)
|
||||
|
||||
# Implement virtual properties
|
||||
|
||||
interface = "cli"
|
||||
interface = 'cli'
|
||||
|
||||
# Implement virtual methods
|
||||
|
||||
@staticmethod
|
||||
def format_arg_names(name, full):
|
||||
if name.startswith("-") and full:
|
||||
if name[0] == '-' and full:
|
||||
return [name, full]
|
||||
return [name]
|
||||
|
||||
|
@ -330,14 +267,13 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
A new ActionsMapParser object for the category
|
||||
|
||||
"""
|
||||
parser = self._subparsers.add_parser(
|
||||
name, description=category_help, help=category_help, **kwargs
|
||||
)
|
||||
return self.__class__(
|
||||
parent=self,
|
||||
parser=parser,
|
||||
subparser_kwargs={"title": "subcommands", "required": True},
|
||||
)
|
||||
parser = self._subparsers.add_parser(name,
|
||||
description=category_help,
|
||||
help=category_help,
|
||||
**kwargs)
|
||||
return self.__class__(self, parser, {
|
||||
'title': "subcommands", 'required': True
|
||||
})
|
||||
|
||||
def add_subcategory_parser(self, name, subcategory_help=None, **kwargs):
|
||||
"""Add a parser for a subcategory
|
||||
|
@ -349,29 +285,17 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
A new ActionsMapParser object for the category
|
||||
|
||||
"""
|
||||
parser = self._subparsers.add_parser(
|
||||
name,
|
||||
parser = self._subparsers.add_parser(name,
|
||||
type_="subcategory",
|
||||
description=subcategory_help,
|
||||
help=subcategory_help,
|
||||
**kwargs,
|
||||
)
|
||||
return self.__class__(
|
||||
parent=self,
|
||||
parser=parser,
|
||||
subparser_kwargs={"title": "actions", "required": True},
|
||||
)
|
||||
**kwargs)
|
||||
return self.__class__(self, parser, {
|
||||
'title': "actions", 'required': True
|
||||
})
|
||||
|
||||
def add_action_parser(
|
||||
self,
|
||||
name,
|
||||
tid,
|
||||
action_help=None,
|
||||
deprecated=False,
|
||||
deprecated_alias=[],
|
||||
hide_in_help=False,
|
||||
**kwargs,
|
||||
):
|
||||
def add_action_parser(self, name, tid, action_help=None, deprecated=False,
|
||||
deprecated_alias=[], **kwargs):
|
||||
"""Add a parser for an action
|
||||
|
||||
Keyword arguments:
|
||||
|
@ -383,67 +307,36 @@ class ActionsMapParser(BaseActionsMapParser):
|
|||
A new ExtendedArgumentParser object for the action
|
||||
|
||||
"""
|
||||
return self._subparsers.add_parser(
|
||||
name,
|
||||
return self._subparsers.add_parser(name,
|
||||
type_="action",
|
||||
help=action_help,
|
||||
description=action_help,
|
||||
deprecated=deprecated,
|
||||
deprecated_alias=deprecated_alias,
|
||||
hide_in_help=hide_in_help,
|
||||
)
|
||||
deprecated_alias=deprecated_alias)
|
||||
|
||||
def auth_method(self, args):
|
||||
ret = self.parse_args(args)
|
||||
tid = getattr(ret, "_tid", [])
|
||||
def add_global_arguments(self, arguments):
|
||||
for argument_name, argument_options in arguments.items():
|
||||
# will adapt arguments name for cli or api context
|
||||
names = self.format_arg_names(str(argument_name),
|
||||
argument_options.pop('full', None))
|
||||
|
||||
# We go down in the subparser tree until we find the leaf
|
||||
# corresponding to the tid with a defined authentication
|
||||
# (yeah it's a mess because the datastructure is a mess..)
|
||||
_p = self._subparsers
|
||||
for word in tid[1:]:
|
||||
_p = _p.choices[word]
|
||||
if hasattr(_p, "authentication"):
|
||||
return _p.authentication
|
||||
else:
|
||||
_p = _p._actions[1]
|
||||
|
||||
if tid == []:
|
||||
return None
|
||||
|
||||
raise MoulinetteError(f"Authentication undefined for {tid} ?", raw_msg=True)
|
||||
self.global_parser.add_argument(*names, **argument_options)
|
||||
|
||||
def parse_args(self, args, **kwargs):
|
||||
try:
|
||||
return self._parser.parse_args(args)
|
||||
ret = self._parser.parse_args(args)
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception as e:
|
||||
error_message = "unable to parse arguments '{}' because: {}".format(
|
||||
" ".join(args),
|
||||
e,
|
||||
)
|
||||
logger.exception(error_message)
|
||||
raise MoulinetteValidationError(error_message, raw_msg=True)
|
||||
|
||||
def want_to_take_lock(self, args):
|
||||
ret = self.parse_args(args)
|
||||
tid = getattr(ret, "_tid", [])
|
||||
if len(tid) == 3:
|
||||
_p = self._subparsers.choices[tid[1]]._actions[1].choices[tid[2]]
|
||||
elif len(tid) == 4:
|
||||
_p = (
|
||||
self._subparsers.choices[tid[1]]
|
||||
._actions[1]
|
||||
.choices[tid[2]]
|
||||
._actions[1]
|
||||
.choices[tid[3]]
|
||||
)
|
||||
|
||||
return getattr(_p, "want_to_take_lock", True)
|
||||
except:
|
||||
logger.exception("unable to parse arguments '%s'", ' '.join(args))
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('error_see_log'))
|
||||
else:
|
||||
self.prepare_action_namespace(getattr(ret, '_tid', None), ret)
|
||||
self._parser.dequeue_callbacks(ret)
|
||||
return ret
|
||||
|
||||
|
||||
class Interface:
|
||||
class Interface(BaseInterface):
|
||||
"""Command-line Interface for the moulinette
|
||||
|
||||
Initialize an interface connected to the standard input/output
|
||||
|
@ -454,27 +347,19 @@ class Interface:
|
|||
|
||||
"""
|
||||
|
||||
type = "cli"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
top_parser=None,
|
||||
load_only_category=None,
|
||||
actionsmap=None,
|
||||
locales_dir=None,
|
||||
):
|
||||
def __init__(self, actionsmap):
|
||||
# Set user locale
|
||||
m18n.set_locale(get_locale())
|
||||
|
||||
self.actionsmap = ActionsMap(
|
||||
actionsmap,
|
||||
ActionsMapParser(top_parser=top_parser),
|
||||
load_only_category=load_only_category,
|
||||
)
|
||||
# Connect signals to handlers
|
||||
msignals.set_handler('display', self._do_display)
|
||||
if os.isatty(1):
|
||||
msignals.set_handler('authenticate', self._do_authenticate)
|
||||
msignals.set_handler('prompt', self._do_prompt)
|
||||
|
||||
Moulinette._interface = self
|
||||
self.actionsmap = actionsmap
|
||||
|
||||
def run(self, args, output_as=None, timeout=None):
|
||||
def run(self, args, output_as=None, password=None, timeout=None):
|
||||
"""Run the moulinette
|
||||
|
||||
Process the action corresponding to the given arguments 'args'
|
||||
|
@ -486,29 +371,34 @@ class Interface:
|
|||
- json: return a JSON encoded string
|
||||
- plain: return a script-readable output
|
||||
- none: do not output the result
|
||||
- password -- The password to use in case of authentication
|
||||
- timeout -- Number of seconds before this command will timeout because it can't acquire the lock (meaning that another command is currently running), by default there is no timeout and the command will wait until it can get the lock
|
||||
|
||||
"""
|
||||
if output_as and output_as not in ['json', 'plain', 'none']:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('invalid_usage'))
|
||||
|
||||
if output_as and output_as not in ["json", "plain", "none"]:
|
||||
raise MoulinetteValidationError("invalid_usage")
|
||||
# auto-complete
|
||||
argcomplete.autocomplete(self.actionsmap.parser._parser)
|
||||
|
||||
if not args:
|
||||
raise MoulinetteValidationError("invalid_usage")
|
||||
# Set handler for authentication
|
||||
if password:
|
||||
msignals.set_handler('authenticate',
|
||||
lambda a, h: a(password=password))
|
||||
|
||||
try:
|
||||
ret = self.actionsmap.process(args, timeout=timeout)
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
raise MoulinetteError("operation_interrupted")
|
||||
raise MoulinetteError(errno.EINTR, m18n.g('operation_interrupted'))
|
||||
|
||||
if ret is None or output_as == "none":
|
||||
if ret is None or output_as == 'none':
|
||||
return
|
||||
|
||||
# Format and print result
|
||||
if output_as:
|
||||
if output_as == "json":
|
||||
if output_as == 'json':
|
||||
import json
|
||||
|
||||
from moulinette.utils.serialize import JSONExtendedEncoder
|
||||
print(json.dumps(ret, cls=JSONExtendedEncoder))
|
||||
else:
|
||||
plain_print_dict(ret)
|
||||
|
@ -517,112 +407,55 @@ class Interface:
|
|||
else:
|
||||
print(ret)
|
||||
|
||||
def authenticate(self, authenticator):
|
||||
# Hmpf we have no-use case in yunohost anymore where we need to auth
|
||||
# because everything is run as root ...
|
||||
# I guess we could imagine some yunohost-independant use-case where
|
||||
# moulinette is used to create a CLI for non-root user that needs to
|
||||
# auth somehow but hmpf -.-
|
||||
msg = m18n.g("password")
|
||||
credentials = self.prompt(msg, True, False, color="yellow")
|
||||
return authenticator.authenticate_credentials(credentials=credentials)
|
||||
# Signals handlers
|
||||
|
||||
def prompt(
|
||||
self,
|
||||
message,
|
||||
is_password=False,
|
||||
confirm=False,
|
||||
color="blue",
|
||||
prefill="",
|
||||
is_multiline=False,
|
||||
autocomplete=[],
|
||||
help=None,
|
||||
):
|
||||
def _do_authenticate(self, authenticator, help):
|
||||
"""Process the authentication
|
||||
|
||||
Handle the core.MoulinetteSignals.authenticate signal.
|
||||
|
||||
"""
|
||||
# TODO: Allow token authentication?
|
||||
msg = m18n.n(help) if help else m18n.g('password')
|
||||
return authenticator(password=self._do_prompt(msg, True, False,
|
||||
color='yellow'))
|
||||
|
||||
def _do_prompt(self, message, is_password, confirm, color='blue'):
|
||||
"""Prompt for a value
|
||||
|
||||
Handle the core.MoulinetteSignals.prompt signal.
|
||||
|
||||
Keyword arguments:
|
||||
- color -- The color to use for prompting message
|
||||
|
||||
"""
|
||||
|
||||
if not os.isatty(1):
|
||||
raise MoulinetteError(
|
||||
"Not a tty, can't do interactive prompts", raw_msg=True
|
||||
)
|
||||
|
||||
def _prompt(message):
|
||||
if not is_multiline:
|
||||
import prompt_toolkit
|
||||
from prompt_toolkit.completion import WordCompleter
|
||||
from prompt_toolkit.styles import Style
|
||||
|
||||
autocomplete_ = WordCompleter(autocomplete)
|
||||
style = Style.from_dict(
|
||||
{
|
||||
"": "",
|
||||
"message": f"#ansi{color} bold",
|
||||
}
|
||||
)
|
||||
|
||||
if help:
|
||||
|
||||
def bottom_toolbar():
|
||||
return [("class:", help)]
|
||||
|
||||
if is_password:
|
||||
prompt = lambda m: getpass.getpass(colorize(m18n.g('colon', m),
|
||||
color))
|
||||
else:
|
||||
bottom_toolbar = None
|
||||
|
||||
colored_message = [
|
||||
("class:message", message),
|
||||
("class:", ": "),
|
||||
]
|
||||
|
||||
return prompt_toolkit.prompt(
|
||||
colored_message,
|
||||
bottom_toolbar=bottom_toolbar,
|
||||
style=style,
|
||||
default=prefill,
|
||||
completer=autocomplete_,
|
||||
complete_while_typing=True,
|
||||
is_password=is_password,
|
||||
)
|
||||
|
||||
else:
|
||||
while True:
|
||||
value = input(
|
||||
colorize(m18n.g("edit_text_question", message), color)
|
||||
)
|
||||
value = value.lower().strip()
|
||||
if value in ["", "n", "no"]:
|
||||
return prefill
|
||||
elif value in ["y", "yes"]:
|
||||
break
|
||||
|
||||
initial_message = prefill.encode("utf-8")
|
||||
|
||||
with tempfile.NamedTemporaryFile(suffix=".tmp") as tf:
|
||||
tf.write(initial_message)
|
||||
tf.flush()
|
||||
call(["editor", tf.name])
|
||||
tf.seek(0)
|
||||
edited_message = tf.read()
|
||||
return edited_message.decode("utf-8")
|
||||
|
||||
value = _prompt(message)
|
||||
prompt = lambda m: raw_input(colorize(m18n.g('colon', m), color))
|
||||
value = prompt(message)
|
||||
|
||||
if confirm:
|
||||
m = message[0].lower() + message[1:]
|
||||
if _prompt(m18n.g("confirm", prompt=m)) != value:
|
||||
raise MoulinetteValidationError("values_mismatch")
|
||||
if prompt(m18n.g('confirm', prompt=m)) != value:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.g('values_mismatch'))
|
||||
|
||||
return value
|
||||
|
||||
def display(self, message, style="info"): # i18n: info
|
||||
"""Display a message"""
|
||||
if style == "success":
|
||||
print("{} {}".format(colorize(m18n.g("success"), "green"), message))
|
||||
elif style == "warning":
|
||||
print("{} {}".format(colorize(m18n.g("warning"), "yellow"), message))
|
||||
elif style == "error":
|
||||
print("{} {}".format(colorize(m18n.g("error"), "red"), message))
|
||||
def _do_display(self, message, style):
|
||||
"""Display a message
|
||||
|
||||
Handle the core.MoulinetteSignals.display signal.
|
||||
|
||||
"""
|
||||
if isinstance(message, unicode):
|
||||
message = message.encode('utf-8')
|
||||
if style == 'success':
|
||||
print('{} {}'.format(colorize(m18n.g('success'), 'green'), message))
|
||||
elif style == 'warning':
|
||||
print('{} {}'.format(colorize(m18n.g('warning'), 'yellow'), message))
|
||||
elif style == 'error':
|
||||
print('{} {}'.format(colorize(m18n.g('error'), 'red'), message))
|
||||
else:
|
||||
print(message)
|
||||
|
|
|
@ -1,48 +1,44 @@
|
|||
import os
|
||||
import yaml
|
||||
import toml
|
||||
import errno
|
||||
import shutil
|
||||
import json
|
||||
import grp
|
||||
|
||||
from pwd import getpwnam
|
||||
from collections import OrderedDict
|
||||
|
||||
from moulinette import m18n
|
||||
from moulinette.globals import CACHE_DIR
|
||||
from moulinette.core import MoulinetteError
|
||||
|
||||
# Files & directories --------------------------------------------------
|
||||
|
||||
|
||||
def read_file(file_path, file_mode="r"):
|
||||
def read_file(file_path):
|
||||
"""
|
||||
Read a regular text file
|
||||
|
||||
Keyword argument:
|
||||
file_path -- Path to the text file
|
||||
"""
|
||||
assert isinstance(
|
||||
file_path, str
|
||||
), "Error: file_path '{}' should be a string but is of type '{}' instead".format(
|
||||
file_path,
|
||||
type(file_path),
|
||||
)
|
||||
assert isinstance(file_path, basestring)
|
||||
|
||||
# Check file exists
|
||||
if not os.path.isfile(file_path):
|
||||
raise MoulinetteError("file_not_exist", path=file_path)
|
||||
raise MoulinetteError(errno.ENOENT,
|
||||
m18n.g('file_not_exist', path=file_path))
|
||||
|
||||
# Open file and read content
|
||||
try:
|
||||
with open(file_path, file_mode) as f:
|
||||
with open(file_path, "r") as f:
|
||||
file_content = f.read()
|
||||
except IOError as e:
|
||||
raise MoulinetteError("cannot_open_file", file=file_path, error=str(e))
|
||||
raise MoulinetteError(errno.EACCES,
|
||||
m18n.g('cannot_open_file',
|
||||
file=file_path, error=str(e)))
|
||||
except Exception as e:
|
||||
raise MoulinetteError(
|
||||
"unknown_error_reading_file", file=file_path, error=str(e)
|
||||
)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.g('error_reading_file',
|
||||
file=file_path, error=str(e)))
|
||||
|
||||
return file_content
|
||||
|
||||
|
@ -62,50 +58,33 @@ def read_json(file_path):
|
|||
try:
|
||||
loaded_json = json.loads(file_content)
|
||||
except ValueError as e:
|
||||
raise MoulinetteError("corrupted_json", ressource=file_path, error=str(e))
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.g('corrupted_json',
|
||||
ressource=file_path, error=str(e)))
|
||||
|
||||
return loaded_json
|
||||
|
||||
|
||||
def read_yaml(file_):
|
||||
def read_yaml(file_path):
|
||||
"""
|
||||
Safely read a yaml file
|
||||
|
||||
Keyword argument:
|
||||
file -- Path or stream to the yaml file
|
||||
"""
|
||||
|
||||
# Read file
|
||||
file_path = file_ if isinstance(file_, str) else file_.name
|
||||
file_content = read_file(file_) if isinstance(file_, str) else file_
|
||||
|
||||
# Try to load yaml to check if it's syntaxically correct
|
||||
try:
|
||||
loaded_yaml = yaml.safe_load(file_content)
|
||||
except Exception as e:
|
||||
raise MoulinetteError("corrupted_yaml", ressource=file_path, error=str(e))
|
||||
|
||||
return loaded_yaml
|
||||
|
||||
|
||||
def read_toml(file_path):
|
||||
"""
|
||||
Safely read a toml file
|
||||
|
||||
Keyword argument:
|
||||
file_path -- Path to the toml file
|
||||
file_path -- Path to the yaml file
|
||||
"""
|
||||
|
||||
# Read file
|
||||
file_content = read_file(file_path)
|
||||
|
||||
# Try to load toml to check if it's syntactically correct
|
||||
# Try to load yaml to check if it's syntaxically correct
|
||||
try:
|
||||
loaded_toml = toml.loads(file_content, _dict=OrderedDict)
|
||||
except Exception as e:
|
||||
raise MoulinetteError("corrupted_toml", ressource=file_path, error=str(e))
|
||||
loaded_yaml = yaml.safe_load(file_content)
|
||||
except ValueError as e:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.g('corrupted_yaml',
|
||||
ressource=file_path, error=str(e)))
|
||||
|
||||
return loaded_toml
|
||||
return loaded_yaml
|
||||
|
||||
|
||||
def write_to_file(file_path, data, file_mode="w"):
|
||||
|
@ -119,40 +98,27 @@ def write_to_file(file_path, data, file_mode="w"):
|
|||
file_mode -- Mode used when writing the file. Option meant to be used
|
||||
by append_to_file to avoid duplicating the code of this function.
|
||||
"""
|
||||
assert (
|
||||
isinstance(data, str) or isinstance(data, bytes) or isinstance(data, list)
|
||||
), "Error: data '{}' should be either a string or a list but is of type '{}'".format(
|
||||
data,
|
||||
type(data),
|
||||
)
|
||||
assert not os.path.isdir(file_path), (
|
||||
"Error: file_path '%s' point to a dir, it should be a file" % file_path
|
||||
)
|
||||
assert os.path.isdir(
|
||||
os.path.dirname(file_path)
|
||||
), "Error: the path ('{}') base dir ('{}') is not a dir".format(
|
||||
file_path,
|
||||
os.path.dirname(file_path),
|
||||
)
|
||||
assert isinstance(data, basestring) or isinstance(data, list)
|
||||
assert not os.path.isdir(file_path)
|
||||
assert os.path.isdir(os.path.dirname(file_path))
|
||||
|
||||
# If data is a list, check elements are strings and build a single string
|
||||
if isinstance(data, list):
|
||||
if not isinstance(data, basestring):
|
||||
for element in data:
|
||||
assert isinstance(
|
||||
element, str
|
||||
), "Error: element '{}' should be a string but is of type '{}' instead".format(
|
||||
element,
|
||||
type(element),
|
||||
)
|
||||
data = "\n".join(data)
|
||||
assert isinstance(element, basestring)
|
||||
data = '\n'.join(data)
|
||||
|
||||
try:
|
||||
with open(file_path, file_mode) as f:
|
||||
f.write(data)
|
||||
except IOError as e:
|
||||
raise MoulinetteError("cannot_write_file", file=file_path, error=str(e))
|
||||
raise MoulinetteError(errno.EACCES,
|
||||
m18n.g('cannot_write_file',
|
||||
file=file_path, error=str(e)))
|
||||
except Exception as e:
|
||||
raise MoulinetteError("error_writing_file", file=file_path, error=str(e))
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.g('error_writing_file',
|
||||
file=file_path, error=str(e)))
|
||||
|
||||
|
||||
def append_to_file(file_path, data):
|
||||
|
@ -167,7 +133,7 @@ def append_to_file(file_path, data):
|
|||
write_to_file(file_path, data, file_mode="a")
|
||||
|
||||
|
||||
def write_to_json(file_path, data, sort_keys=False, indent=None):
|
||||
def write_to_json(file_path, data):
|
||||
"""
|
||||
Write a dictionnary or a list to a json file
|
||||
|
||||
|
@ -177,48 +143,7 @@ def write_to_json(file_path, data, sort_keys=False, indent=None):
|
|||
"""
|
||||
|
||||
# Assumptions
|
||||
assert isinstance(
|
||||
file_path, str
|
||||
), "Error: file_path '{}' should be a string but is of type '{}' instead".format(
|
||||
file_path,
|
||||
type(file_path),
|
||||
)
|
||||
assert isinstance(data, dict) or isinstance(
|
||||
data, list
|
||||
), "Error: data '{}' should be a dict or a list but is of type '{}' instead".format(
|
||||
data,
|
||||
type(data),
|
||||
)
|
||||
assert not os.path.isdir(file_path), (
|
||||
"Error: file_path '%s' point to a dir, it should be a file" % file_path
|
||||
)
|
||||
assert os.path.isdir(
|
||||
os.path.dirname(file_path)
|
||||
), "Error: the path ('{}') base dir ('{}') is not a dir".format(
|
||||
file_path,
|
||||
os.path.dirname(file_path),
|
||||
)
|
||||
|
||||
# Write dict to file
|
||||
try:
|
||||
with open(file_path, "w") as f:
|
||||
json.dump(data, f, sort_keys=sort_keys, indent=indent)
|
||||
except IOError as e:
|
||||
raise MoulinetteError("cannot_write_file", file=file_path, error=str(e))
|
||||
except Exception as e:
|
||||
raise MoulinetteError("error_writing_file", file=file_path, error=str(e))
|
||||
|
||||
|
||||
def write_to_yaml(file_path, data):
|
||||
"""
|
||||
Write a dictionnary or a list to a yaml file
|
||||
|
||||
Keyword argument:
|
||||
file_path -- Path to the output yaml file
|
||||
data -- The data to write (must be a dict or a list)
|
||||
"""
|
||||
# Assumptions
|
||||
assert isinstance(file_path, str)
|
||||
assert isinstance(file_path, basestring)
|
||||
assert isinstance(data, dict) or isinstance(data, list)
|
||||
assert not os.path.isdir(file_path)
|
||||
assert os.path.isdir(os.path.dirname(file_path))
|
||||
|
@ -226,14 +151,18 @@ def write_to_yaml(file_path, data):
|
|||
# Write dict to file
|
||||
try:
|
||||
with open(file_path, "w") as f:
|
||||
yaml.safe_dump(data, f, default_flow_style=False)
|
||||
json.dump(data, f)
|
||||
except IOError as e:
|
||||
raise MoulinetteError("cannot_write_file", file=file_path, error=str(e))
|
||||
raise MoulinetteError(errno.EACCES,
|
||||
m18n.g('cannot_write_file',
|
||||
file=file_path, error=str(e)))
|
||||
except Exception as e:
|
||||
raise MoulinetteError("error_writing_file", file=file_path, error=str(e))
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.g('_error_writing_file',
|
||||
file=file_path, error=str(e)))
|
||||
|
||||
|
||||
def mkdir(path, mode=0o0777, parents=False, uid=None, gid=None, force=False):
|
||||
def mkdir(path, mode=0777, parents=False, uid=None, gid=None, force=False):
|
||||
"""Create a directory with optional features
|
||||
|
||||
Create a directory and optionaly set its permissions to mode and its
|
||||
|
@ -250,7 +179,7 @@ def mkdir(path, mode=0o0777, parents=False, uid=None, gid=None, force=False):
|
|||
|
||||
"""
|
||||
if os.path.exists(path) and not force:
|
||||
raise OSError(errno.EEXIST, m18n.g("folder_exists", path=path))
|
||||
raise OSError(errno.EEXIST, m18n.g('folder_exists', path=path))
|
||||
|
||||
if parents:
|
||||
# Create parents directories as needed
|
||||
|
@ -267,15 +196,7 @@ def mkdir(path, mode=0o0777, parents=False, uid=None, gid=None, force=False):
|
|||
return
|
||||
|
||||
# Create directory and set permissions
|
||||
try:
|
||||
oldmask = os.umask(000)
|
||||
os.mkdir(path, mode)
|
||||
os.umask(oldmask)
|
||||
except OSError:
|
||||
# mimic Python3.2+ os.makedirs exist_ok behaviour
|
||||
if not force or not os.path.isdir(path):
|
||||
raise
|
||||
|
||||
if uid is not None or gid is not None:
|
||||
chown(path, uid, gid)
|
||||
|
||||
|
@ -293,18 +214,20 @@ def chown(path, uid=None, gid=None, recursive=False):
|
|||
raise ValueError("either uid or gid argument is required")
|
||||
|
||||
# Retrieve uid/gid
|
||||
if isinstance(uid, str):
|
||||
if isinstance(uid, basestring):
|
||||
try:
|
||||
uid = getpwnam(uid).pw_uid
|
||||
except KeyError:
|
||||
raise MoulinetteError("unknown_user", user=uid)
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.g('unknown_user', user=uid))
|
||||
elif uid is None:
|
||||
uid = -1
|
||||
if isinstance(gid, str):
|
||||
if isinstance(gid, basestring):
|
||||
try:
|
||||
gid = grp.getgrnam(gid).gr_gid
|
||||
except KeyError:
|
||||
raise MoulinetteError("unknown_group", group=gid)
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.g('unknown_group', group=gid))
|
||||
elif gid is None:
|
||||
gid = -1
|
||||
|
||||
|
@ -317,9 +240,9 @@ def chown(path, uid=None, gid=None, recursive=False):
|
|||
for f in files:
|
||||
os.chown(os.path.join(root, f), uid, gid)
|
||||
except Exception as e:
|
||||
raise MoulinetteError(
|
||||
"error_changing_file_permissions", path=path, error=str(e)
|
||||
)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.g('error_changing_file_permissions',
|
||||
path=path, error=str(e)))
|
||||
|
||||
|
||||
def chmod(path, mode, fmode=None, recursive=False):
|
||||
|
@ -343,9 +266,9 @@ def chmod(path, mode, fmode=None, recursive=False):
|
|||
for f in files:
|
||||
os.chmod(os.path.join(root, f), fmode)
|
||||
except Exception as e:
|
||||
raise MoulinetteError(
|
||||
"error_changing_file_permissions", path=path, error=str(e)
|
||||
)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.g('error_changing_file_permissions',
|
||||
path=path, error=str(e)))
|
||||
|
||||
|
||||
def rm(path, recursive=False, force=False):
|
||||
|
@ -364,11 +287,6 @@ def rm(path, recursive=False, force=False):
|
|||
os.remove(path)
|
||||
except OSError as e:
|
||||
if not force:
|
||||
raise MoulinetteError("error_removing", path=path, error=str(e))
|
||||
|
||||
|
||||
def cp(source, dest, recursive=False, **kwargs):
|
||||
if recursive and os.path.isdir(source):
|
||||
return shutil.copytree(source, dest, symlinks=True, **kwargs)
|
||||
else:
|
||||
return shutil.copy2(source, dest, follow_symlinks=False, **kwargs)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.g('error_removing',
|
||||
path=path, error=str(e)))
|
||||
|
|
|
@ -1,29 +1,10 @@
|
|||
import os
|
||||
import logging
|
||||
|
||||
# import all constants because other modules try to import them from this
|
||||
# import all constant because other modules tries to important them from this
|
||||
# module because SUCCESS is defined in this module
|
||||
from logging import (
|
||||
addLevelName,
|
||||
setLoggerClass,
|
||||
Logger,
|
||||
getLogger,
|
||||
NOTSET, # noqa
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
CRITICAL,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"NOTSET", # noqa
|
||||
"DEBUG",
|
||||
"INFO",
|
||||
"WARNING",
|
||||
"ERROR",
|
||||
"CRITICAL",
|
||||
"SUCCESS",
|
||||
]
|
||||
from logging import (addLevelName, setLoggerClass, Logger, getLogger, NOTSET,
|
||||
DEBUG, INFO, WARNING, ERROR, CRITICAL)
|
||||
|
||||
|
||||
# Global configuration and functions -----------------------------------
|
||||
|
@ -31,20 +12,27 @@ __all__ = [
|
|||
SUCCESS = 25
|
||||
|
||||
DEFAULT_LOGGING = {
|
||||
"version": 1,
|
||||
"disable_existing_loggers": False,
|
||||
"formatters": {
|
||||
"simple": {"format": "%(asctime)-15s %(levelname)-8s %(name)s - %(message)s"},
|
||||
},
|
||||
"handlers": {
|
||||
"console": {
|
||||
"level": "DEBUG",
|
||||
"formatter": "simple",
|
||||
"class": "logging.StreamHandler",
|
||||
"stream": "ext://sys.stdout",
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'simple': {
|
||||
'format': '%(asctime)-15s %(levelname)-8s %(name)s - %(message)s'
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'formatter': 'simple',
|
||||
'class': 'logging.StreamHandler',
|
||||
'stream': 'ext://sys.stdout',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'moulinette': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console'],
|
||||
},
|
||||
},
|
||||
"loggers": {"moulinette": {"level": "DEBUG", "handlers": ["console"]}},
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,7 +46,7 @@ def configure_logging(logging_config=None):
|
|||
from logging.config import dictConfig
|
||||
|
||||
# add custom logging level and class
|
||||
addLevelName(SUCCESS, "SUCCESS")
|
||||
addLevelName(SUCCESS, 'SUCCESS')
|
||||
setLoggerClass(MoulinetteLogger)
|
||||
|
||||
# load configuration from dict
|
||||
|
@ -69,18 +57,15 @@ def configure_logging(logging_config=None):
|
|||
|
||||
def getHandlersByClass(classinfo, limit=0):
|
||||
"""Retrieve registered handlers of a given class."""
|
||||
|
||||
from logging import _handlers
|
||||
|
||||
handlers = []
|
||||
for ref in _handlers.itervaluerefs():
|
||||
for ref in logging._handlers.itervaluerefs():
|
||||
o = ref()
|
||||
if o is not None and isinstance(o, classinfo):
|
||||
if limit == 1:
|
||||
return o
|
||||
handlers.append(o)
|
||||
if limit != 0 and len(handlers) > limit:
|
||||
return handlers[: limit - 1]
|
||||
return handlers[:limit - 1]
|
||||
return handlers
|
||||
|
||||
|
||||
|
@ -93,7 +78,6 @@ class MoulinetteLogger(Logger):
|
|||
LogRecord extra and can be used with the ActionFilter.
|
||||
|
||||
"""
|
||||
|
||||
action_id = None
|
||||
|
||||
def success(self, msg, *args, **kwargs):
|
||||
|
@ -101,19 +85,16 @@ class MoulinetteLogger(Logger):
|
|||
if self.isEnabledFor(SUCCESS):
|
||||
self._log(SUCCESS, msg, args, **kwargs)
|
||||
|
||||
def findCaller(self, *args):
|
||||
def findCaller(self):
|
||||
"""Override findCaller method to consider this source file."""
|
||||
|
||||
from logging import currentframe, _srcfile
|
||||
|
||||
f = currentframe()
|
||||
f = logging.currentframe()
|
||||
if f is not None:
|
||||
f = f.f_back
|
||||
rv = "(unknown file)", 0, "(unknown function)"
|
||||
while hasattr(f, "f_code"):
|
||||
co = f.f_code
|
||||
filename = os.path.normcase(co.co_filename)
|
||||
if filename == _srcfile or filename == __file__:
|
||||
if filename == logging._srcfile or filename == __file__:
|
||||
f = f.f_back
|
||||
continue
|
||||
rv = (co.co_filename, f.f_lineno, co.co_name)
|
||||
|
@ -123,12 +104,12 @@ class MoulinetteLogger(Logger):
|
|||
def _log(self, *args, **kwargs):
|
||||
"""Append action_id if available to the extra."""
|
||||
if self.action_id is not None:
|
||||
extra = kwargs.get("extra", {})
|
||||
if "action_id" not in extra:
|
||||
extra = kwargs.get('extra', {})
|
||||
if 'action_id' not in extra:
|
||||
# FIXME: Get real action_id instead of logger/current one
|
||||
extra["action_id"] = _get_action_id()
|
||||
kwargs["extra"] = extra
|
||||
return super()._log(*args, **kwargs)
|
||||
extra['action_id'] = _get_action_id()
|
||||
kwargs['extra'] = extra
|
||||
return Logger._log(self, *args, **kwargs)
|
||||
|
||||
|
||||
# Action logging -------------------------------------------------------
|
||||
|
@ -138,7 +119,7 @@ action_id = 0
|
|||
|
||||
|
||||
def _get_action_id():
|
||||
return "%d.%d" % (pid, action_id)
|
||||
return '%d.%d' % (pid, action_id)
|
||||
|
||||
|
||||
def start_action_logging():
|
||||
|
@ -164,14 +145,14 @@ def getActionLogger(name=None, logger=None, action_id=None):
|
|||
|
||||
"""
|
||||
if not name and not logger:
|
||||
raise ValueError("Either a name or a logger must be specified")
|
||||
raise ValueError('Either a name or a logger must be specified')
|
||||
|
||||
logger = logger or getLogger(name)
|
||||
logger.action_id = action_id if action_id else _get_action_id()
|
||||
return logger
|
||||
|
||||
|
||||
class ActionFilter:
|
||||
class ActionFilter(object):
|
||||
"""Extend log record for an optionnal action
|
||||
|
||||
Filter a given record and look for an `action_id` key. If it is not found
|
||||
|
@ -181,15 +162,15 @@ class ActionFilter:
|
|||
|
||||
"""
|
||||
|
||||
def __init__(self, message_key="fmessage", strict=False):
|
||||
def __init__(self, message_key='fmessage', strict=False):
|
||||
self.message_key = message_key
|
||||
self.strict = strict
|
||||
|
||||
def filter(self, record):
|
||||
msg = record.getMessage()
|
||||
action_id = record.__dict__.get("action_id", None)
|
||||
action_id = record.__dict__.get('action_id', None)
|
||||
if action_id is not None:
|
||||
msg = "[{:s}] {:s}".format(action_id, msg)
|
||||
msg = '[{:s}] {:s}'.format(action_id, msg)
|
||||
elif self.strict:
|
||||
return False
|
||||
record.__dict__[self.message_key] = msg
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import errno
|
||||
import json
|
||||
|
||||
from moulinette import m18n
|
||||
from moulinette.core import MoulinetteError
|
||||
|
||||
|
||||
|
@ -15,30 +17,35 @@ def download_text(url, timeout=30, expected_status_code=200):
|
|||
None to ignore the status code.
|
||||
"""
|
||||
import requests # lazy loading this module for performance reasons
|
||||
|
||||
# Assumptions
|
||||
assert isinstance(url, str)
|
||||
|
||||
# Download file
|
||||
try:
|
||||
r = requests.get(url, timeout=timeout)
|
||||
# SSL exceptions
|
||||
except requests.exceptions.SSLError:
|
||||
raise MoulinetteError("download_ssl_error", url=url)
|
||||
# Invalid URL
|
||||
except requests.exceptions.ConnectionError:
|
||||
raise MoulinetteError("invalid_url", url=url)
|
||||
raise MoulinetteError(errno.EBADE,
|
||||
m18n.g('invalid_url', url=url))
|
||||
# SSL exceptions
|
||||
except requests.exceptions.SSLError:
|
||||
raise MoulinetteError(errno.EBADE,
|
||||
m18n.g('download_ssl_error', url=url))
|
||||
# Timeout exceptions
|
||||
except requests.exceptions.Timeout:
|
||||
raise MoulinetteError("download_timeout", url=url)
|
||||
raise MoulinetteError(errno.ETIME,
|
||||
m18n.g('download_timeout', url=url))
|
||||
# Unknown stuff
|
||||
except Exception as e:
|
||||
raise MoulinetteError("download_unknown_error", url=url, error=str(e))
|
||||
raise MoulinetteError(errno.ECONNRESET,
|
||||
m18n.g('download_unknown_error',
|
||||
url=url, error=str(e)))
|
||||
# Assume error if status code is not 200 (OK)
|
||||
if expected_status_code is not None and r.status_code != expected_status_code:
|
||||
raise MoulinetteError(
|
||||
"download_bad_status_code", url=url, code=str(r.status_code)
|
||||
)
|
||||
if expected_status_code is not None \
|
||||
and r.status_code != expected_status_code:
|
||||
raise MoulinetteError(errno.EBADE,
|
||||
m18n.g('download_bad_status_code',
|
||||
url=url, code=str(r.status_code)))
|
||||
|
||||
return r.text
|
||||
|
||||
|
@ -58,7 +65,8 @@ def download_json(url, timeout=30, expected_status_code=200):
|
|||
# Try to load json to check if it's syntaxically correct
|
||||
try:
|
||||
loaded_json = json.loads(text)
|
||||
except ValueError as e:
|
||||
raise MoulinetteError("corrupted_json", ressource=url, error=str(e))
|
||||
except ValueError:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.g('corrupted_json', ressource=url))
|
||||
|
||||
return loaded_json
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
import errno
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
import threading
|
||||
import queue
|
||||
import logging
|
||||
|
||||
from moulinette.core import MoulinetteError
|
||||
|
||||
# This import is unused in this file. It will be deleted in future (W0611 PEP8),
|
||||
# but for the momment we keep it due to yunohost moulinette script that used
|
||||
# process.quote syntax to access this module !
|
||||
from shlex import quote
|
||||
try:
|
||||
from pipes import quote # Python2 & Python3 <= 3.2
|
||||
except ImportError:
|
||||
from shlex import quote # Python3 >= 3.3
|
||||
|
||||
from .stream import async_file_reading
|
||||
quote # This line is here to avoid W0611 PEP8 error (see comments above)
|
||||
|
||||
# Prevent to import subprocess only for common classes
|
||||
CalledProcessError = subprocess.CalledProcessError
|
||||
logger = logging.getLogger("moulinette.utils.process")
|
||||
|
||||
|
||||
# Alternative subprocess methods ---------------------------------------
|
||||
|
||||
|
||||
def check_output(args, stderr=subprocess.STDOUT, shell=True, **kwargs):
|
||||
"""Run command with arguments and return its output as a byte string
|
||||
|
||||
|
@ -25,16 +29,11 @@ def check_output(args, stderr=subprocess.STDOUT, shell=True, **kwargs):
|
|||
and use shell by default before calling subprocess.check_output.
|
||||
|
||||
"""
|
||||
return (
|
||||
subprocess.check_output(args, stderr=stderr, shell=shell, **kwargs)
|
||||
.decode("utf-8")
|
||||
.strip()
|
||||
)
|
||||
return subprocess.check_output(args, stderr=stderr, shell=shell, **kwargs)
|
||||
|
||||
|
||||
# Call with stream access ----------------------------------------------
|
||||
|
||||
|
||||
def call_async_output(args, callback, **kwargs):
|
||||
"""Run command and provide its output asynchronously
|
||||
|
||||
|
@ -50,96 +49,97 @@ def call_async_output(args, callback, **kwargs):
|
|||
Keyword arguments:
|
||||
- args -- String or sequence of program arguments
|
||||
- callback -- Method or object to call with output as argument
|
||||
- kwargs -- Additional arguments for the Popen constructor
|
||||
- **kwargs -- Additional arguments for the Popen constructor
|
||||
|
||||
Returns:
|
||||
Exit status of the command
|
||||
|
||||
"""
|
||||
for a in ["stdout", "stderr"]:
|
||||
for a in ['stdout', 'stderr']:
|
||||
if a in kwargs:
|
||||
raise ValueError("%s argument not allowed, " "it will be overridden." % a)
|
||||
raise ValueError('%s argument not allowed, '
|
||||
'it will be overridden.' % a)
|
||||
|
||||
log_queue = queue.Queue()
|
||||
if "stdinfo" in kwargs and kwargs["stdinfo"] != None:
|
||||
assert len(callback) == 3
|
||||
stdinfo = kwargs.pop("stdinfo")
|
||||
os.mkfifo(stdinfo, 0600)
|
||||
# Open stdinfo for reading (in a nonblocking way, i.e. even
|
||||
# if command does not write in the stdinfo pipe...)
|
||||
stdinfo_f = os.open(stdinfo, os.O_RDONLY|os.O_NONBLOCK)
|
||||
else:
|
||||
kwargs.pop("stdinfo")
|
||||
stdinfo = None
|
||||
|
||||
kwargs["stdout"] = LogPipe(callback[0], log_queue)
|
||||
kwargs["stderr"] = LogPipe(callback[1], log_queue)
|
||||
stdinfo = LogPipe(callback[2], log_queue) if len(callback) >= 3 else None
|
||||
if stdinfo:
|
||||
kwargs["pass_fds"] = [stdinfo.fdWrite]
|
||||
if "env" not in kwargs:
|
||||
kwargs["env"] = os.environ
|
||||
kwargs["env"]["YNH_STDINFO"] = str(stdinfo.fdWrite)
|
||||
# Validate callback argument
|
||||
if isinstance(callback, tuple):
|
||||
if len(callback) < 2:
|
||||
raise ValueError('callback argument should be a 2-tuple')
|
||||
kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE
|
||||
separate_stderr = True
|
||||
elif callable(callback):
|
||||
kwargs['stdout'] = subprocess.PIPE
|
||||
kwargs['stderr'] = subprocess.STDOUT
|
||||
separate_stderr = False
|
||||
callback = (callback,)
|
||||
else:
|
||||
raise ValueError('callback argument must be callable or a 2-tuple')
|
||||
|
||||
if "env" in kwargs and not all(isinstance(v, str) for v in kwargs["env"].values()):
|
||||
logger.warning(
|
||||
"While trying to call call_async_output: env contained non-string values, probably gonna cause issue in Popen(...)"
|
||||
)
|
||||
|
||||
try:
|
||||
# Run the command
|
||||
p = subprocess.Popen(args, **kwargs)
|
||||
|
||||
while p.poll() is None:
|
||||
while True:
|
||||
try:
|
||||
callback, message = log_queue.get(True, 1)
|
||||
except queue.Empty:
|
||||
break
|
||||
|
||||
callback(message)
|
||||
while True:
|
||||
try:
|
||||
callback, message = log_queue.get_nowait()
|
||||
except queue.Empty:
|
||||
break
|
||||
|
||||
callback(message)
|
||||
finally:
|
||||
kwargs["stdout"].close()
|
||||
kwargs["stderr"].close()
|
||||
# Wrap and get command outputs
|
||||
stdout_reader, stdout_consum = async_file_reading(p.stdout, callback[0])
|
||||
if separate_stderr:
|
||||
stderr_reader, stderr_consum = async_file_reading(p.stderr, callback[1])
|
||||
if stdinfo:
|
||||
stdinfo.close()
|
||||
stdinfo_reader, stdinfo_consum = async_file_reading(stdinfo_f, callback[2])
|
||||
|
||||
while not stdout_reader.eof() and not stderr_reader.eof():
|
||||
while not stdout_consum.empty() or not stderr_consum.empty():
|
||||
# alternate between the 2 consumers to avoid desynchronisation
|
||||
# this way is not 100% perfect but should do it
|
||||
stdout_consum.process_next_line()
|
||||
stderr_consum.process_next_line()
|
||||
stdinfo_consum.process_next_line()
|
||||
time.sleep(.1)
|
||||
stderr_reader.join()
|
||||
# clear the queues
|
||||
stdout_consum.process_current_queue()
|
||||
stderr_consum.process_current_queue()
|
||||
stdinfo_consum.process_current_queue()
|
||||
else:
|
||||
while not stdout_reader.eof():
|
||||
stdout_consum.process_current_queue()
|
||||
time.sleep(.1)
|
||||
stdout_reader.join()
|
||||
# clear the queue
|
||||
stdout_consum.process_current_queue()
|
||||
|
||||
if stdinfo:
|
||||
# Remove the stdinfo pipe
|
||||
os.remove(stdinfo)
|
||||
os.rmdir(os.path.dirname(stdinfo))
|
||||
stdinfo_reader.join()
|
||||
stdinfo_consum.process_current_queue()
|
||||
|
||||
# on slow hardware, in very edgy situations it is possible that the process
|
||||
# isn't finished just after having closed stdout and stderr, so we wait a
|
||||
# bit to give hime the time to finish (while having a timeout)
|
||||
# Note : p.poll() returns None is the process hasn't finished yet
|
||||
start = time.time()
|
||||
while time.time() - start < 10:
|
||||
if p.poll() is not None:
|
||||
return p.poll()
|
||||
time.sleep(.1)
|
||||
|
||||
return p.poll()
|
||||
|
||||
|
||||
class LogPipe(threading.Thread):
|
||||
# Adapted from https://codereview.stackexchange.com/a/17959
|
||||
def __init__(self, log_callback, queue):
|
||||
"""Setup the object with a logger and a loglevel
|
||||
and start the thread
|
||||
"""
|
||||
threading.Thread.__init__(self)
|
||||
self.daemon = False
|
||||
self.log_callback = log_callback
|
||||
|
||||
self.fdRead, self.fdWrite = os.pipe()
|
||||
self.pipeReader = os.fdopen(self.fdRead, "rb")
|
||||
|
||||
self.queue = queue
|
||||
|
||||
self.start()
|
||||
|
||||
def fileno(self):
|
||||
"""Return the write file descriptor of the pipe"""
|
||||
return self.fdWrite
|
||||
|
||||
def run(self):
|
||||
"""Run the thread, logging everything."""
|
||||
for line in iter(self.pipeReader.readline, b""):
|
||||
self.queue.put((self.log_callback, line.decode("utf-8").strip("\n")))
|
||||
|
||||
self.pipeReader.close()
|
||||
|
||||
def close(self):
|
||||
"""Close the write end of the pipe."""
|
||||
os.close(self.fdWrite)
|
||||
|
||||
|
||||
# Call multiple commands -----------------------------------------------
|
||||
|
||||
|
||||
def run_commands(cmds, callback=None, separate_stderr=False, shell=True, **kwargs):
|
||||
def run_commands(cmds, callback=None, separate_stderr=False, shell=True,
|
||||
**kwargs):
|
||||
"""Run multiple commands with error management
|
||||
|
||||
Run a list of commands and allow to manage how to treat errors either
|
||||
|
@ -167,7 +167,7 @@ def run_commands(cmds, callback=None, separate_stderr=False, shell=True, **kwarg
|
|||
callback is given, a "subprocess.CalledProcessError"
|
||||
will be raised in case of command failure.
|
||||
- separate_stderr -- True to return command output as a 2-tuple
|
||||
- kwargs -- Additional arguments for the Popen constructor
|
||||
- **kwargs -- Additional arguments for the Popen constructor
|
||||
|
||||
Returns:
|
||||
Number of failed commands
|
||||
|
@ -176,18 +176,18 @@ def run_commands(cmds, callback=None, separate_stderr=False, shell=True, **kwarg
|
|||
|
||||
# stdout and stderr are specified by this code later, so they cannot be
|
||||
# overriden by user input
|
||||
for a in ["stdout", "stderr"]:
|
||||
for a in ['stdout', 'stderr']:
|
||||
if a in kwargs:
|
||||
raise ValueError("%s argument not allowed, " "it will be overridden." % a)
|
||||
raise ValueError('%s argument not allowed, '
|
||||
'it will be overridden.' % a)
|
||||
|
||||
# If no callback specified...
|
||||
if callback is None:
|
||||
# Raise CalledProcessError on command failure
|
||||
def callback(r, c, o):
|
||||
raise CalledProcessError(r, c, o)
|
||||
|
||||
elif not callable(callback):
|
||||
raise ValueError("callback argument must be callable")
|
||||
raise ValueError('callback argument must be callable')
|
||||
|
||||
# Manage stderr
|
||||
if separate_stderr:
|
||||
|
@ -200,9 +200,9 @@ def run_commands(cmds, callback=None, separate_stderr=False, shell=True, **kwarg
|
|||
# Iterate over commands
|
||||
error = 0
|
||||
for cmd in cmds:
|
||||
process = subprocess.Popen(
|
||||
cmd, stdout=subprocess.PIPE, stderr=_stderr, shell=shell, **kwargs
|
||||
)
|
||||
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
stderr=_stderr, shell=shell, **kwargs)
|
||||
|
||||
output = _get_output(*process.communicate())
|
||||
retcode = process.poll()
|
||||
|
|
35
moulinette/utils/serialize.py
Normal file
35
moulinette/utils/serialize.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
import logging
|
||||
from json.encoder import JSONEncoder
|
||||
import datetime
|
||||
|
||||
logger = logging.getLogger('moulinette.utils.serialize')
|
||||
|
||||
|
||||
# JSON utilities -------------------------------------------------------
|
||||
|
||||
class JSONExtendedEncoder(JSONEncoder):
|
||||
"""Extended JSON encoder
|
||||
|
||||
Extend default JSON encoder to recognize more types and classes. It
|
||||
will never raise if the object can't be encoded and return its repr
|
||||
instead.
|
||||
The following objects and types are supported:
|
||||
- set: converted into list
|
||||
|
||||
"""
|
||||
|
||||
def default(self, o):
|
||||
"""Return a serializable object"""
|
||||
# Convert compatible containers into list
|
||||
if isinstance(o, set) or (
|
||||
hasattr(o, '__iter__') and hasattr(o, 'next')):
|
||||
return list(o)
|
||||
|
||||
# Display the date in its iso format ISO-8601 Internet Profile (RFC 3339)
|
||||
if isinstance(o, datetime.datetime) or isinstance(o, datetime.date):
|
||||
return o.isoformat()
|
||||
|
||||
# Return the repr for object that json can't encode
|
||||
logger.warning('cannot properly encode in JSON the object %s, '
|
||||
'returned repr is: %r', type(o), o)
|
||||
return repr(o)
|
107
moulinette/utils/stream.py
Normal file
107
moulinette/utils/stream.py
Normal file
|
@ -0,0 +1,107 @@
|
|||
import os
|
||||
import time
|
||||
|
||||
from multiprocessing.process import Process
|
||||
from multiprocessing.queues import SimpleQueue
|
||||
|
||||
|
||||
# Read from a stream ---------------------------------------------------
|
||||
|
||||
class AsynchronousFileReader(Process):
|
||||
"""
|
||||
Helper class to implement asynchronous reading of a file
|
||||
in a separate thread. Pushes read lines on a queue to
|
||||
be consumed in another thread.
|
||||
|
||||
Based on:
|
||||
http://stefaanlippens.net/python-asynchronous-subprocess-pipe-reading
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, fd, queue):
|
||||
assert hasattr(queue, 'put')
|
||||
assert hasattr(queue, 'empty')
|
||||
assert isinstance(fd, int) or callable(fd.readline)
|
||||
Process.__init__(self)
|
||||
self._fd = fd
|
||||
self._queue = queue
|
||||
|
||||
def run(self):
|
||||
"""The body of the tread: read lines and put them on the queue."""
|
||||
|
||||
# If self._fd is a file opened with open()...
|
||||
# Typically that's for stdout/stderr pipes
|
||||
# We can read the stuff easily with 'readline'
|
||||
if not isinstance(self._fd, int):
|
||||
for line in iter(self._fd.readline, ''):
|
||||
self._queue.put(line)
|
||||
|
||||
# Else, it got opened with os.open() and we have to read it
|
||||
# wit low level crap...
|
||||
else:
|
||||
data = ""
|
||||
while True:
|
||||
# Try to read (non-blockingly) a few bytes, append them to
|
||||
# the buffer
|
||||
data += os.read(self._fd, 50)
|
||||
|
||||
# If nobody's writing in there anymore, get out
|
||||
if not data and os.fstat(self._fd).st_nlink == 0:
|
||||
return
|
||||
|
||||
# If we have data, extract a line (ending with \n) and feed
|
||||
# it to the consumer
|
||||
if data and '\n' in data:
|
||||
lines = data.split('\n')
|
||||
self._queue.put(lines[0])
|
||||
data = '\n'.join(lines[1:])
|
||||
else:
|
||||
time.sleep(0.05)
|
||||
|
||||
def eof(self):
|
||||
"""Check whether there is no more content to expect."""
|
||||
return not self.is_alive() and self._queue.empty()
|
||||
|
||||
def join(self, timeout=None, close=True):
|
||||
"""Close the file and join the thread."""
|
||||
if close:
|
||||
self._queue.put(StopIteration)
|
||||
if isinstance(self._fd, int):
|
||||
os.close(self._fd)
|
||||
else:
|
||||
self._fd.close()
|
||||
Process.join(self, timeout)
|
||||
|
||||
|
||||
class Consummer(object):
|
||||
def __init__(self, queue, callback):
|
||||
self.queue = queue
|
||||
self.callback = callback
|
||||
|
||||
def empty(self):
|
||||
return self.queue.empty()
|
||||
|
||||
def process_next_line(self):
|
||||
if not self.empty():
|
||||
line = self.queue.get()
|
||||
if line:
|
||||
if line == StopIteration:
|
||||
return
|
||||
self.callback(line)
|
||||
|
||||
def process_current_queue(self):
|
||||
while not self.empty():
|
||||
line = self.queue.get()
|
||||
if line:
|
||||
if line == StopIteration:
|
||||
break
|
||||
self.callback(line)
|
||||
|
||||
|
||||
def async_file_reading(fd, callback):
|
||||
"""Helper which instantiate and run an AsynchronousFileReader."""
|
||||
queue = SimpleQueue()
|
||||
reader = AsynchronousFileReader(fd, queue)
|
||||
reader.start()
|
||||
consummer = Consummer(queue, callback)
|
||||
return (reader, consummer)
|
106
moulinette/utils/tests/conftest.py
Normal file
106
moulinette/utils/tests/conftest.py
Normal file
|
@ -0,0 +1,106 @@
|
|||
import sys
|
||||
import moulinette
|
||||
|
||||
sys.path.append("..")
|
||||
|
||||
###############################################################################
|
||||
# Tweak moulinette init to have yunohost namespace #
|
||||
###############################################################################
|
||||
|
||||
|
||||
old_init = moulinette.core.Moulinette18n.__init__
|
||||
|
||||
|
||||
def monkey_path_i18n_init(self, package, default_locale="en"):
|
||||
old_init(self, package, default_locale)
|
||||
self.load_namespace("moulinette")
|
||||
|
||||
|
||||
moulinette.core.Moulinette18n.__init__ = monkey_path_i18n_init
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Tweak translator to raise exceptions if string keys are not defined #
|
||||
###############################################################################
|
||||
|
||||
|
||||
old_translate = moulinette.core.Translator.translate
|
||||
|
||||
|
||||
def new_translate(self, key, *args, **kwargs):
|
||||
|
||||
if key not in self._translations[self.default_locale].keys():
|
||||
raise KeyError("Unable to retrieve key %s for default locale !" % key)
|
||||
|
||||
return old_translate(self, key, *args, **kwargs)
|
||||
|
||||
|
||||
moulinette.core.Translator.translate = new_translate
|
||||
|
||||
|
||||
def new_m18nn(self, key, *args, **kwargs):
|
||||
return self._global.translate(key, *args, **kwargs)
|
||||
|
||||
|
||||
moulinette.core.Moulinette18n.g = new_m18nn
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Init the moulinette to have the cli loggers stuff #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def pytest_cmdline_main(config):
|
||||
"""Configure logging and initialize the moulinette"""
|
||||
# Define loggers handlers
|
||||
handlers = set(['tty'])
|
||||
root_handlers = set(handlers)
|
||||
|
||||
# Define loggers level
|
||||
level = 'INFO'
|
||||
tty_level = 'SUCCESS'
|
||||
|
||||
# Custom logging configuration
|
||||
logging = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
'formatters': {
|
||||
'tty-debug': {
|
||||
'format': '%(relativeCreated)-4d %(fmessage)s'
|
||||
},
|
||||
'precise': {
|
||||
'format': '%(asctime)-15s %(levelname)-8s %(name)s %(funcName)s - %(fmessage)s'
|
||||
},
|
||||
},
|
||||
'filters': {
|
||||
'action': {
|
||||
'()': 'moulinette.utils.log.ActionFilter',
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'tty': {
|
||||
'level': tty_level,
|
||||
'class': 'moulinette.interfaces.cli.TTYHandler',
|
||||
'formatter': '',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'moulinette': {
|
||||
'level': level,
|
||||
'handlers': [],
|
||||
'propagate': True,
|
||||
},
|
||||
'moulinette.interface': {
|
||||
'level': level,
|
||||
'handlers': handlers,
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'level': level,
|
||||
'handlers': root_handlers,
|
||||
},
|
||||
}
|
||||
|
||||
# Initialize moulinette
|
||||
moulinette.init(logging_config=logging, _from_source=False)
|
295
moulinette/utils/tests/test_filesystem.py
Normal file
295
moulinette/utils/tests/test_filesystem.py
Normal file
|
@ -0,0 +1,295 @@
|
|||
|
||||
# General python lib
|
||||
import os
|
||||
import pwd
|
||||
import pytest
|
||||
|
||||
# Moulinette specific
|
||||
from moulinette.core import MoulinetteError
|
||||
from moulinette.utils.filesystem import (read_file, read_json,
|
||||
write_to_file, append_to_file,
|
||||
write_to_json,
|
||||
rm,
|
||||
chmod, chown)
|
||||
|
||||
# We define a dummy context with test folders and files
|
||||
|
||||
TEST_URL = "https://some.test.url/yolo.txt"
|
||||
TMP_TEST_DIR = "/tmp/test_iohelpers"
|
||||
TMP_TEST_FILE = "%s/foofile" % TMP_TEST_DIR
|
||||
TMP_TEST_JSON = "%s/barjson" % TMP_TEST_DIR
|
||||
NON_ROOT_USER = "admin"
|
||||
NON_ROOT_GROUP = "mail"
|
||||
|
||||
|
||||
def setup_function(function):
|
||||
|
||||
os.system("rm -rf %s" % TMP_TEST_DIR)
|
||||
os.system("mkdir %s" % TMP_TEST_DIR)
|
||||
os.system("echo 'foo\nbar' > %s" % TMP_TEST_FILE)
|
||||
os.system("echo '{ \"foo\":\"bar\" }' > %s" % TMP_TEST_JSON)
|
||||
os.system("chmod 700 %s" % TMP_TEST_FILE)
|
||||
os.system("chmod 700 %s" % TMP_TEST_JSON)
|
||||
|
||||
|
||||
def teardown_function(function):
|
||||
|
||||
os.seteuid(0)
|
||||
os.system("rm -rf /tmp/test_iohelpers/")
|
||||
|
||||
|
||||
# Helper to try stuff as non-root
|
||||
def switch_to_non_root_user():
|
||||
|
||||
nonrootuser = pwd.getpwnam(NON_ROOT_USER).pw_uid
|
||||
os.seteuid(nonrootuser)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Test file read #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def test_read_file():
|
||||
|
||||
content = read_file(TMP_TEST_FILE)
|
||||
assert content == "foo\nbar\n"
|
||||
|
||||
|
||||
def test_read_file_badfile():
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
read_file(TMP_TEST_FILE + "nope")
|
||||
|
||||
|
||||
def test_read_file_badpermissions():
|
||||
|
||||
switch_to_non_root_user()
|
||||
with pytest.raises(MoulinetteError):
|
||||
read_file(TMP_TEST_FILE)
|
||||
|
||||
|
||||
def test_read_json():
|
||||
|
||||
content = read_json(TMP_TEST_JSON)
|
||||
assert "foo" in content.keys()
|
||||
assert content["foo"] == "bar"
|
||||
|
||||
|
||||
def test_read_json_badjson():
|
||||
|
||||
os.system("echo '{ not valid json lol }' > %s" % TMP_TEST_JSON)
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
read_json(TMP_TEST_JSON)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Test file write #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def test_write_to_existing_file():
|
||||
|
||||
assert os.path.exists(TMP_TEST_FILE)
|
||||
write_to_file(TMP_TEST_FILE, "yolo\nswag")
|
||||
assert read_file(TMP_TEST_FILE) == "yolo\nswag"
|
||||
|
||||
|
||||
def test_write_to_new_file():
|
||||
|
||||
new_file = "%s/barfile" % TMP_TEST_DIR
|
||||
assert not os.path.exists(new_file)
|
||||
write_to_file(new_file, "yolo\nswag")
|
||||
assert os.path.exists(new_file)
|
||||
assert read_file(new_file) == "yolo\nswag"
|
||||
|
||||
|
||||
def test_write_to_existing_file_badpermissions():
|
||||
|
||||
assert os.path.exists(TMP_TEST_FILE)
|
||||
switch_to_non_root_user()
|
||||
with pytest.raises(MoulinetteError):
|
||||
write_to_file(TMP_TEST_FILE, "yolo\nswag")
|
||||
|
||||
|
||||
def test_write_to_new_file_badpermissions():
|
||||
|
||||
switch_to_non_root_user()
|
||||
new_file = "%s/barfile" % TMP_TEST_DIR
|
||||
assert not os.path.exists(new_file)
|
||||
with pytest.raises(MoulinetteError):
|
||||
write_to_file(new_file, "yolo\nswag")
|
||||
|
||||
|
||||
def test_write_to_folder():
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
write_to_file(TMP_TEST_DIR, "yolo\nswag")
|
||||
|
||||
|
||||
def test_write_inside_nonexistent_folder():
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
write_to_file("/toto/test", "yolo\nswag")
|
||||
|
||||
|
||||
def test_write_to_file_with_a_list():
|
||||
|
||||
assert os.path.exists(TMP_TEST_FILE)
|
||||
write_to_file(TMP_TEST_FILE, ["yolo", "swag"])
|
||||
assert read_file(TMP_TEST_FILE) == "yolo\nswag"
|
||||
|
||||
|
||||
def test_append_to_existing_file():
|
||||
|
||||
assert os.path.exists(TMP_TEST_FILE)
|
||||
append_to_file(TMP_TEST_FILE, "yolo\nswag")
|
||||
assert read_file(TMP_TEST_FILE) == "foo\nbar\nyolo\nswag"
|
||||
|
||||
|
||||
def test_append_to_new_file():
|
||||
|
||||
new_file = "%s/barfile" % TMP_TEST_DIR
|
||||
assert not os.path.exists(new_file)
|
||||
append_to_file(new_file, "yolo\nswag")
|
||||
assert os.path.exists(new_file)
|
||||
assert read_file(new_file) == "yolo\nswag"
|
||||
|
||||
|
||||
def text_write_dict_to_json():
|
||||
|
||||
dummy_dict = {"foo": 42, "bar": ["a", "b", "c"]}
|
||||
write_to_json(TMP_TEST_FILE, dummy_dict)
|
||||
j = read_json(TMP_TEST_FILE)
|
||||
assert "foo" in j.keys()
|
||||
assert "bar" in j.keys()
|
||||
assert j["foo"] == 42
|
||||
assert j["bar"] == ["a", "b", "c"]
|
||||
assert read_file(TMP_TEST_FILE) == "foo\nbar\nyolo\nswag"
|
||||
|
||||
|
||||
def text_write_list_to_json():
|
||||
|
||||
dummy_list = ["foo", "bar", "baz"]
|
||||
write_to_json(TMP_TEST_FILE, dummy_list)
|
||||
j = read_json(TMP_TEST_FILE)
|
||||
assert j == ["foo", "bar", "baz"]
|
||||
|
||||
|
||||
def test_write_to_json_badpermissions():
|
||||
|
||||
switch_to_non_root_user()
|
||||
dummy_dict = {"foo": 42, "bar": ["a", "b", "c"]}
|
||||
with pytest.raises(MoulinetteError):
|
||||
write_to_json(TMP_TEST_FILE, dummy_dict)
|
||||
|
||||
|
||||
def test_write_json_inside_nonexistent_folder():
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
write_to_file("/toto/test.json", ["a", "b"])
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Test file remove #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def test_remove_file():
|
||||
|
||||
rm(TMP_TEST_FILE)
|
||||
assert not os.path.exists(TMP_TEST_FILE)
|
||||
|
||||
|
||||
def test_remove_file_badpermissions():
|
||||
|
||||
switch_to_non_root_user()
|
||||
with pytest.raises(MoulinetteError):
|
||||
rm(TMP_TEST_FILE)
|
||||
|
||||
|
||||
def test_remove_directory():
|
||||
|
||||
rm(TMP_TEST_DIR, recursive=True)
|
||||
assert not os.path.exists(TMP_TEST_DIR)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Test permission change #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def get_permissions(file_path):
|
||||
from stat import ST_MODE
|
||||
return (pwd.getpwuid(os.stat(file_path).st_uid).pw_name,
|
||||
pwd.getpwuid(os.stat(file_path).st_gid).pw_name,
|
||||
oct(os.stat(file_path)[ST_MODE])[-3:])
|
||||
|
||||
|
||||
# FIXME - should split the test of chown / chmod as independent tests
|
||||
def set_permissions(f, owner, group, perms):
|
||||
chown(f, owner, group)
|
||||
chmod(f, perms)
|
||||
|
||||
|
||||
def test_setpermissions_file():
|
||||
|
||||
# Check we're at the default permissions
|
||||
assert get_permissions(TMP_TEST_FILE) == ("root", "root", "700")
|
||||
|
||||
# Change the permissions
|
||||
set_permissions(TMP_TEST_FILE, NON_ROOT_USER, NON_ROOT_GROUP, 0111)
|
||||
|
||||
# Check the permissions got changed
|
||||
assert get_permissions(TMP_TEST_FILE) == (NON_ROOT_USER, NON_ROOT_GROUP, "111")
|
||||
|
||||
# Change the permissions again
|
||||
set_permissions(TMP_TEST_FILE, "root", "root", 0777)
|
||||
|
||||
# Check the permissions got changed
|
||||
assert get_permissions(TMP_TEST_FILE) == ("root", "root", "777")
|
||||
|
||||
|
||||
def test_setpermissions_directory():
|
||||
|
||||
# Check we're at the default permissions
|
||||
assert get_permissions(TMP_TEST_DIR) == ("root", "root", "755")
|
||||
|
||||
# Change the permissions
|
||||
set_permissions(TMP_TEST_DIR, NON_ROOT_USER, NON_ROOT_GROUP, 0111)
|
||||
|
||||
# Check the permissions got changed
|
||||
assert get_permissions(TMP_TEST_DIR) == (NON_ROOT_USER, NON_ROOT_GROUP, "111")
|
||||
|
||||
# Change the permissions again
|
||||
set_permissions(TMP_TEST_DIR, "root", "root", 0777)
|
||||
|
||||
# Check the permissions got changed
|
||||
assert get_permissions(TMP_TEST_DIR) == ("root", "root", "777")
|
||||
|
||||
|
||||
def test_setpermissions_permissiondenied():
|
||||
|
||||
switch_to_non_root_user()
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
set_permissions(TMP_TEST_FILE, NON_ROOT_USER, NON_ROOT_GROUP, 0111)
|
||||
|
||||
|
||||
def test_setpermissions_badfile():
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
set_permissions("/foo/bar/yolo", NON_ROOT_USER, NON_ROOT_GROUP, 0111)
|
||||
|
||||
|
||||
def test_setpermissions_baduser():
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
set_permissions(TMP_TEST_FILE, "foo", NON_ROOT_GROUP, 0111)
|
||||
|
||||
|
||||
def test_setpermissions_badgroup():
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
set_permissions(TMP_TEST_FILE, NON_ROOT_USER, "foo", 0111)
|
90
moulinette/utils/tests/test_network.py
Normal file
90
moulinette/utils/tests/test_network.py
Normal file
|
@ -0,0 +1,90 @@
|
|||
|
||||
# General python lib
|
||||
import pytest
|
||||
import requests
|
||||
import requests_mock
|
||||
|
||||
# Moulinette specific
|
||||
from moulinette.core import MoulinetteError
|
||||
from moulinette.utils.network import download_text, download_json
|
||||
|
||||
# We define a dummy context with test folders and files
|
||||
|
||||
TEST_URL = "https://some.test.url/yolo.txt"
|
||||
|
||||
|
||||
def setup_function(function):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def teardown_function(function):
|
||||
|
||||
pass
|
||||
|
||||
###############################################################################
|
||||
# Test download #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def test_download():
|
||||
|
||||
with requests_mock.Mocker() as m:
|
||||
m.register_uri("GET", TEST_URL, text='some text')
|
||||
|
||||
fetched_text = download_text(TEST_URL)
|
||||
|
||||
assert fetched_text == "some text"
|
||||
|
||||
|
||||
def test_download_badurl():
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
download_text(TEST_URL)
|
||||
|
||||
|
||||
def test_download_404():
|
||||
|
||||
with requests_mock.Mocker() as m:
|
||||
m.register_uri("GET", TEST_URL, status_code=404)
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
download_text(TEST_URL)
|
||||
|
||||
|
||||
def test_download_sslerror():
|
||||
|
||||
with requests_mock.Mocker() as m:
|
||||
m.register_uri("GET", TEST_URL, exc=requests.exceptions.SSLError)
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
download_text(TEST_URL)
|
||||
|
||||
|
||||
def test_download_timeout():
|
||||
|
||||
with requests_mock.Mocker() as m:
|
||||
m.register_uri("GET", TEST_URL, exc=requests.exceptions.ConnectTimeout)
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
download_text(TEST_URL)
|
||||
|
||||
|
||||
def test_download_json():
|
||||
|
||||
with requests_mock.Mocker() as m:
|
||||
m.register_uri("GET", TEST_URL, text='{ "foo":"bar" }')
|
||||
|
||||
fetched_json = download_json(TEST_URL)
|
||||
|
||||
assert "foo" in fetched_json.keys()
|
||||
assert fetched_json["foo"] == "bar"
|
||||
|
||||
|
||||
def test_download_json_badjson():
|
||||
|
||||
with requests_mock.Mocker() as m:
|
||||
m.register_uri("GET", TEST_URL, text='{ not json lol }')
|
||||
|
||||
with pytest.raises(MoulinetteError):
|
||||
download_json(TEST_URL)
|
66
moulinette/utils/tests/test_process.py
Normal file
66
moulinette/utils/tests/test_process.py
Normal file
|
@ -0,0 +1,66 @@
|
|||
# General python lib
|
||||
import os
|
||||
import pwd
|
||||
import pytest
|
||||
|
||||
# Moulinette specific
|
||||
from subprocess import CalledProcessError
|
||||
from moulinette.utils.process import run_commands
|
||||
|
||||
# We define a dummy context with test folders and files
|
||||
|
||||
TMP_TEST_DIR = "/tmp/test_iohelpers"
|
||||
TMP_TEST_FILE = "%s/foofile" % TMP_TEST_DIR
|
||||
NON_ROOT_USER = "admin"
|
||||
NON_ROOT_GROUP = "mail"
|
||||
|
||||
|
||||
def setup_function(function):
|
||||
|
||||
os.system("rm -rf %s" % TMP_TEST_DIR)
|
||||
os.system("mkdir %s" % TMP_TEST_DIR)
|
||||
os.system("echo 'foo\nbar' > %s" % TMP_TEST_FILE)
|
||||
os.system("chmod 700 %s" % TMP_TEST_FILE)
|
||||
|
||||
|
||||
def teardown_function(function):
|
||||
|
||||
os.seteuid(0)
|
||||
os.system("rm -rf /tmp/test_iohelpers/")
|
||||
|
||||
|
||||
# Helper to try stuff as non-root
|
||||
def switch_to_non_root_user():
|
||||
|
||||
nonrootuser = pwd.getpwnam(NON_ROOT_USER).pw_uid
|
||||
os.seteuid(nonrootuser)
|
||||
|
||||
###############################################################################
|
||||
# Test run shell commands #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def test_run_shell_command_list():
|
||||
|
||||
commands = ["rm -f %s" % TMP_TEST_FILE]
|
||||
|
||||
assert os.path.exists(TMP_TEST_FILE)
|
||||
run_commands(commands)
|
||||
assert not os.path.exists(TMP_TEST_FILE)
|
||||
|
||||
|
||||
def test_run_shell_badcommand():
|
||||
|
||||
commands = ["yolo swag"]
|
||||
|
||||
with pytest.raises(CalledProcessError):
|
||||
run_commands(commands)
|
||||
|
||||
|
||||
def test_run_shell_command_badpermissions():
|
||||
|
||||
commands = ["rm -f %s" % TMP_TEST_FILE]
|
||||
|
||||
switch_to_non_root_user()
|
||||
with pytest.raises(CalledProcessError):
|
||||
run_commands(commands)
|
|
@ -3,14 +3,14 @@ import re
|
|||
import mmap
|
||||
import binascii
|
||||
|
||||
# Pattern searching ----------------------------------------------------
|
||||
|
||||
# Pattern searching ----------------------------------------------------
|
||||
|
||||
def search(pattern, text, count=0, flags=0):
|
||||
"""Search for pattern in a text
|
||||
|
||||
Scan through text looking for all locations where the regular
|
||||
expression pattern matches, and return them as a list of strings.
|
||||
expresion pattern matches, and return them as a list of strings.
|
||||
|
||||
The optional argument count is the maximum number of pattern
|
||||
occurences to return; count must be an integer. If omitted or zero,
|
||||
|
@ -46,25 +46,23 @@ def searchf(pattern, path, count=0, flags=re.MULTILINE):
|
|||
content by using the search function.
|
||||
|
||||
"""
|
||||
with open(path, "rb+") as f:
|
||||
with open(path, 'r+') as f:
|
||||
data = mmap.mmap(f.fileno(), 0)
|
||||
match = search(pattern, data.read().decode(), count, flags)
|
||||
match = search(pattern, data, count, flags)
|
||||
data.close()
|
||||
return match
|
||||
|
||||
|
||||
# Text formatting ------------------------------------------------------
|
||||
|
||||
|
||||
def prependlines(text, prepend):
|
||||
"""Prepend a string to each line of a text"""
|
||||
lines = text.splitlines(True)
|
||||
return "{}{}".format(prepend, prepend.join(lines))
|
||||
return "%s%s" % (prepend, prepend.join(lines))
|
||||
|
||||
|
||||
# Randomize ------------------------------------------------------------
|
||||
|
||||
|
||||
def random_ascii(length=40):
|
||||
def random_ascii(length=20):
|
||||
"""Return a random ascii string"""
|
||||
return binascii.hexlify(os.urandom(length)).decode("ascii")[:length]
|
||||
return binascii.hexlify(os.urandom(length)).decode('ascii')
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[pytest]
|
||||
addopts = --cov=moulinette -s -v --no-cov-on-fail
|
||||
norecursedirs = dist doc build .tox .eggs
|
||||
testpaths = test/
|
||||
env =
|
||||
TESTS_RUN = True
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue