[X2Go-Commits] [x2gobroker] 02/07: x2gobroker/defaults.py: Provide API documentation for global defaults.

git-admin at x2go.org git-admin at x2go.org
Thu Sep 13 15:26:35 CEST 2018


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2gobroker.

commit eefaed4187faa6af33c15e4622a75039845a4ab9
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Thu Sep 13 08:22:52 2018 +0200

    x2gobroker/defaults.py: Provide API documentation for global defaults.
---
 docs/Makefile          |  3 ++
 x2gobroker/defaults.py | 94 ++++++++++++++++++++++++++++++++------------------
 2 files changed, 64 insertions(+), 33 deletions(-)

diff --git a/docs/Makefile b/docs/Makefile
index 9e23aa9..f97332f 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -1,6 +1,9 @@
 # Makefile for Sphinx documentation
 #
 
+# required in the Python X2Go Broker code... e.g. in x2gobroker/defaults.py
+SPHINX_API_DOCUMENTATION_BUILD = yes
+
 # You can set these variables from the command line.
 SPHINXOPTS    =
 SPHINXBUILD   = sphinx-build
diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py
index 0196496..1615354 100644
--- a/x2gobroker/defaults.py
+++ b/x2gobroker/defaults.py
@@ -17,6 +17,18 @@
 # Free Software Foundation, Inc.,
 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
+"""
+X2Go Session Brokers uses many hard-coded defaults, that can be overridden in various ways:
+
+  * environment variables of the same name as the variable name in Python
+  * for **SysV init system**: environment variables set in a default configuration
+    file under ``/etc/default``; normally the naming scheme is
+    ``/etc/default/<executable-name>``
+  * for **systemd init system**: in the file ``/etc/x2go/broker/defaults.conf``:
+    this file should be installed on your system, the file needs to be provided
+    in INI file format
+"""
+
 # modules
 import os
 import uuid
@@ -29,10 +41,20 @@ from x2gobroker.loggers import iniconfig_loaded
 if iniconfig_loaded:
     from x2gobroker.loggers import iniconfig, iniconfig_section
 
-X2GOBROKER_USER =  pwd.getpwuid(os.geteuid())[0]
-X2GOBROKER_GROUP =  grp.getgrgid(pwd.getpwuid(os.geteuid())[3])[0]
+X2GOBROKER_USER = '<some-user>'
+"""The (system) user, X2Go Session Broker runs under. Whether this is a system user or e.g. your own user account depends on what component of the broker is used."""
+if 'SPHINX_API_DOCUMENTATION_BUILD' in os.environ.keys():
+    X2GOBROKER_USER =  pwd.getpwuid(os.geteuid())[0]
+
+X2GOBROKER_GROUP = '<some-group>'
+"""The (system) group, X2Go Session Broker runs under. Whether this is a system user or e.g. the x2gobroker-users group is dependent on what component of the broker is used."""
+if 'SPHINX_API_DOCUMENTATION_BUILD' in os.environ.keys():
+    X2GOBROKER_GROUP =  grp.getgrgid(pwd.getpwuid(os.geteuid())[3])[0]
+
 os.environ['HOME'] = pwd.getpwuid(os.geteuid())[5]
 
+X2GOBROKER_AGENT_USER="x2gobroker"
+"""The system user to use when launching X2Go Broker Agent on remote X2Go Servers."""
 if 'X2GOBROKER_DAEMON_GROUP' in os.environ:
     X2GOBROKER_DAEMON_GROUP=os.environ['X2GOBROKER_DAEMON_GROUP']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DAEMON_GROUP'):
@@ -47,13 +69,13 @@ elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_AG
     X2GOBROKER_AGENT_USER=iniconfig.get(iniconfig_section, 'X2GOBROKER_AGENT_USER')
 elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_AGENT_USER'):
     X2GOBROKER_AGENT_USER=iniconfig.get('common', 'X2GOBROKER_AGENT_USER')
