Skip to content

Commit

Permalink
Submissions in various languages
Browse files Browse the repository at this point in the history
  • Loading branch information
architv committed Feb 7, 2014
2 parents 6f5c55a + 98e27a8 commit 49a6dfe
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ Dependencies:

These dependencies can be installed via `pip` or `apt-get`

For mechanize:

$ pip install mechanize
$ apt-get install python-mechanize
For BeautifulSoup4:

$ pip install BeautifulSoup4
$ apt-get install python-BeautifulSoup4
Usage:
----------
Expand All @@ -39,9 +34,16 @@ Usage:

Note:
------
The submission takes place in your default programming language.
The submission takes place in the following programming languages:

* C
* C++
* Java
* C#
* Python

Developed By:
--------------
* [Dhruv Agarwal](https://github.com/dhruvagarwal)
* [Archit Verma](https://github.com/architv)

38 changes: 28 additions & 10 deletions fastsubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@ def ran_string(res, list):
except:
print random.choice(myList[2])

def f_submit(site):
path = raw_input('Give your file path along with name and extension: ')
fil = open(path).read()
br.open('http://www.'+site+'.com/submit/' + raw_input("Enter Question Code: "))
br.select_form(nr=0)
br.form["body" if site=='codechef' else "file"]=fil
return br.submit()
def f_submit(site,langlist):
path = raw_input('Give your file path along with name and extension: ')
fil = open(path).read()
br.open('http://www.'+site+'.com/submit/' + raw_input("Enter Question Code: "))
br.select_form(nr=0)
br.form["body" if site=='codechef' else "file"]=fil
print "Please choose the programming language(Enter the number corresponding to it):"
i=1
for lang in langlist:
for key in lang:
print("%d. %s" % (i,key))
i+=1
sub = raw_input()
key, value = (langlist[int(sub)-1]).popitem()
br.form["submission_language" if site=='codechef' else "lang"]=[value]
return br.submit()

def recheck_cc(solution_id):
response = mechanize.urlopen('http://www.codechef.com/viewsolution/'+solution_id)
Expand All @@ -53,7 +62,7 @@ def recheck_cc(solution_id):
return status.split(':')[1]

def cc():
response = f_submit('codechef')
response = f_submit('codechef',langlist)
html_code = str(response.read())
html_code = html_code.split('\n')
for line in html_code:
Expand All @@ -80,7 +89,7 @@ def recheck(user):
return x[4]

def sp(user):
f_submit('spoj')
f_submit('spoj',langlist)
c=0
res=recheck(user)
print "Running your solution. Sit tight."
Expand All @@ -93,6 +102,15 @@ def sp(user):
myList.append(['That was awesome!','Your IQ is off the charts!','Now that was some pretty cool stuff','You rock! Nice job.', 'Very NIce'])
myList.append(['You almost nailed that one! A little quicker next time.'])
myList.append(['That\'s sad. You should consider trying again','This is programming. You know that, right?','Aww, snap!', 'Oh, drat!'])
langlist = []
langlist.append({'C(gcc-4.8.1)':'11'})
langlist.append({'C++(gcc-4.3.2)':'41'})
langlist.append({'C++(gcc-4.8.1)':'1'})
langlist.append({'C++11(gcc-4.8.1)':'44'})
langlist.append({'C#(gmcs-2.0.1)':'27'})
langlist.append({'Java(javac-1.7.0_25)':'10'})
langlist.append({'Python(python-2.7.2)':'4'})
langlist.append({'Python3(python-3.1.2)':'116'})
threadLock = threading.Lock()
br = mechanize.Browser()
br.set_handle_robots(False)
Expand Down Expand Up @@ -130,4 +148,4 @@ def sp(user):
t_sp=mythread(site,data[1])
t_sp.start()
t_sp.join()
ch=raw_input("Do you want to continue(y/n): ")
ch=raw_input("Do you want to continue(y/n): ")

0 comments on commit 49a6dfe

Please sign in to comment.