summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/examples/hydrilla.wsgi9
-rw-r--r--setup.cfg2
-rw-r--r--src/hydrilla/server/__init__.py2
-rw-r--r--src/hydrilla/server/locales/en_US/LC_MESSAGES/hydrilla-messages.po14
-rw-r--r--src/hydrilla/server/serve.py13
-rw-r--r--tests/test_server.py3
6 files changed, 35 insertions, 8 deletions
diff --git a/doc/examples/hydrilla.wsgi b/doc/examples/hydrilla.wsgi
index 0a3769b..3455701 100644
--- a/doc/examples/hydrilla.wsgi
+++ b/doc/examples/hydrilla.wsgi
@@ -13,9 +13,14 @@
#path = Path('/path/to/virtualenv/bin/activate_this.py')
#exec(path.read_text(), {'__file__': str(path)})
-from hydrilla.server import HydrillaApp, config
+from hydrilla.server import start_wsgi
# The following line will initialize Hydrilla with the default, internal
# configuration while also attempting to load /etc/hydrilla/config.json if it's
# present.
-application = HydrillaApp(config.load())
+application = start_wsgi()
+
+# Comment the above and uncomment this to use a different config file.
+
+#from hydrilla.server import config
+#application = start_wsgi(config.load(['/path/to/config.json']))
diff --git a/setup.cfg b/setup.cfg
index 95c540c..7b506a2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -53,7 +53,7 @@ exclude =
[options.entry_points]
console_scripts =
- hydrilla = hydrilla.server.serve:start
+ hydrilla = hydrilla.server:start
[extract_messages]
mapping_file = babel.cfg
diff --git a/src/hydrilla/server/__init__.py b/src/hydrilla/server/__init__.py
index baa78cc..7bd71ea 100644
--- a/src/hydrilla/server/__init__.py
+++ b/src/hydrilla/server/__init__.py
@@ -5,4 +5,4 @@
# Available under the terms of Creative Commons Zero v1.0 Universal.
from . import config
-from .serve import HydrillaApp
+from .serve import start, start_wsgi
diff --git a/src/hydrilla/server/locales/en_US/LC_MESSAGES/hydrilla-messages.po b/src/hydrilla/server/locales/en_US/LC_MESSAGES/hydrilla-messages.po
index a532a37..7ea930a 100644
--- a/src/hydrilla/server/locales/en_US/LC_MESSAGES/hydrilla-messages.po
+++ b/src/hydrilla/server/locales/en_US/LC_MESSAGES/hydrilla-messages.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: hydrilla.builder 0.1\n"
"Report-Msgid-Bugs-To: koszko@koszko.org\n"
-"POT-Creation-Date: 2022-04-19 14:22+0200\n"
+"POT-Creation-Date: 2022-04-22 17:09+0200\n"
"PO-Revision-Date: 2022-02-12 00:00+0000\n"
"Last-Translator: Wojtek Kosior <koszko@koszko.org>\n"
"Language: en_US\n"
@@ -67,6 +67,7 @@ msgstr ""
"'{pattern}')."
#: src/hydrilla/server/serve.py:566 src/hydrilla/server/serve.py:588
+#: src/hydrilla/server/serve.py:626
#, python-format
msgid "%(prog)s_%(version)s_license"
msgstr ""
@@ -108,7 +109,7 @@ msgstr ""
"Language to use (also affects served HTML files). Overrides value from "
"the config file (if any)."
-#: src/hydrilla/server/serve.py:589
+#: src/hydrilla/server/serve.py:589 src/hydrilla/server/serve.py:627
msgid "version_printing"
msgstr "Print version information and exit."
@@ -125,6 +126,15 @@ msgstr ""
"Hydrilla instance. For better performance, consider deployment using "
"WSGI."
+#: src/hydrilla/server/serve.py:632
+msgid "serve_hydrilla_packages_wsgi_help"
+msgstr ""
+"Serve Hydrilla packages.\n"
+"\n"
+"This program is a WSGI script that runs Hydrilla repository behind an "
+"HTTP server like Apache2 or Nginx. You can configure Hydrilla through the"
+" /etc/hydrilla/config.json file."
+
#. 'hydrilla' as a title
#: src/hydrilla/server/templates/base.html:99
#: src/hydrilla/server/templates/base.html:105
diff --git a/src/hydrilla/server/serve.py b/src/hydrilla/server/serve.py
index 9e51324..d2835f6 100644
--- a/src/hydrilla/server/serve.py
+++ b/src/hydrilla/server/serve.py
@@ -558,7 +558,7 @@ def query():
@bp.route('/--help')
def mm_help():
- return start.get_help(click.Context(start)) + '\n'
+ return start.get_help(click.Context(start_wsgi)) + '\n'
@bp.route('/--version')
def mm_version():
@@ -621,3 +621,14 @@ def start(malcontent_dir: Optional[str], hydrilla_project_url: Optional[str],
start.__doc__ = _('serve_hydrilla_packages_explain_wsgi_considerations')
start = click.command()(start)
+
+@click.version_option(version=_version.version, prog_name='Hydrilla',
+ message=_('%(prog)s_%(version)s_license'),
+ help=_('version_printing'))
+def start_wsgi(_config=None) -> None:
+ """<this will be replaced by a localized docstring for Click to pick up>"""
+ return HydrillaApp(_config or config.load())
+
+start_wsgi.__doc__ = _('serve_hydrilla_packages_wsgi_help')
+
+start_wsgi = click.command()(start_wsgi)
diff --git a/tests/test_server.py b/tests/test_server.py
index 1da5663..0820d5c 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -43,7 +43,8 @@ from werkzeug import Response
from hydrilla import util as hydrilla_util
from hydrilla.builder import Build
-from hydrilla.server import HydrillaApp, config, _version
+from hydrilla.server import config, _version
+from hydrilla.server.serve import HydrillaApp
here = Path(__file__).resolve().parent
config_path = here / 'config.json'