Skip to content

Commit

Permalink
Merge pull request #294 from irontable/develop
Browse files Browse the repository at this point in the history
fix config values being read as lists in Python client
  • Loading branch information
irontablee committed Jun 22, 2016
2 parents 885ce59 + d0cfa38 commit 12acfcf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions genie-client/src/main/python/pygenie/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,33 @@ def _load_options(self):
sections with options set to the :py:class:`GenieConfSection` object's
attributes."""

# this is work-around for when config values are loaded as a list when
# execution is threaded (still need to look closer into why this is
# happening)
def unlist(value):
return value[0] if isinstance(value, list) else value

# explicitly set genie section object
self.genie.set('url', C.get('genie.url', DEFAULT_GENIE_URL))
self.genie.set('username', C.get('genie.username',
os.environ.get('USER',
DEFAULT_GENIE_USERNAME)))
self.genie.set('version', C.get('genie.version', DEFAULT_GENIE_VERSION))
default_username = os.environ.get('USER', DEFAULT_GENIE_USERNAME)
self.genie.set('url',
unlist(C.get('genie.url', DEFAULT_GENIE_URL)))
self.genie.set('username',
unlist(C.get('genie.username', default_username)))
self.genie.set('version',
unlist(C.get('genie.version', DEFAULT_GENIE_VERSION)))

# create and set other section objects
for section in C.config.sections():
section_clean = section.replace(' ', '_').replace('.', '_')
gcs = self.genie if section_clean == 'genie' \
else GenieConfSection(name=section_clean)

for option in C.config.options(section):
option_clean = option.replace(' ', '_').replace('.', '_')
if section_clean != 'genie' \
or option_clean not in {'url', 'username', 'version'}:
gcs.set(option_clean, C.get(section, option))
gcs.set(option_clean, unlist(C.get(section, option)))

setattr(self, section_clean, gcs)

def to_dict(self):
Expand Down
2 changes: 1 addition & 1 deletion genie-client/src/main/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name='nflx-genie-client',
version='3.0.4',
version='3.0.5',
author='Netflix Inc.',
author_email='genieoss@googlegroups.com',
keywords='genie hadoop cloud netflix client bigdata presto',
Expand Down

0 comments on commit 12acfcf

Please sign in to comment.