Skip to content

Update to 3.7 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions hackerearth/api_handlers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import urllib
import urllib2
import requests

from settings import COMPILE_API_ENDPOINT
Expand Down Expand Up @@ -37,8 +36,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


Expand Down
14 changes: 7 additions & 7 deletions hackerearth/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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='',
Expand All @@ -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()
Expand All @@ -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

Expand All @@ -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='',
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion hackerearth/result.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json


class BaseAPIResult(object):
"""Represents a response from the HackerEarth API.
"""
Expand Down Expand Up @@ -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:
Expand Down
15 changes: 8 additions & 7 deletions hackerearth/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from api_handlers import HackerEarthAPI

client_secret = '0a7f0101e5cc06e4417a3addeb76164680ac83a4'
client_secret = ''

source = open('test_source.py', 'r').read()
lang = SupportedLanguages.PYTHON
Expand All @@ -18,14 +18,15 @@

api = HackerEarthAPI(params)

print 'Compiling code..'
print('Compiling code..')
r = api.compile()
print r.__dict__
print(r.__dict__)

print '\nRunning code...'
print('\nRunning code...')
r = api.run()
print r.__dict__
print(r.__dict__)
output = r.__dict__.get('output')

print '\nRun Output:'
print output
print('\nRun Output:')
print(output)
# print('Process Complete!')
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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']
)