Skip to content

Commit

Permalink
URL Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
yemyat committed Nov 25, 2010
2 parents f93e6d4 + 1eff3f9 commit cc671ad
Showing 1 changed file with 28 additions and 18 deletions.
46 changes: 28 additions & 18 deletions PSDownloaderGUI.py
Expand Up @@ -17,54 +17,64 @@ def download():
topic_id_list = leo.parse_id("topicid",leo.open_url(URL_LIST["current_problem"]+
"projectid="+str(project_id_list[-1])+
"&groupid="+str(group_id_list[-1])))

get_download_url = leo.open_url(URL_LIST["problem_download"]+topic_id_list[-1])

download_url = "http://leo.rp.edu.sg"+ re.search('HREF=\"(.+?zip)',get_download_url.read()).groups()[0]
response.set("Downloading")
os.chdir(os.path.expanduser("~/Desktop"))
zip_file = open("problem.zip","wb")
zip_file.write( leo.open_url(download_url).read() )
zip_file.close()

extractDirectory=""
file=open("problem.zip")

##WillYan
zfile=zipfile.ZipFile(file)
a=zfile.namelist()
zfile.extractall()
b=os.getcwd()+"/"+"Problem"+str(len(project_id_list))+"/"
os.makedirs(b)
count=0
for i in a:
extractDirectory=os.getcwd()+"/"+str(i)
filename=a[count][(a[count].rfind("/")+1)::]
if(os.path.isdir(extractDirectory)==False):
shutil.copyfile(extractDirectory,(b+"/"+filename))
count+=1
os.remove("problem.zip")
response.set("Done!")

def download_thread(dummy=1):
threading.Thread(target=download).start()

if __name__ == "__main__":
root = Tk()
root.title("LEO PS Downloader")

main_frame = Frame(root,width=200,height=120)
main_frame.grid(column=0,row=0)

username_label = Label(main_frame, text="Username")
username_label.grid(column=0,row=0)

username_field =Entry(main_frame)
username_field.grid(column=1,row=0,columnspan=2)

password_label = Label(main_frame, text="Password")
password_label.grid(column=0,row=1)

password_field =Entry(main_frame,show="*")
password_field.grid(column=1,row=1,columnspan=2)
password_field.bind("<Return>",download_thread)

response = StringVar()
response.set("")

response_label = Label(main_frame, textvariable=response,fg="red",anchor=W,justify=LEFT)
response_label.grid(column=0,row=2)

dl_button = Button(main_frame,text="Download",command=download_thread)
dl_button.grid(column=2,row=2)

root.mainloop()






root.mainloop()

0 comments on commit cc671ad

Please sign in to comment.