-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathstart.py
35 lines (30 loc) · 1.31 KB
/
start.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
from GitterClasses import *
if len(sys.argv) == 5 and sys.argv[1] == 'fetch' and sys.argv[3] == 'git-push':
print 'Fetch from Codechef and push to github.'
Config.githubUser = (sys.argv[4])[:(sys.argv[4]).find('/')]
Config.githubRepo = (sys.argv[4])[(sys.argv[4]).find('/') + 1:]
pass1 = getpass.getpass('Github Password : ')
pass2 = getpass.getpass('Retype Password : ')
if (pass1 != pass2):
sys.exit('Passwords dont match!')
else:
Config.githubPasswd = pass1
git = Git(Config.githubUser, Config.githubPasswd, Config.githubRepo)
git.clone()
elif len(sys.argv) == 3 and sys.argv[1] == 'fetch':
print 'Fetch and save from Codechef'
Config.codechefUser = sys.argv[2]
Config.githubRepo = sys.argv[2] # to set name of local directory as codechefUsername
else:
sys.exit(
'Kindly follow correct format for input.\n\tpython start.py fetch <codechef-username>\nOR\n\tpython start.py fetch <codechef-username> git-push <github-username>/<github-repo>')
Chef.buildProblemListAndFileStructure(Config.codechefUser)
Chef.updateSubmissionList()
Chef.fetchSubmissions()
if len(sys.argv) == 3:
sys.exit('Done.')
git.add()
git.commit('Another Auto Commit!')
git.push()
sys.exit(
'\nTask Completed\n\nFORK from : https://github.com/aedorado/CodeChef-Gitter\n')