-else:
-    X2GOBROKER_AGENT_USER="x2gobroker"
 
 ###
 ### dynamic default values, influencable through os.environ...
 ###
 
+X2GOBROKER_DEBUG_INTERACTIVELY = False
+"""When set to ``True``, the X2Go Broker component this parameter is set for, runs in foreground and debugging mode."""
 if 'X2GOBROKER_DEBUG' in os.environ:
     X2GOBROKER_DEBUG = ( os.environ['X2GOBROKER_DEBUG'].lower() in ('1', 'on', 'true', 'yes', ) )
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DEBUG'):
@@ -68,8 +90,7 @@ elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DE
     X2GOBROKER_DEBUG_INTERACTIVELY=iniconfig.get(iniconfig_section, 'X2GOBROKER_DEBUG_INTERACTIVELY')
 elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DEBUG_INTERACTIVELY'):
     X2GOBROKER_DEBUG_INTERACTIVELY=iniconfig.get('common', 'X2GOBROKER_DEBUG_INTERACTIVELY')
-else:
-    X2GOBROKER_DEBUG_INTERACTIVELY = False
+
 if 'X2GOBROKER_TESTSUITE' in os.environ:
     X2GOBROKER_TESTSUITE = ( os.environ['X2GOBROKER_TESTSUITE'].lower() in ('1', 'on', 'true', 'yes', ) )
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_TESTSUITE'):
@@ -89,94 +110,95 @@ if X2GOBROKER_TESTSUITE:
     logger_access.setLevel(logging.CRITICAL)
     logger_error.setLevel(logging.CRITICAL)
 
+X2GOBROKER_CONFIG = "/etc/x2go/x2gobroker.conf"
+"""Location of X2Go Broker\'s global configuration file."""
 if 'X2GOBROKER_CONFIG' in os.environ:
     X2GOBROKER_CONFIG = os.environ['X2GOBROKER_CONFIG']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_CONFIG'):
     X2GOBROKER_CONFIG=iniconfig.get(iniconfig_section, 'X2GOBROKER_CONFIG')
 elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_CONFIG'):
     X2GOBROKER_CONFIG=iniconfig.get('common', 'X2GOBROKER_CONFIG')
-else:
-    X2GOBROKER_CONFIG = "/etc/x2go/x2gobroker.conf"
 
+X2GOBROKER_SESSIONPROFILES = "/etc/x2go/broker/x2gobroker-sessionprofiles.conf"
+"""Location of the INI file based broker backend \'s session profiles configuration file."""
 if 'X2GOBROKER_SESSIONPROFILES' in os.environ:
     X2GOBROKER_SESSIONPROFILES = os.environ['X2GOBROKER_SESSIONPROFILES']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_SESSIONPROFILES'):
     X2GOBROKER_SESSIONPROFILES=iniconfig.get(iniconfig_section, 'X2GOBROKER_SESSIONPROFILES')
 elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_SESSIONPROFILES'):
     X2GOBROKER_SESSIONPROFILES=iniconfig.get('common', 'X2GOBROKER_SESSIONPROFILES')
-else:
-    X2GOBROKER_SESSIONPROFILES = "/etc/x2go/broker/x2gobroker-sessionprofiles.conf"
 
+X2GOBROKER_AGENT_CMD = "/usr/lib/x2go/x2gobroker-agent"
+"""Path to the X2Go Broker Agent executable on remote X2Go Servers."""
 if 'X2GOBROKER_AGENT_CMD' in os.environ:
     X2GOBROKER_AGENT_CMD = os.environ['X2GOBROKER_AGENT_CMD']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_AGENT_CMD'):
     X2GOBROKER_AGENT_CMD=iniconfig.get(iniconfig_section, 'X2GOBROKER_AGENT_CMD')
 elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_AGENT_CMD'):
     X2GOBROKER_AGENT_CMD=iniconfig.get('common', 'X2GOBROKER_AGENT_CMD')
-else:
-    X2GOBROKER_AGENT_CMD = "/usr/lib/x2go/x2gobroker-agent"
 
