Skip to content

Commit

Permalink
Merge pull request #11 from xcpcio/fix-gym-spider-in-windows
Browse files Browse the repository at this point in the history
fix: replace `:` character
  • Loading branch information
Dup4 committed Dec 18, 2023
2 parents 6696e5d + e2e2eaf commit ee09c59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 0 additions & 2 deletions codeforces_gym_spider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@ python gao.py <GYM ID> [--output <Output path>]

# Incremental Seeding After Failure
python gao.py <GYM ID> --submissions <submissions list that can be found under output path> [--output <Output path>]


```
6 changes: 3 additions & 3 deletions codeforces_gym_spider/credential.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"api_key" : "",
"api_secret" : ""
}
"api_key": "",
"api_secret": ""
}
9 changes: 5 additions & 4 deletions codeforces_gym_spider/gao.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

extensions = (
('++', 'cpp'),
('GNU C', 'c'),
('GNU C', 'c'),
('JavaScript', 'js'),
('Java', 'java'),
('Py', 'py'),
Expand Down Expand Up @@ -48,7 +48,7 @@ def issue_request(method, params, cred):
#print(sig_plain)
alg = hashlib.new("sha512", sig_plain.encode(encoding='ascii'))
api_sig = alg.hexdigest()
uri = 'https://codeforces.com/api/%s?%s&apiKey=%s&time=%d&apiSig=%s%s'%(method, params, key, now, rand, api_sig)
uri = 'https://codeforces.com/api/%s?%s&apiKey=%s&time=%d&apiSig=%s%s'%(method, params, key, now, rand, api_sig)
#print(uri)
r = requests.get(uri)
return r
Expand Down Expand Up @@ -163,10 +163,11 @@ def download_submission(session, sub):
problem = sub['problem']["index"]
problem_root = output_root + problem + '/'
if os.path.exists(problem_root) == False:
info('Problem %s Home not exsited, create it: '%(problem) + os.path.abspath(problem_root))
info('Problem %s Home not existed, create it: '%(problem) + os.path.abspath(problem_root))
os.mkdir(problem_root)
ext = get_extension(sub)
author = sub['author']['teamName'] if 'teamName' in sub['author'] else sub['author']['members'][0]['handle']
author = author.replace(':', '_')
sub_path = problem_root + sub['verdict'] + '_' + author + '_' + str(sub['id']) + '.' + ext
if os.path.exists(sub_path):
info('Skipped ' + sub_path)
Expand Down Expand Up @@ -226,7 +227,7 @@ def main():
info('[%d/%d] Processed. %d Succeeded.'%(count, len(submissions), succeed))
if count % 10 == 0:
info('Time Escaped %ds. ET: %ds.'%(passed, et))

print('Done. Succeed: %d, Total: %d'%(succeed, len(submissions)))
return True

Expand Down

0 comments on commit ee09c59

Please sign in to comment.