Skip to content

Commit

Permalink
forgot to add files
Browse files Browse the repository at this point in the history
  • Loading branch information
irontablee committed Aug 24, 2016
1 parent 9f55b09 commit eccc2fa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
31 changes: 30 additions & 1 deletion genie-client/src/main/python/pygenie/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import time
import uuid

from functools import wraps

import requests

from .auth import AuthHandler
Expand Down Expand Up @@ -97,6 +99,33 @@ def call(url, method='get', headers=None, raise_not_status=None,
return resp


def convert_to_unicode(value):
"""Convert value to unicode."""

if is_str(value) and not isinstance(value, unicode):
return value.decode('utf-8')

return value


def unicodify(func):
"""
Decorator to convert all string args and kwargs to unicode.
"""

@wraps(func)
def wrapper(*args, **kwargs):
"""Wraps func."""

args = tuple(convert_to_unicode(i) for i in args)
kwargs = {convert_to_unicode(key): convert_to_unicode(value) \
for key, value in kwargs.items()}

return func(*args, **kwargs)

return wrapper


def dttm_to_epoch(date_str, frmt='%Y-%m-%dT%H:%M:%SZ'):
"""Convert a date string to epoch seconds."""

Expand Down Expand Up @@ -146,4 +175,4 @@ def uuid_str():
str: A unique id.
"""

return str(uuid.uuid1())
return unicode(uuid.uuid1())
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.1.0',
version='3.0.33',
author='Netflix Inc.',
author_email='genieoss@googlegroups.com',
keywords='genie hadoop cloud netflix client bigdata presto',
Expand Down

0 comments on commit eccc2fa

Please sign in to comment.