Regenerate function doc

This commit is contained in:
Kload 2013-07-06 10:17:16 +02:00
parent c9179d33c7
commit ce93c9dfc8
9 changed files with 143 additions and 211 deletions

View file

@ -106,7 +106,7 @@ def main():
else: else:
f.write(line) f.write(line)
if re.search(r'^def '+ category +'_'+ action +'(', line): if re.search(r'^def '+ category +'_'+ action +'\(', line):
in_block = True in_block = True

View file

@ -20,6 +20,8 @@
""" """
""" yunohost_app.py """ yunohost_app.py
Manage apps
""" """
import os import os
import sys import sys
@ -45,8 +47,6 @@ def app_listlists():
""" """
List fetched lists List fetched lists
Returns:
Dict of lists
""" """
list_list = [] list_list = []
@ -62,14 +62,11 @@ def app_listlists():
def app_fetchlist(url=None, name=None): def app_fetchlist(url=None, name=None):
""" """
Fetch application list Fetch application list from app server
Keyword arguments: Keyword argument:
url -- Custom list URL url -- URL of remote JSON list (default http://fapp.yunohost.org/app/list/raw)
name -- Name of the app list name -- Name of the list (default fapp)
Returns:
True | YunoHostError
""" """
# Create app path if not exists # Create app path if not exists
@ -90,9 +87,9 @@ def app_fetchlist(url=None, name=None):
def app_removelist(name): def app_removelist(name):
""" """
Remove specified application list Remove list from the repositories
Keyword arguments: Keyword argument:
name -- Name of the list to remove 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): def app_list(offset=None, limit=None, filter=None, raw=False):
""" """
List available applications List apps
Keyword arguments: Keyword argument:
offset -- App to begin with
limit -- Number of apps to list
filter -- Name filter
raw -- Return the full app_dict raw -- Return the full app_dict
limit -- Maximum number of app fetched
Returns: offset -- Starting number for app fetching
Dict of apps filter -- Name filter of app_id or app_name
""" """
# TODO: List installed applications # 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): def app_info(app, instance=None, raw=False):
""" """
Fetch informations for selected apps Get app informations
Keyword arguments: Keyword argument:
app -- App ID instance -- App instance number
instance -- Specific number of instance to get info from
raw -- Return the full app_dict raw -- Return the full app_dict
app -- App ID
Returns:
Dict | Fail
""" """
try: try:
@ -206,14 +197,12 @@ def app_info(app, instance=None, raw=False):
def app_map(app=None, raw=False): def app_map(app=None, raw=False):
""" """
Map of installed apps List apps by domain
Keyword arguments: Keyword argument:
app -- App ID of app to map app -- Specific app to map
raw -- Return complete dict raw -- Return complete dict
Returns:
Dict
""" """
result = {} result = {}
@ -241,17 +230,14 @@ def app_map(app=None, raw=False):
def app_upgrade(app, instance=[], url=None, file=None): def app_upgrade(app, instance=[], url=None, file=None):
""" """
Upgrade selected apps Upgrade app
Keyword arguments: Keyword argument:
app -- List of app_id to upgrade (default all upgradable app) instance -- App instance number to upgrade
instance -- Specific number(s) of instance(s) to upgrade url -- Git url to fetch for upgrade
url -- Git url to fetch before upgrade app -- App(s) to upgrade (default all)
file -- Folder or tarball for upgrade file -- Folder or tarball for upgrade
Returns:
Win | Fail
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
try: try:
@ -388,17 +374,14 @@ def app_upgrade(app, instance=[], url=None, file=None):
def app_install(app, domain, path='/', label=None, mode='private'): def app_install(app, domain, path='/', label=None, mode='private'):
""" """
Install selected app Install apps
Keyword arguments: Keyword argument:
app -- AppID to install (or filename) path
domain -- Web domain for the app mode -- level of privacy of the app (public|protected|private)
path -- Subpath of the domain domain
label -- User defined name for the app app -- App to install
mode -- public|private|protected label
Returns:
Win | Fail
""" """
# TODO: Virer la règle "default" lemon # 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=[]): def app_remove(app, instance=[]):
""" """
Remove app(s) Remove app
Keyword arguments: Keyword argument:
app -- App ID to remove instance -- App instance number to delete
instance -- List of instances to remove (default all) app -- App(s) to delete
""" """
lemon_conf_lines = {} lemon_conf_lines = {}
@ -676,11 +659,11 @@ def app_remove(app, instance=[]):
def app_addaccess(apps, users): def app_addaccess(apps, users):
""" """
Grant access to a private app to a user Grant access right to users (everyone by default)
Keyword arguments: Keyword argument:
apps -- List of app to grant access to apps
users -- Users to grant access for users
""" """
if not isinstance(users, list): users = [users] if not isinstance(users, list): users = [users]
@ -725,11 +708,11 @@ def app_addaccess(apps, users):
def app_removeaccess(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: Keyword argument:
apps -- List of app to revoke access to apps
users -- Users to revoke access for users
""" """
if not isinstance(users, list): users = [users] if not isinstance(users, list): users = [users]

View file

@ -20,6 +20,8 @@
""" """
""" yunohost_backup.py """ yunohost_backup.py
Manage backups
""" """
import os import os
import sys import sys
@ -32,11 +34,8 @@ def backup_init(helper=False):
""" """
Init Tahoe-LAFS configuration Init Tahoe-LAFS configuration
Keyword arguments: Keyword argument:
helper -- Create a helper node rather than a "helped" one helper -- Init as a helper node rather than a "helped" one
Returns:
Win | Fail
""" """
pass pass

View file

@ -20,6 +20,8 @@
""" """
""" yunohost_domain.py """ yunohost_domain.py
Manage domains
""" """
import os import os
import sys import sys
@ -35,15 +37,13 @@ lemon_tmp_conf = '/tmp/tmplemonconf'
def domain_list(filter=None, limit=None, offset=None): def domain_list(filter=None, limit=None, offset=None):
""" """
List YunoHost domains List domains
Keyword argument: Keyword argument:
filter -- LDAP filter to search with limit -- Maximum number of domain fetched
limit offset -- Starting number for domain fetching
offset filter -- LDAP filter used to search
Returns:
Dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
result_list = [] result_list = []
@ -69,15 +69,12 @@ def domain_list(filter=None, limit=None, offset=None):
def domain_add(domains, raw=False, main=False): def domain_add(domains, raw=False, main=False):
""" """
Add one or more domains Create a custom domain
Keyword argument: Keyword argument:
domains -- List of domains to add raw -- Auto-configure Apache and LemonLDAP for the domain
raw -- Do not configure Apache and LemonLDAP for the domain too domains -- Domain name to add
main -- Is the main domain
Returns:
Dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
attr_dict = { 'objectClass' : ['mailDomain', 'top'] } attr_dict = { 'objectClass' : ['mailDomain', 'top'] }
@ -225,13 +222,11 @@ def domain_add(domains, raw=False, main=False):
def domain_remove(domains): def domain_remove(domains):
""" """
Remove domain from LDAP Delete domains
Keyword argument: Keyword argument:
domains -- List of domains to remove domains -- Domain(s) to delete
Returns:
Dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
result = [] result = []

View file

@ -20,6 +20,8 @@
""" """
""" yunohost_dyndns.py """ yunohost_dyndns.py
Subscribe and Update DynDNS Hosts
""" """
import os import os
import sys import sys
@ -32,13 +34,10 @@ def dyndns_subscribe(subscribe_host="dyndns.yunohost.org", domain=None, key=None
""" """
Subscribe to a DynDNS service Subscribe to a DynDNS service
Keyword arguments: Keyword argument:
key -- Public DNS key
subscribe_host -- Dynette HTTP API to subscribe to subscribe_host -- Dynette HTTP API to subscribe to
domain -- Full domain to subscribe with domain -- Full domain to subscribe with
key -- Public DNS key
Returns:
Win | Fail
""" """
if domain is None: 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): 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 dyn_host -- Dynette DNS server to inform
domain -- Full domain to update ip -- IP address to send
key -- Public DNS key key -- Public DNS key
ip -- IP to send domain -- Full domain to subscribe with
Returns:
Win | Fail
""" """
if domain is None: if domain is None:
@ -145,8 +141,6 @@ def dyndns_installcron():
""" """
Install IP update cron Install IP update cron
Returns:
Win
""" """
os.system("touch /etc/cron.d/yunohost-dyndns") os.system("touch /etc/cron.d/yunohost-dyndns")
@ -158,8 +152,6 @@ def dyndns_removecron():
""" """
Remove IP update cron Remove IP update cron
Returns:
Win | Fail
""" """
try: try:

View file

@ -20,6 +20,8 @@
""" """
""" yunohost_firewall.py """ yunohost_firewall.py
Manage firewall rules
""" """
import os import os
import sys import sys
@ -40,16 +42,13 @@ from yunohost import YunoHostError, win_msg
def firewall_allow(protocol=None, port=None, ipv6=None, upnp=False): def firewall_allow(protocol=None, port=None, ipv6=None, upnp=False):
""" """
Allow port in iptables Allow connection port/protocol
Keyword arguments: Keyword argument:
protocol -- Protocol used protocol -- Protocol associated with port
ipv6 -- ipv6
upnp -- upnp
port -- Port to open port -- Port to open
ipv6 -- Boolean ipv6
upnp -- Boolean upnp
Return
Dict
""" """
port = int(port) 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): def firewall_disallow(protocol=None, port=None, ipv6=None, upnp=False):
""" """
Disallow port in iptables Disallow connection
Keyword arguments: Keyword argument:
protocol -- Protocol used protocol -- Protocol associated with port
ipv6 -- ipv6
upnp -- upnp
port -- Port to open 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(): def firewall_list():
""" """
Allow port in iptables List all firewall rules
Keyword arguments:
None
Return
Dict
""" """
with open ('firewall.yml') as f: with open ('firewall.yml') as f:
@ -115,13 +106,11 @@ def firewall_list():
def firewall_reload(upnp=False): def firewall_reload(upnp=False):
""" """
Reload iptables configuration Reload all firewall rules
Keyword arguments: Keyword argument:
upnp -- Boolean upnp upnp -- upnp
Return
Dict
""" """
with open('firewall.yml', 'r') as f: with open('firewall.yml', 'r') as f:
firewall = yaml.load(f) firewall = yaml.load(f)
@ -279,10 +268,8 @@ def remove_portmapping():
def firewall_installupnp(): def firewall_installupnp():
""" """
Add upnp cron Add upnp cron
Keyword arguments:
None
Return
None
""" """
with open('firewall.yml', 'r') as f: with open('firewall.yml', 'r') as f:
@ -303,10 +290,8 @@ def firewall_installupnp():
def firewall_removeupnp(): def firewall_removeupnp():
""" """
Remove upnp cron Remove upnp cron
Keyword arguments:
None
Return
None
""" """
with open('firewall.yml', 'r') as f: with open('firewall.yml', 'r') as f:
firewall = yaml.load(f) firewall = yaml.load(f)
@ -327,12 +312,9 @@ def firewall_removeupnp():
def firewall_checkupnp(): def firewall_checkupnp():
""" """
Check if UPNP is installed check if UPNP is install or not (0 yes 1 no)
Keyword arguments:
None
Return
0 if installed
1 if not
""" """
with open('firewall.yml', 'r') as f: with open('firewall.yml', 'r') as f:
firewall = yaml.load(f) firewall = yaml.load(f)
@ -344,11 +326,9 @@ def firewall_checkupnp():
def firewall_stop(): def firewall_stop():
""" """
Stop firewall Stop iptables and ip6tables
Keyword arguments:
None
Return
None
""" """
os.system ("iptables -P INPUT ACCEPT") os.system ("iptables -P INPUT ACCEPT")