+if os.path.isdir('/run/x2gobroker'):
+    RUNDIR = '/run'
+else:
+    RUNDIR = '/var/run/x2gobroker'
+X2GOBROKER_AUTHSERVICE_SOCKET="{run}/x2gobroker/x2gobroker-authservice.socket".format(run=RUNDIR)
+"""Location of the X2Go Broker Auth Service's authentication socket file."""
 if 'X2GOBROKER_AUTHSERVICE_SOCKET' in os.environ:
     X2GOBROKER_AUTHSERVICE_SOCKET=os.environ['X2GOBROKER_AUTHSERVICE_SOCKET']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_AUTHSERVICE_SOCKET'):
     X2GOBROKER_AUTHSERVICE_SOCKET=iniconfig.get(iniconfig_section, 'X2GOBROKER_AUTHSERVICE_SOCKET')
 elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_AUTHSERVICE_SOCKET'):
     X2GOBROKER_AUTHSERVICE_SOCKET=iniconfig.get('common', 'X2GOBROKER_AUTHSERVICE_SOCKET')
-else:
-    if os.path.isdir('/run/x2gobroker'):
-        RUNDIR = '/run'
-    else:
-        RUNDIR = '/var/run/x2gobroker'
-    X2GOBROKER_AUTHSERVICE_SOCKET="{run}/x2gobroker/x2gobroker-authservice.socket".format(run=RUNDIR)
 
+if os.path.isdir('/run/x2gobroker'):
+    RUNDIR = '/run'
+else:
+    RUNDIR = '/var/run/x2gobroker'
+X2GOBROKER_LOADCHECKER_SOCKET="{run}/x2gobroker/x2gobroker-loadchecker.socket".format(run=RUNDIR)
+"""Location of the X2Go Broker Load Checker's communication socket file."""
 if 'X2GOBROKER_LOADCHECKER_SOCKET' in os.environ:
     X2GOBROKER_LOADCHECKER_SOCKET=os.environ['X2GOBROKER_LOADCHECKER_SOCKET']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_LOADCHECKER_SOCKET'):
     X2GOBROKER_LOADCHECKER_SOCKET=iniconfig.get(iniconfig_section, 'X2GOBROKER_LOADCHECKER_SOCKET')
 elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_LOADCHECKER_SOCKET'):
     X2GOBROKER_LOADCHECKER_SOCKET=iniconfig.get('common', 'X2GOBROKER_LOADCHECKER_SOCKET')
-else:
-    if os.path.isdir('/run/x2gobroker'):
-        RUNDIR = '/run'
-    else:
-        RUNDIR = '/var/run/x2gobroker'
-    X2GOBROKER_LOADCHECKER_SOCKET="{run}/x2gobroker/x2gobroker-loadchecker.socket".format(run=RUNDIR)
 
+X2GOBROKER_DEFAULT_BACKEND = "inifile"
+"""The broker backend to use by default."""
 if 'X2GOBROKER_DEFAULT_BACKEND' in os.environ:
     X2GOBROKER_DEFAULT_BACKEND = os.environ['X2GOBROKER_DEFAULT_BACKEND']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_DEFAULT_BACKEND'):
     X2GOBROKER_DEFAULT_BACKEND=iniconfig.get(iniconfig_section, 'X2GOBROKER_DEFAULT_BACKEND')
 elif iniconfig_loaded and iniconfig.has_option('common', 'X2GOBROKER_DEFAULT_BACKEND'):
     X2GOBROKER_DEFAULT_BACKEND=iniconfig.get('common', 'X2GOBROKER_DEFAULT_BACKEND')
-else:
-    X2GOBROKER_DEFAULT_BACKEND = "inifile"
 
