keedio / buildoop

Hadoop Ecosystem Builder: Build, package, test and deploy your Hadoop ecosystem project.
Apache License 2.0
28 stars 11 forks source link

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

Closed jjmleiro closed 9 years ago

jjmleiro commented 9 years ago

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(sourcefile, 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")