Skip to content
Snippets Groups Projects

fixed list of variables reported by lb-run

Merged Marco Clemencic requested to merge clemenci/LbScripts:LBCORE-1111 into master
+ 18
7
Compare changes
  • Side-by-side
  • Inline
@@ -113,13 +113,16 @@ class Script(object):
help="XML file describing the changes to the environment")
parser.add_option("--sh",
action="store_const", const="sh", dest="shell",
help="Print the environment as shell commands for 'sh'-derived shells.")
help="Print the changes to the environment as shell commands for 'sh'-derived shells.")
parser.add_option("--csh",
action="store_const", const="csh", dest="shell",
help="Print the environment as shell commands for 'csh'-derived shells.")
help="Print the changes to the environment as shell commands for 'csh'-derived shells.")
parser.add_option("--py",
action="store_const", const="py", dest="shell",
help="Print the environment as Python dictionary.")
help="Print the changes to the environment as Python dictionary.")
parser.add_option("-A", "--all",
action="store_true",
help="Print all variables, instead of just the changes, with --sh, --csh and --py.")
parser.add_option('--verbose', action='store_const',
const=logging.INFO, dest='log_level',
@@ -204,16 +207,24 @@ class Script(object):
'''
Print to standard output the final environment in the required format.
'''
if not self.opts.shell or self.opts.all:
# 'env' behaviour: print the whole environment
env = self.env
else:
# special dumps: print only the diffs
env = dict((name, value)
for name, value in sorted(self.env.items())
if os.environ.get(name) != value)
if self.opts.shell == 'py':
from pprint import pprint
pprint(self.env)
pprint(env)
else:
template = {'sh': "export {0}='{1}'",
'csh': "setenv {0} '{1}';"}.get(self.opts.shell,
"{0}={1}")
for name, value in sorted(self.env.items()):
if os.environ.get(name) != value:
print template.format(name, value)
print '\n'.join(template.format(name, value)
for name, value in sorted(env.items()))
def expandEnvVars(self, iterable):
'''
Loading