diff --git a/generate_function_doc.py b/generate_function_doc.py index 1bd17a04..66b63d8c 100755 --- a/generate_function_doc.py +++ b/generate_function_doc.py @@ -106,7 +106,7 @@ def main(): else: f.write(line) - if re.search(r'^def '+ category +'_'+ action +'(', line): + if re.search(r'^def '+ category +'_'+ action +'\(', line): in_block = True diff --git a/yunohost_app.py b/yunohost_app.py index cb3466c1..1576632e 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -20,6 +20,8 @@ """ """ yunohost_app.py + + Manage apps """ import os import sys @@ -45,8 +47,6 @@ def app_listlists(): """ List fetched lists - Returns: - Dict of lists """ list_list = [] @@ -62,14 +62,11 @@ def app_listlists(): def app_fetchlist(url=None, name=None): """ - Fetch application list + Fetch application list from app server - Keyword arguments: - url -- Custom list URL - name -- Name of the app list - - Returns: - True | YunoHostError + Keyword argument: + url -- URL of remote JSON list (default http://fapp.yunohost.org/app/list/raw) + name -- Name of the list (default fapp) """ # Create app path if not exists @@ -90,9 +87,9 @@ def app_fetchlist(url=None, name=None): def app_removelist(name): """ - Remove specified application list + Remove list from the repositories - Keyword arguments: + Keyword argument: name -- Name of the list to remove """ @@ -106,16 +103,13 @@ def app_removelist(name): def app_list(offset=None, limit=None, filter=None, raw=False): """ - List available applications + List apps - Keyword arguments: - offset -- App to begin with - limit -- Number of apps to list - filter -- Name filter + Keyword argument: raw -- Return the full app_dict - - Returns: - Dict of apps + limit -- Maximum number of app fetched + offset -- Starting number for app fetching + filter -- Name filter of app_id or app_name """ # TODO: List installed applications @@ -168,15 +162,12 @@ def app_list(offset=None, limit=None, filter=None, raw=False): def app_info(app, instance=None, raw=False): """ - Fetch informations for selected apps + Get app informations - Keyword arguments: - app -- App ID - instance -- Specific number of instance to get info from + Keyword argument: + instance -- App instance number raw -- Return the full app_dict - - Returns: - Dict | Fail + app -- App ID """ try: @@ -206,14 +197,12 @@ def app_info(app, instance=None, raw=False): def app_map(app=None, raw=False): """ - Map of installed apps + List apps by domain - Keyword arguments: - app -- App ID of app to map + Keyword argument: + app -- Specific app to map raw -- Return complete dict - Returns: - Dict """ result = {} @@ -241,17 +230,14 @@ def app_map(app=None, raw=False): def app_upgrade(app, instance=[], url=None, file=None): """ - Upgrade selected apps + Upgrade app - Keyword arguments: - app -- List of app_id to upgrade (default all upgradable app) - instance -- Specific number(s) of instance(s) to upgrade - url -- Git url to fetch before upgrade + Keyword argument: + instance -- App instance number to upgrade + url -- Git url to fetch for upgrade + app -- App(s) to upgrade (default all) file -- Folder or tarball for upgrade - Returns: - Win | Fail - """ with YunoHostLDAP() as yldap: try: @@ -388,17 +374,14 @@ def app_upgrade(app, instance=[], url=None, file=None): def app_install(app, domain, path='/', label=None, mode='private'): """ - Install selected app + Install apps - Keyword arguments: - app -- AppID to install (or filename) - domain -- Web domain for the app - path -- Subpath of the domain - label -- User defined name for the app - mode -- public|private|protected - - Returns: - Win | Fail + Keyword argument: + path + mode -- level of privacy of the app (public|protected|private) + domain + app -- App to install + label """ # TODO: Virer la règle "default" lemon @@ -612,11 +595,11 @@ def app_install(app, domain, path='/', label=None, mode='private'): def app_remove(app, instance=[]): """ - Remove app(s) + Remove app - Keyword arguments: - app -- App ID to remove - instance -- List of instances to remove (default all) + Keyword argument: + instance -- App instance number to delete + app -- App(s) to delete """ lemon_conf_lines = {} @@ -676,11 +659,11 @@ def app_remove(app, instance=[]): def app_addaccess(apps, users): """ - Grant access to a private app to a user + Grant access right to users (everyone by default) - Keyword arguments: - apps -- List of app to grant access to - users -- Users to grant access for + Keyword argument: + apps + users """ if not isinstance(users, list): users = [users] @@ -725,11 +708,11 @@ def app_addaccess(apps, users): def app_removeaccess(apps, users): """ - Revoke access to a private app to a user + Revoke access right to users (everyone by default) - Keyword arguments: - apps -- List of app to revoke access to - users -- Users to revoke access for + Keyword argument: + apps + users """ if not isinstance(users, list): users = [users] diff --git a/yunohost_backup.py b/yunohost_backup.py index 91a20747..7efa20b6 100644 --- a/yunohost_backup.py +++ b/yunohost_backup.py @@ -20,6 +20,8 @@ """ """ yunohost_backup.py + + Manage backups """ import os import sys @@ -32,11 +34,8 @@ def backup_init(helper=False): """ Init Tahoe-LAFS configuration - Keyword arguments: - helper -- Create a helper node rather than a "helped" one - - Returns: - Win | Fail + Keyword argument: + helper -- Init as a helper node rather than a "helped" one """ pass diff --git a/yunohost_domain.py b/yunohost_domain.py index 171e24e5..3a259993 100644 --- a/yunohost_domain.py +++ b/yunohost_domain.py @@ -20,6 +20,8 @@ """ """ yunohost_domain.py + + Manage domains """ import os import sys @@ -35,15 +37,13 @@ lemon_tmp_conf = '/tmp/tmplemonconf' def domain_list(filter=None, limit=None, offset=None): """ - List YunoHost domains + List domains Keyword argument: - filter -- LDAP filter to search with - limit - offset + limit -- Maximum number of domain fetched + offset -- Starting number for domain fetching + filter -- LDAP filter used to search - Returns: - Dict """ with YunoHostLDAP() as yldap: result_list = [] @@ -69,15 +69,12 @@ def domain_list(filter=None, limit=None, offset=None): def domain_add(domains, raw=False, main=False): """ - Add one or more domains + Create a custom domain Keyword argument: - domains -- List of domains to add - raw -- Do not configure Apache and LemonLDAP for the domain too - main -- Is the main domain + raw -- Auto-configure Apache and LemonLDAP for the domain + domains -- Domain name to add - Returns: - Dict """ with YunoHostLDAP() as yldap: attr_dict = { 'objectClass' : ['mailDomain', 'top'] } @@ -225,13 +222,11 @@ def domain_add(domains, raw=False, main=False): def domain_remove(domains): """ - Remove domain from LDAP + Delete domains Keyword argument: - domains -- List of domains to remove + domains -- Domain(s) to delete - Returns: - Dict """ with YunoHostLDAP() as yldap: result = [] diff --git a/yunohost_dyndns.py b/yunohost_dyndns.py index 306b3c5c..902227fe 100644 --- a/yunohost_dyndns.py +++ b/yunohost_dyndns.py @@ -20,6 +20,8 @@ """ """ yunohost_dyndns.py + + Subscribe and Update DynDNS Hosts """ import os import sys @@ -32,13 +34,10 @@ def dyndns_subscribe(subscribe_host="dyndns.yunohost.org", domain=None, key=None """ Subscribe to a DynDNS service - Keyword arguments: + Keyword argument: + key -- Public DNS key subscribe_host -- Dynette HTTP API to subscribe to - domain -- Full domain to subscribe with - key -- Public DNS key - - Returns: - Win | Fail + domain -- Full domain to subscribe with """ if domain is None: @@ -72,16 +71,13 @@ def dyndns_subscribe(subscribe_host="dyndns.yunohost.org", domain=None, key=None def dyndns_update(dyn_host="dynhost.yunohost.org", domain=None, key=None, ip=None): """ - Update IP on DNS platform + Update IP on DynDNS platform - Keyword arguments: + Keyword argument: dyn_host -- Dynette DNS server to inform - domain -- Full domain to update - key -- Public DNS key - ip -- IP to send - - Returns: - Win | Fail + ip -- IP address to send + key -- Public DNS key + domain -- Full domain to subscribe with """ if domain is None: @@ -145,8 +141,6 @@ def dyndns_installcron(): """ Install IP update cron - Returns: - Win """ os.system("touch /etc/cron.d/yunohost-dyndns") @@ -158,8 +152,6 @@ def dyndns_removecron(): """ Remove IP update cron - Returns: - Win | Fail """ try: diff --git a/yunohost_firewall.py b/yunohost_firewall.py index 25072d79..705ad27a 100644 --- a/yunohost_firewall.py +++ b/yunohost_firewall.py @@ -20,6 +20,8 @@ """ """ yunohost_firewall.py + + Manage firewall rules """ import os import sys @@ -40,16 +42,13 @@ from yunohost import YunoHostError, win_msg def firewall_allow(protocol=None, port=None, ipv6=None, upnp=False): """ - Allow port in iptables + Allow connection port/protocol - Keyword arguments: - protocol -- Protocol used + Keyword argument: + protocol -- Protocol associated with port + ipv6 -- ipv6 + upnp -- upnp port -- Port to open - ipv6 -- Boolean ipv6 - upnp -- Boolean upnp - - Return - Dict """ port = int(port) @@ -74,16 +73,13 @@ def firewall_allow(protocol=None, port=None, ipv6=None, upnp=False): def firewall_disallow(protocol=None, port=None, ipv6=None, upnp=False): """ - Disallow port in iptables + Disallow connection - Keyword arguments: - protocol -- Protocol used + Keyword argument: + protocol -- Protocol associated with port + ipv6 -- ipv6 + upnp -- upnp port -- Port to open - ipv6 -- Boolean ipv6 - upnp -- Boolan upnp - - Return - Dict """ @@ -100,13 +96,8 @@ def firewall_disallow(protocol=None, port=None, ipv6=None, upnp=False): def firewall_list(): """ - Allow port in iptables + List all firewall rules - Keyword arguments: - None - - Return - Dict """ with open ('firewall.yml') as f: @@ -115,13 +106,11 @@ def firewall_list(): def firewall_reload(upnp=False): """ - Reload iptables configuration + Reload all firewall rules - Keyword arguments: - upnp -- Boolean upnp + Keyword argument: + upnp -- upnp - Return - Dict """ with open('firewall.yml', 'r') as f: firewall = yaml.load(f) @@ -279,10 +268,8 @@ def remove_portmapping(): def firewall_installupnp(): """ Add upnp cron - Keyword arguments: - None - Return - None + + """ with open('firewall.yml', 'r') as f: @@ -303,10 +290,8 @@ def firewall_installupnp(): def firewall_removeupnp(): """ Remove upnp cron - Keyword arguments: - None - Return - None + + """ with open('firewall.yml', 'r') as f: firewall = yaml.load(f) @@ -327,12 +312,9 @@ def firewall_removeupnp(): def firewall_checkupnp(): """ - Check if UPNP is installed - Keyword arguments: - None - Return - 0 if installed - 1 if not + check if UPNP is install or not (0 yes 1 no) + + """ with open('firewall.yml', 'r') as f: firewall = yaml.load(f) @@ -344,11 +326,9 @@ def firewall_checkupnp(): def firewall_stop(): """ - Stop firewall - Keyword arguments: - None - Return - None + Stop iptables and ip6tables + + """ os.system ("iptables -P INPUT ACCEPT") diff --git a/yunohost_monitor.py b/yunohost_monitor.py index a6f38152..2d53c7f9 100644 --- a/yunohost_monitor.py +++ b/yunohost_monitor.py @@ -20,6 +20,8 @@ """ """ yunohost_monitor.py + + Monitoring functions """ import xmlrpclib import json @@ -86,6 +88,16 @@ def process_check(args): def monitor_info(memory=False, cpu=False, disk=False, ifconfig=False, uptime=False, public=False): """ + Check System + + Keyword argument: + public -- Show IP public + cpu -- Check CPU + uptime -- Show Uptime + disk -- Check Disk + ifconfig -- Show Ip and MAC Adress + memory -- Check Memory + """ if memory: return json.loads(s.getMem()) @@ -126,15 +138,3 @@ def monitor_info(memory=False, cpu=False, disk=False, ifconfig=False, uptime=Fal raise YunoHostError(1, _('No arguments provided')) def monitor_process(enable=None, disable=None, start=None, stop=None, check=None, info=False): - if enable: - return process_enable(enable) - elif disable: - return process_disable(disable) - elif start: - return process_start(start) - elif stop: - return process_stop(stop) - elif check: - return process_check(check) - elif info: - return json.loads(s.getProcessCount()) diff --git a/yunohost_tools.py b/yunohost_tools.py index 436fc615..34f77bb6 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -20,6 +20,8 @@ """ """ yunohost_tools.py + + Specific tools """ import os import sys @@ -32,10 +34,8 @@ from yunohost_dyndns import dyndns_subscribe def tools_ldapinit(): """ - Initialize YunoHost LDAP scheme + YunoHost LDAP initialization - Returns: - dict """ with YunoHostLDAP() as yldap: @@ -69,13 +69,10 @@ def tools_adminpw(old_password, new_password): """ Change admin password - Keyword arguments: + Keyword argument: old_password new_password - Returns: - dict - """ # Validate password length if len(new_password) < 4: @@ -91,15 +88,12 @@ def tools_adminpw(old_password, new_password): def tools_maindomain(old_domain, new_domain): """ - Change admin password + Main domain change tool - Keyword arguments: + Keyword argument: old_domain new_domain - Returns: - dict - """ if not old_domain: @@ -179,14 +173,12 @@ def tools_maindomain(old_domain, new_domain): def tools_postinstall(domain, password, dyndns=False): """ - Post-install configuration + YunoHost post-install - Keyword arguments: - domain -- Main domain - password -- New admin password - - Returns: - dict + Keyword argument: + password -- YunoHost admin password + dyndns -- Subscribe domain to a DynDNS service + domain -- YunoHost main domain """ with YunoHostLDAP(password='yunohost') as yldap: diff --git a/yunohost_user.py b/yunohost_user.py index fb438e70..63c4e65b 100644 --- a/yunohost_user.py +++ b/yunohost_user.py @@ -20,6 +20,8 @@ """ """ yunohost_user.py + + Manage users """ import os import sys @@ -33,16 +35,14 @@ from yunohost_domain import domain_list def user_list(fields=None, filter=None, limit=None, offset=None): """ - List YunoHost users from LDAP + List users Keyword argument: - fields -- Fields to fetch - filter -- LDAP filter to use - limit -- Number of user to fetch - offset -- User number to begin with + fields -- fields to fetch + limit -- Maximum number of user fetched + offset -- Starting number for user fetching + filter -- LDAP filter used to search - Returns: - Dict """ with YunoHostLDAP() as yldap: user_attrs = ['uid', 'mail', 'cn', 'maildrop'] @@ -89,16 +89,15 @@ def user_list(fields=None, filter=None, limit=None, offset=None): def user_create(username, firstname, lastname, mail, password): """ - Add user to LDAP + Create user Keyword argument: - username - firstname - lastname password + firstname + mail -- Main mail address must be unique + lastname + username -- Must be unique - Returns: - Dict """ with YunoHostLDAP() as yldap: # Validate password length @@ -159,14 +158,12 @@ def user_create(username, firstname, lastname, mail, password): def user_delete(users, purge=None): """ - Remove user from LDAP + Delete user Keyword argument: - users -- List of users to delete or single user - purge -- Whether or not purge /home/user directory + users -- Username of users to delete + purge - Returns: - Dict """ with YunoHostLDAP() as yldap: result = { 'Users' : [] } @@ -188,24 +185,20 @@ def user_delete(users, purge=None): def user_update(username, firstname=None, lastname=None, mail=None, change_password=None, - add_mailforward=None, remove_mailforward=None, - add_mailalias=None, remove_mailalias=None): """ Update user informations Keyword argument: - username -- Username to update + remove_mailalias -- Mail aliases to remove + change_password -- New password to set + username -- Username of user to update + remove_mailforward -- Mailforward addresses to remove + add_mailforward -- Mailforward addresses to add firstname - lastname + add_mailalias -- Mail aliases to add mail - change_password -- New password - add_mailforward - remove_mailforward - add_mailalias - remove_mailalias + lastname - Returns: - Dict """ with YunoHostLDAP() as yldap: attrs_to_fetch = ['givenName', 'sn', 'mail', 'maildrop'] @@ -292,13 +285,11 @@ def user_update(username, firstname=None, lastname=None, mail=None, change_passw def user_info(username): """ - Fetch user informations from LDAP + Get user informations Keyword argument: - username -- Username or mail to get info + username -- Username or mail to get informations - Returns: - Dict """ with YunoHostLDAP() as yldap: user_attrs = ['cn', 'mail', 'uid', 'maildrop']