Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

[ Storm 0.9.2 - Openbus 0.0.1 ] Storm scripts loses environment variables #145

Closed
jjmleiro opened this issue Nov 25, 2014 · 0 comments
Closed

Comments

@jjmleiro
Copy link

Possible solution in Storm Script:

def set_env(env_file):
while True:
source_file = '/tmp/regr.source.%d'%random.randint(0, (2*32)-1)
if not os.path.isfile(source_file): break
with open(source_file, 'w') as src_file:
src_file.write('#!/bin/bash\n')
src_file.write('source %s\n'%env_file)
src_file.write('env\n')
os.chmod(source_file, 0755)
p = subprocess.Popen(source_file, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = p.communicate()
setting = re.compile('^(?P[^=]
)=')
value = re.compile('=(?P.*$)')
env_dict = {}
for line in out.splitlines():
if setting.search(line) and value.search(line):
env_dict[setting.search(line).group('setting')] = value.search(line).group('value')
for k, v in env_dict.items():
os.environ[k] = v
for k, v in env_dict.items():
try:
assert(os.getenv(k) == v)
except AssertionError:
raise Exception('Unable to modify environment')

set_env("/etc/default/storm")

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant