[reprotest] 01/04: Put the list of servers in a more obvious place in the --help text

Ximin Luo infinity0 at debian.org
Fri Nov 18 19:02:20 UTC 2016


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

infinity0 pushed a commit to branch master
in repository reprotest.

commit aa2bfc83aaa6dab8b610f4de59423582a339a18c
Author: Ximin Luo <infinity0 at debian.org>
Date:   Fri Nov 18 17:24:47 2016 +0100

    Put the list of servers in a more obvious place in the --help text
---
 README.md             |  9 ++++-----
 reprotest/__init__.py | 14 +++++++++-----
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index ebf4103..f80b5f6 100644
--- a/README.md
+++ b/README.md
@@ -29,15 +29,14 @@ Running in a virtual server
 ===========================
 
 You can also run the build inside what is called a "virtual server". This could
-be a container, a chroot, etc. There are different ones available, look under
-reprotest/virt (or $PYTHONPATH/reprotest/virt) for a full list. You run them
-like this:
+be a container, a chroot, etc. There are different ones available, see `--help`
+full list. You run them like this:
 
     reprotest 'python3 setup.py bdist_wheel' 'dist/*.whl' qemu /path/to/qemu.img
     reprotest 'debuild -b -uc -us' '../*.deb' schroot unstable-amd64
 
-You can run `reprotest/virt/$SERVER --help` for a full list of options.
-TODO: add these to reprotest's `--help`.
+You can also run `reprotest --help <virtual_server_name>` for a full list of
+options for that particular virtual server.
 
 Unfortunately we currently don't set up build dependencies inside the virtual
 server so you will have to either do that yourself before running reprotest,
diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index f3daaf1..35a2ccd 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -32,9 +32,13 @@ def is_executable(parent, fn):
     path = os.path.join(parent, fn)
     return os.path.isfile(path) and os.access(path, os.X_OK)
 
+all_servers = None
 def get_all_servers():
-    server_dir = get_server_path("")
-    return sorted(fn for fn in os.listdir(server_dir) if is_executable(server_dir, fn))
+    global all_servers
+    if all_servers is None:
+        server_dir = get_server_path("")
+        all_servers = sorted(fn for fn in os.listdir(server_dir) if is_executable(server_dir, fn))
+    return all_servers
 
 
 # chroot is the only form of OS virtualization that's available on
@@ -418,14 +422,14 @@ COMMAND_LINE_OPTIONS = types.MappingProxyType(collections.OrderedDict([
                 'being the name of the server. If this itself contains options '
                 '(of the form -xxx or --xxx), you should put a "--" between '
                 'these arguments and reprotest\'s own options. '
-                'Default: "null", to run directly in /tmp.'})),
+                'Default: "null", to run directly in /tmp. Choices: %s' %
+                ', '.join(get_all_servers())})),
     ('--help', types.MappingProxyType({
         'dest': 'help', 'default': None, 'const': True, 'nargs': '?',
         'choices': get_all_servers(),
         'metavar': 'VIRTUAL_SERVER_NAME',
         'help': 'Show this help message and exit. When given an argument, '
-        'show instead the help message for that virtual server and exit. '
-        'Choices: %(choices)s'})),
+        'show instead the help message for that virtual server and exit. '})),
     ('--source-root', types.MappingProxyType({
         'dest': 'source_root', 'type': pathlib.Path,
         'help': 'Root of the source tree, if not the '

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git



More information about the Reproducible-commits mailing list