View file

@ -20,6 +20,8 @@
""" """
""" yunohost_monitor.py """ yunohost_monitor.py
Monitoring functions
""" """
import xmlrpclib import xmlrpclib
import json 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): 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: if memory:
return json.loads(s.getMem()) 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')) raise YunoHostError(1, _('No arguments provided'))
def monitor_process(enable=None, disable=None, start=None, stop=None, check=None, info=False): 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())

View file

@ -20,6 +20,8 @@
""" """
""" yunohost_tools.py """ yunohost_tools.py
Specific tools
""" """
import os import os
import sys import sys
@ -32,10 +34,8 @@ from yunohost_dyndns import dyndns_subscribe
def tools_ldapinit(): def tools_ldapinit():
""" """
Initialize YunoHost LDAP scheme YunoHost LDAP initialization
Returns:
dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
@ -69,13 +69,10 @@ def tools_adminpw(old_password, new_password):
""" """
Change admin password Change admin password
Keyword arguments: Keyword argument:
old_password old_password
new_password new_password
Returns:
dict
""" """
# Validate password length # Validate password length
if len(new_password) < 4: if len(new_password) < 4:
@ -91,15 +88,12 @@ def tools_adminpw(old_password, new_password):
def tools_maindomain(old_domain, new_domain): def tools_maindomain(old_domain, new_domain):
""" """
Change admin password Main domain change tool
Keyword arguments: Keyword argument:
old_domain old_domain
new_domain new_domain
Returns:
dict
""" """
if not old_domain: if not old_domain:
@ -179,14 +173,12 @@ def tools_maindomain(old_domain, new_domain):
def tools_postinstall(domain, password, dyndns=False): def tools_postinstall(domain, password, dyndns=False):
""" """
Post-install configuration YunoHost post-install
Keyword arguments: Keyword argument:
domain -- Main domain password -- YunoHost admin password
password -- New admin password dyndns -- Subscribe domain to a DynDNS service
domain -- YunoHost main domain
Returns:
dict
""" """
with YunoHostLDAP(password='yunohost') as yldap: with YunoHostLDAP(password='yunohost') as yldap:

