-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (48 loc) · 1.79 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import asyncio
from pyppeteer import launch
from lightoj import LightOJ
from vjudge import Vjudge
import os
async def main():
browser = await launch({
'args': [
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-setuid-sandbox',
'--no-first-run',
'--no-sandbox',
'--no-zygote',
'--single-process']
})
print('Vjudge')
vjudge_username = input('User Id or E-mail: ')
vjudge_password = input('Password: ')
vjudge = Vjudge(vjudge_username, vjudge_password)
vjudge.downloadSubmissions()
print('LightOJ')
lightoj_username = input('User Id or E-mail: ')
lightoj_password = input('Password: ')
directory_path = 'solutions/LightOJ'
lightOj = LightOJ(lightoj_username, lightoj_password, browser)
logged_in = await lightOj.login()
if not logged_in:
print('login failed: lightoj')
exit(0)
# print(await lightOj.get_solve_list())
if not os.path.exists(directory_path):
print('No LightOJ solutions')
exit(0)
for problem_number in os.listdir(directory_path):
# if lightOj.is_solved(problem_number):
# print(problem_number + " is already solved")
# else:
# print(problem_number + " is not solved")
for file in os.listdir(directory_path + '/' + problem_number):
with open(directory_path + '/' + problem_number + '/' + file) as file:
source_code = file.read()
extension = os.path.splitext(file.name)[1]
await lightOj.submit(problem_number, source_code, extension)
print(await lightOj.get_solve_list())
await browser.close()
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())