Beispiel #1
0
	if os.path.exists('imgs.info') == False: return
	imgs = getPairs('imgs.info', 'img', 'path', 'url')

def getImg(path):
	print 'image: %s' % (path)
	if path not in imgs.keys():
		print 'uploading...'
		url = uploadpic(path).getURL()
		# there is some decode bug, just do this yet.
		print >>open('imgs.info', 'a'), '<img path=\"%s\" url=\"%s\"/>' % (path, url)
		updateimg()
	print imgs[path]
	return imgs[path]

# init img
getToken(getVal("init.info", "flickr", "token"))
updateimg()

froot = os.getcwd()
wordfilename = os.path.join(froot, 'problem.doc')
htmlfilename = os.path.join(froot, 'problem.html')

# turn the word file to html file
msword = client.Dispatch('Word.Application')
msword.Visible = 0
msword.DisplayAlerts = 0
doc = msword.Documents.Open(wordfilename)
doc.SaveAs(htmlfilename, 10) # wdFormatHTML = 10
doc.Close()
msword.Quit()
Beispiel #2
0
import urllib, urllib2, cookielib
from inforeader import getVal
import re

cid = getVal("init.info", "diy", "cid")
pid = getVal("init.info", "problem", "pid")

username = ''
userpass = ''
diypass = getVal("init.info", "diy", "pass")

cookiejar = cookielib.CookieJar()
cookieproc = urllib2.HTTPCookieProcessor(cookiejar)
urlOpener = urllib2.build_opener(cookieproc)

# login
loginurl = "http://acm.hdu.edu.cn/userloginex.php?action=login&cid=0&notice=0"
loginval = {"username": username, "userpass": userpass, "login":"******"}
urlOpener.open(urllib2.Request(loginurl, urllib.urlencode(loginval)))

# enterdiy
diyurl = "http://acm.hdu.edu.cn/diy/contest_login.php?action=login&cid=" + cid
diyval = {"password":diypass, "submit":"Enter"}
print urlOpener.open(urllib2.Request(diyurl, urllib.urlencode(diyval))).read

# submit
submiturl = "http://acm.hdu.edu.cn/diy/contest_submit.php?action=submit&cid=" + cid
code = open("standard.cpp", "r").read()
code = re.sub("freopen", "//freopen", code)
submitval = {"problemid":pid, "language":"0", "usercode":code}
print urlOpener.open(urllib2.Request(submiturl, urllib.urlencode(submitval))).read()
Beispiel #3
0
from cookielib import CookieJar
from inforeader import getVal, getText

#login
cookiejar = CookieJar()
cookieproc = HTTPCookieProcessor(cookiejar)
urlOpener = build_opener(cookieproc)

loginurl = "http://acm.hdu.edu.cn/userloginex.php?action=login&cid=0&notice=0"
loginval = {"username":"******", "userpass":"******", "login":"******"}
urlOpener.open(Request(loginurl, urlencode(loginval)))

#read file
infofile = 'problem.info'

cid = getVal(infofile, 'cid', 'cid')
pid = getVal(infofile, 'pid', 'pid')

proval = {}
proval['pid'] =					pid
#proval['title'] =				getVal(infofile, 'title', 'title')
proval['title'] =				"<h1>" + getVal(infofile, 'title', 'title') + "</h1>"
proval['timelimit'] =			getVal(infofile, 'timelimite', 'timelimite')
proval['javatimelimit'] =		getVal(infofile, 'timelimite', 'javatimelimite')
proval['memorylimit'] =			getVal(infofile, 'memorylimite', 'memorylimite')
proval['javamemorylimit'] = 	getVal(infofile, 'memorylimite', 'javamemorylimite')
proval['outputlimit'] =			getVal(infofile, 'outputlimite', 'outputlimite')
proval['author'] =				getVal(infofile, 'author', 'author')
proval['source'] =				getVal(infofile, 'source', 'source')
proval['content'] =				getText(infofile, 'description')
proval['input'] =				getText(infofile, 'input')