From 2aafac137049f5fff234551089ce8c9a8a5eea1f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 22 Feb 2007 20:07:23 +0000 Subject: [PATCH] can set env vars --- doc/README.virtualisation-server | 10 +++++++--- virt-subproc/VirtSubproc.py | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/README.virtualisation-server b/doc/README.virtualisation-server index 3c3835d..ab7243c 100644 --- a/doc/README.virtualisation-server +++ b/doc/README.virtualisation-server @@ -103,18 +103,22 @@ Protocol Currently defined keyword arguments: + env== + + Sets the environment variable to . + debug=- Arranges to pass fd the testbed command, and send all output to it to the fd as passed by the virt server's caller. - If this feature is available, execute-debug will - be advertised. Only one such plumbing is available. - may be 1 or 2, in which case no output will be written to the or files. + If this feature is available, execute-debug will + be advertised. Only one such plumbing is available. + * Commands copydown copyup diff --git a/virt-subproc/VirtSubproc.py b/virt-subproc/VirtSubproc.py index 8720716..32af6d5 100644 --- a/virt-subproc/VirtSubproc.py +++ b/virt-subproc/VirtSubproc.py @@ -148,12 +148,17 @@ def cmd_execute(c, ce): cmdnumargs(c, ce, 5, None) debug_re = regexp.compile('debug=(\d+)\-(\d+)$') debug_g = None + envs = [] for kw in ce[6:]: if kw.startswith('debug='): if debug_g: bomb("multiple debug= in execute") m = debug_re.match(kw) if not m: bomb("invalid execute debug arg `%s'" % kw) debug_g = m.groups() + elif kw.startswith('env='): + es = kw[4:]; eq = es.find('=') + if eq <= 0: bomb("invalid env arg `%s'" % kw) + envs.append((es[:eq], es[eq+1:])) else: bomb("invalid execute kw arg `%s'" % kw) gobody = " import sys\n" @@ -169,6 +174,10 @@ def cmd_execute(c, ce): if ioe == tfd: ioe_tfd = -1 gobody += " setfd(%d,'%s',%d)\n" % ( ioe_tfd, ce[ioe+2], ioe>0 ) + for e in envs: + gobody += (" os.environ[urllib.unquote('%s')]" + " = urllib.unquote('%s')\n" + % tuple(map(urllib.quote, e))) gobody += " os.chdir(urllib.unquote('" + ce[5] +"'))\n" gobody += " cmd = '%s'\n" % ce[1] gobody += (" cmd = cmd.split(',')\n" -- 2.30.2