Skip to content

Commit

Permalink
Fixed encoding issues and __import__ level
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlowery committed Mar 10, 2017
1 parent 3cf0a3d commit b2055e5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Submission.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from urllib import urlencode
from urllib2 import urlopen
from urllib.parse import urlencode
from urllib.request import urlopen
from json import loads, dumps
from collections import OrderedDict
import numpy as np
Expand All @@ -22,11 +22,11 @@ def submit(self):
self.login_prompt()

parts = OrderedDict()
for part_id, _ in enumerate(self.__srcs,1):
for part_id, _ in enumerate(self.__srcs, 1):
parts[str(part_id)] = {'output': self.__output(part_id)}

result, response = self.request(parts)
response = loads(response)
response = loads(response.decode('utf-8'))
try:
print(response['errorMessage'])
return
Expand All @@ -40,7 +40,7 @@ def submit(self):
partFeedback = response['partFeedbacks'][part]
partEvaluation = response['partEvaluations'][part]
score = '%d / %3d' % (partEvaluation['score'], partEvaluation['maxScore'])
print('== %43s | %9s | %-s' % (self.__part_names[int(part)-1], score, partFeedback))
print('== %43s | %9s | %-s' % (self.__part_names[int(part) - 1], score, partFeedback))

evaluation = response['evaluation']

Expand Down Expand Up @@ -80,8 +80,7 @@ def request(self, parts):
'secret': self.__password,
'parts': parts,
'submitterEmail': self.__login}

params = urlencode({'jsonBody': dumps(params)})
params = urlencode({'jsonBody': dumps(params)}).encode('utf-8')
f = urlopen(self.__submit_url, params)
try:
return 0, f.read()
Expand Down

0 comments on commit b2055e5

Please sign in to comment.