Allow site-local extensions to autoserv, and a custom site install
of the autotest client
From: Steve Howard <showard@google.com>
Signed-off-by: Martin Bligh <mbligh@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@876 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/server/utils.py b/server/utils.py
index d650701..ba350ef 100644
--- a/server/utils.py
+++ b/server/utils.py
@@ -381,3 +381,38 @@
def get_server_dir():
path = os.path.dirname(sys.modules['utils'].__file__)
return os.path.abspath(path)
+
+
+class AutoservOptionParser:
+ """Custom command-line options parser for autoserv.
+
+ We can't use the general getopt methods here, as there will be unknown
+ extra arguments that we pass down into the control file instead.
+ Thus we process the arguments by hand, for which we are duly repentant.
+ Making a single function here just makes it harder to read. Suck it up.
+ """
+
+ def __init__(self, args):
+ self.args = args
+
+
+ def parse_opts(self, flag):
+ if self.args.count(flag):
+ idx = self.args.index(flag)
+ self.args[idx : idx+1] = []
+ return True
+ else:
+ return False
+
+
+ def parse_opts_param(self, flag, default = None, split = False):
+ if self.args.count(flag):
+ idx = self.args.index(flag)
+ ret = self.args[idx+1]
+ self.args[idx : idx+2] = []
+ if split:
+ return ret.split(split)
+ else:
+ return ret
+ else:
+ return default