From ded463f4b2e03cbc8587e56edfbfa8bd61c5b210 Mon Sep 17 00:00:00 2001 From: abohlman <54598168+abohlman@users.noreply.github.com> Date: Mon, 7 Oct 2019 13:14:48 -0400 Subject: [PATCH 1/5] Update to 3.7 --- hackerearth/api_handlers.py | 6 +++--- hackerearth/parameters.py | 14 +++++++------- hackerearth/result.py | 3 ++- hackerearth/setup.py | 27 +++++++++++++++++++++++++++ hackerearth/test_api.py | 15 ++++++++------- 5 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 hackerearth/setup.py diff --git a/hackerearth/api_handlers.py b/hackerearth/api_handlers.py index 2ad5a8e..a02a697 100644 --- a/hackerearth/api_handlers.py +++ b/hackerearth/api_handlers.py @@ -1,6 +1,6 @@ import json import urllib -import urllib2 +# import urllib2 import requests from settings import COMPILE_API_ENDPOINT @@ -37,8 +37,8 @@ def __request(self, url, params): response = None try: response = requests.post(url, data=params) - except Exception, e: - print e + except Exception as e: + print(e) return response diff --git a/hackerearth/parameters.py b/hackerearth/parameters.py index 1e8c72d..55b2afc 100644 --- a/hackerearth/parameters.py +++ b/hackerearth/parameters.py @@ -49,7 +49,7 @@ def _clean_params(self, params): """Removes parameters whose values are set to None. """ clean_params = {} - for key, value in params.iteritems(): + for key, value in params.items(): if value is not None: clean_params[key] = value @@ -58,7 +58,7 @@ def _clean_params(self, params): class CompileAPIParameters(BaseAPIParameters): def __init__(self, client_secret, source, lang, - async=0, + asyncron=0, id=None, save=1, callback='', @@ -70,7 +70,7 @@ def __init__(self, client_secret, source, lang, self.save = save self.callback = callback self.compressed = compressed - self.async = async + self.asyncron = asyncron def _build_params_dict(self): params = super(CompileAPIParameters, self)._build_params_dict() @@ -80,7 +80,7 @@ def _build_params_dict(self): 'save': self.save, 'callback': self.callback, 'compressed': self.compressed, - 'async': self.async + 'async': self.asyncron }) return params @@ -90,7 +90,7 @@ def __init__(self, client_secret, source, lang, program_input=None, time_limit=settings.RUN_TIME_UPPER_LIMIT, memory_limit=settings.MEMORY_UPPER_LIMIT, - async=0, + asyncron = 0, id=None, save=1, callback='', @@ -104,12 +104,12 @@ def __init__(self, client_secret, source, lang, self.save = save self.callback = callback self.compressed = compressed - self.async = async + self.asyncron = asyncron self.html = html self.compiled = compiled self.time_limit = min(time_limit, settings.RUN_TIME_UPPER_LIMIT) self.memory_limit = min(memory_limit, settings.MEMORY_UPPER_LIMIT) - print self.memory_limit + print (self.memory_limit) def _build_params_dict(self): params = super(RunAPIParameters, self)._build_params_dict() diff --git a/hackerearth/result.py b/hackerearth/result.py index e6007e0..3496970 100644 --- a/hackerearth/result.py +++ b/hackerearth/result.py @@ -1,5 +1,6 @@ import json + class BaseAPIResult(object): """Represents a response from the HackerEarth API. """ @@ -44,7 +45,7 @@ def _flatten_dict(self, dict_): key/value pairs. """ flattened_dict = {} - for (key, value) in dict_.iteritems(): + for (key, value) in dict_.items(): if isinstance(value, dict): flattened_dict.update(self._flatten_dict(value)) else: diff --git a/hackerearth/setup.py b/hackerearth/setup.py new file mode 100644 index 0000000..b55a5c7 --- /dev/null +++ b/hackerearth/setup.py @@ -0,0 +1,27 @@ +from setuptools import setup + + +REQUIREMENTS = [ + 'requests' +] + + +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Topic :: Internet', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3.7', + ] + +setup(name='he-sdk-python', + version='0.3', + description='Python client for HackerEarth Code Checker API v3', + url='https://github.com/HackerEarth/he-sdk-python', + author='Praveen Kumar', + author_email='praveen@hackerearth.com', + license='MIT', + packages=['hackerearth'], + classifiers=CLASSIFIERS, + keywords='hackerarth code cheker api python client', install_requires=['requests'] + ) diff --git a/hackerearth/test_api.py b/hackerearth/test_api.py index b2b0a5c..b6d6f6d 100644 --- a/hackerearth/test_api.py +++ b/hackerearth/test_api.py @@ -6,7 +6,7 @@ from api_handlers import HackerEarthAPI -client_secret = '0a7f0101e5cc06e4417a3addeb76164680ac83a4' +client_secret = '' source = open('test_source.py', 'r').read() lang = SupportedLanguages.PYTHON @@ -18,14 +18,15 @@ api = HackerEarthAPI(params) -print 'Compiling code..' +print('Compiling code..') r = api.compile() -print r.__dict__ +# print(r.__dict__) If something breaks, uncomment this -print '\nRunning code...' +print('\nRunning code...') r = api.run() -print r.__dict__ +# print(r.__dict__) If something breaks, uncomment this output = r.__dict__.get('output') -print '\nRun Output:' -print output +print('\nRun Output:') +print(output) +# print('Process Complete!') From 619083b414bec81c2a7bd1a9cd4788742e073af4 Mon Sep 17 00:00:00 2001 From: abohlman <54598168+abohlman@users.noreply.github.com> Date: Mon, 7 Oct 2019 13:19:57 -0400 Subject: [PATCH 2/5] Update api_handlers.py --- hackerearth/api_handlers.py | 1 - 1 file changed, 1 deletion(-) diff --git a/hackerearth/api_handlers.py b/hackerearth/api_handlers.py index a02a697..87b8c8a 100644 --- a/hackerearth/api_handlers.py +++ b/hackerearth/api_handlers.py @@ -1,6 +1,5 @@ import json import urllib -# import urllib2 import requests from settings import COMPILE_API_ENDPOINT From f4a11c735410b36c0f863ba6fb145ec469dfa05d Mon Sep 17 00:00:00 2001 From: abohlman <54598168+abohlman@users.noreply.github.com> Date: Mon, 7 Oct 2019 13:22:00 -0400 Subject: [PATCH 3/5] Delete setup.py --- hackerearth/setup.py | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 hackerearth/setup.py diff --git a/hackerearth/setup.py b/hackerearth/setup.py deleted file mode 100644 index b55a5c7..0000000 --- a/hackerearth/setup.py +++ /dev/null @@ -1,27 +0,0 @@ -from setuptools import setup - - -REQUIREMENTS = [ - 'requests' -] - - -CLASSIFIERS = [ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Developers', - 'Topic :: Internet', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.7', - ] - -setup(name='he-sdk-python', - version='0.3', - description='Python client for HackerEarth Code Checker API v3', - url='https://github.com/HackerEarth/he-sdk-python', - author='Praveen Kumar', - author_email='praveen@hackerearth.com', - license='MIT', - packages=['hackerearth'], - classifiers=CLASSIFIERS, - keywords='hackerarth code cheker api python client', install_requires=['requests'] - ) From ed36f67712f80614b25fb80513e7882a81ba4050 Mon Sep 17 00:00:00 2001 From: abohlman <54598168+abohlman@users.noreply.github.com> Date: Mon, 7 Oct 2019 13:22:32 -0400 Subject: [PATCH 4/5] Update setup.py --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index bb8eab4..b55a5c7 100644 --- a/setup.py +++ b/setup.py @@ -11,8 +11,7 @@ 'Intended Audience :: Developers', 'Topic :: Internet', 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.7', ] setup(name='he-sdk-python', @@ -24,5 +23,5 @@ license='MIT', packages=['hackerearth'], classifiers=CLASSIFIERS, - keywords='hackerarth code cheker api python client' + keywords='hackerarth code cheker api python client', install_requires=['requests'] ) From 558344e18745e3e0f2b82f011b56e8f0aec7f64c Mon Sep 17 00:00:00 2001 From: abohlman <54598168+abohlman@users.noreply.github.com> Date: Mon, 7 Oct 2019 13:24:58 -0400 Subject: [PATCH 5/5] Update test_api.py --- hackerearth/test_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hackerearth/test_api.py b/hackerearth/test_api.py index b6d6f6d..a2da85f 100644 --- a/hackerearth/test_api.py +++ b/hackerearth/test_api.py @@ -20,11 +20,11 @@ print('Compiling code..') r = api.compile() -# print(r.__dict__) If something breaks, uncomment this +print(r.__dict__) print('\nRunning code...') r = api.run() -# print(r.__dict__) If something breaks, uncomment this +print(r.__dict__) output = r.__dict__.get('output') print('\nRun Output:')