View file

@ -20,6 +20,8 @@
""" """
""" yunohost_user.py """ yunohost_user.py
Manage users
""" """
import os import os
import sys import sys
@ -33,16 +35,14 @@ from yunohost_domain import domain_list
def user_list(fields=None, filter=None, limit=None, offset=None): def user_list(fields=None, filter=None, limit=None, offset=None):
""" """
List YunoHost users from LDAP List users
Keyword argument: Keyword argument:
fields -- Fields to fetch fields -- fields to fetch
filter -- LDAP filter to use limit -- Maximum number of user fetched
limit -- Number of user to fetch offset -- Starting number for user fetching
offset -- User number to begin with filter -- LDAP filter used to search
Returns:
Dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
user_attrs = ['uid', 'mail', 'cn', 'maildrop'] 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): def user_create(username, firstname, lastname, mail, password):
""" """
Add user to LDAP Create user
Keyword argument: Keyword argument:
username
firstname
lastname
password password
firstname
mail -- Main mail address must be unique
lastname
username -- Must be unique
Returns:
Dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
# Validate password length # Validate password length
@ -159,14 +158,12 @@ def user_create(username, firstname, lastname, mail, password):
def user_delete(users, purge=None): def user_delete(users, purge=None):
""" """
Remove user from LDAP Delete user
Keyword argument: Keyword argument:
users -- List of users to delete or single user users -- Username of users to delete
purge -- Whether or not purge /home/user directory purge
Returns:
Dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
result = { 'Users' : [] } 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, 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 Update user informations
Keyword argument: 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 firstname
lastname add_mailalias -- Mail aliases to add
mail mail
change_password -- New password lastname
add_mailforward
remove_mailforward
add_mailalias
remove_mailalias
Returns:
Dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
attrs_to_fetch = ['givenName', 'sn', 'mail', 'maildrop'] 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): def user_info(username):
""" """
Fetch user informations from LDAP Get user informations
Keyword argument: Keyword argument:
username -- Username or mail to get info username -- Username or mail to get informations
Returns:
Dict
""" """
with YunoHostLDAP() as yldap: with YunoHostLDAP() as yldap:
user_attrs = ['cn', 'mail', 'uid', 'maildrop'] user_attrs = ['cn', 'mail', 'uid', 'maildrop']