+
+DAEMON_BIND_ADDRESS = ""
+"""Bind address for the X2Go Session Broker standalone daemon."""
 if 'DAEMON_BIND_ADDRESS' in os.environ:
     DAEMON_BIND_ADDRESS = os.environ['DAEMON_BIND_ADDRESS']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'DAEMON_BIND_ADDRESS'):
     DAEMON_BIND_ADDRESS = iniconfig.get(iniconfig_section, 'DAEMON_BIND_ADDRESS')
 elif iniconfig_loaded and iniconfig.has_option('daemon', 'DAEMON_BIND_ADDRESS'):
     DAEMON_BIND_ADDRESS = iniconfig.get('daemon', 'DAEMON_BIND_ADDRESS')
-else:
-    DAEMON_BIND_ADDRESS = ""
 
+X2GOBROKER_SSL_CERTFILE = ""
+"""Path to the SSL/TLS public certificate file."""
 if 'X2GOBROKER_SSL_CERTFILE' in os.environ:
     X2GOBROKER_SSL_CERTFILE = os.environ['X2GOBROKER_SSL_CERTFILE']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_SSL_CERTFILE'):
     X2GOBROKER_SSL_CERTFILE = iniconfig.get(iniconfig_section, 'X2GOBROKER_SSL_CERTFILE')
 elif iniconfig_loaded and iniconfig.has_option('daemon', 'X2GOBROKER_SSL_CERTFILE'):
     X2GOBROKER_SSL_CERTFILE = iniconfig.get('daemon', 'X2GOBROKER_SSL_CERTFILE')
-else:
-    X2GOBROKER_SSL_CERTFILE = ""
 
+X2GOBROKER_SSL_KEYFILE = ""
+"""Path to the SSL/TLS secret key file."""
 if 'X2GOBROKER_SSL_KEYFILE' in os.environ:
     X2GOBROKER_SSL_KEYFILE = os.environ['X2GOBROKER_SSL_KEYFILE']
 elif iniconfig_loaded and iniconfig.has_option(iniconfig_section, 'X2GOBROKER_SSL_KEYFILE'):
     X2GOBROKER_SSL_KEYFILE = iniconfig.get(iniconfig_section, 'X2GOBROKER_SSL_KEYFILE')
 elif iniconfig_loaded and iniconfig.has_option('daemon', 'X2GOBROKER_SSL_KEYFILE'):
     X2GOBROKER_SSL_KEYFILE = iniconfig.get('daemon', 'X2GOBROKER_SSL_KEYFILE')
-else:
-    X2GOBROKER_SSL_KEYFILE = ""
 
 ###
 ### static / hard-coded defaults
@@ -189,6 +211,7 @@ else:
 
 # the home directory of the user that the daemon/cgi runs as
 X2GOBROKER_HOME = os.path.normpath(os.path.expanduser('~{broker_uid}'.format(broker_uid=X2GOBROKER_DAEMON_USER)))
+"""Home directory of the user that an X2Go Broker component runs under."""
 
 # defaults for X2Go Sessino Broker configuration file
 X2GOBROKER_CONFIG_DEFAULTS = {
@@ -258,6 +281,8 @@ X2GOBROKER_CONFIG_DEFAULTS = {
         'load-checker': True,
     },
 }
+"""Defaults of the global configuration file, see ``X2GOBROKER_CONFIG``."""
+
 
 X2GO_DESKTOP_SESSIONS= [
     'KDE',
@@ -273,6 +298,7 @@ X2GO_DESKTOP_SESSIONS= [
     'OPENBOX',
     'XDMCP',
 ]
+"""Desktop environment session types supported by X2Go."""
 
 # defaults for X2Go Sessino Broker session profiles file
 X2GOBROKER_SESSIONPROFILE_DEFAULTS = {
@@ -323,5 +349,7 @@ X2GOBROKER_SESSIONPROFILE_DEFAULTS = {
         'acl-any-order': 'deny-allow',
     },
 }
+"""Default setting of a broker'ish session profile."""
 
-X2GOBROKER_LATEST_UCCS_API_VERSION = 5
\ No newline at end of file
+X2GOBROKER_LATEST_UCCS_API_VERSION = 5
+"""Latest known API of the UCCS protocol that we support."""

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git


More information about the x2go-commits mailing list