-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_doi.py
executable file
·60 lines (51 loc) · 1.97 KB
/
add_doi.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
52
53
54
55
56
57
58
59
60
import cgi
import cgitb
import os
import sys
sys.path.append('/data/project/recitation-bot/recitation-bot/recitation-bot/')
import status_page
cgitb.enable()
print "Content-Type: text/html" # HTML is following
print # blank line, end of headers
print "<TITLE>jump a doi to the front of the queue</TITLE>"
print "<H1>jump a doi to the front of the queue</H1>"
print "<html>"
print "<body>"
# standard single line text field
print "<form method='post'>"
print "Enter a doi (don't include 'http://dx.doi.org/'):"
print "<input type='text' name='doi' value='' /><BR/>"
print "If DOI already uploaded, force reupload of "
reupload_vars = ['reupload_text', 'reupload_images', 'reupload_equations', 'reupload_tables']
reupload_text = ['text', 'images', 'equations', 'tables']
for var, text in zip(reupload_vars, reupload_text):
print "<input type='checkbox' name='%s' />%s" % (var, text)
print ".<br /><input type='submit' value='submit form' />"
print "</form>"
form = cgi.FieldStorage()
reupload = []
doi_plain = ''
#print form
for field_name in form:
field=form[field_name]
for check in reupload_vars:
if field.name == check:
if form[check].value == 'on':
print "<p>%s : %s</p>" % (check, form[check].value)
reupload.append(check)
if field.name == 'doi':
doi_plain = field.value
doi_safe = cgi.escape(repr(doi_plain))
if doi_plain:
#write to log
dequeue = open('/data/project/recitation-bot/recitation-bot/jump_the_queue.log','a')
dequeue.write(doi_plain+'\t'+str(reupload)+'\n')
dequeue.close()
#show the user
print "<p>%s will be uploaded shortly</p>" % doi_safe
url = 'http://tools.wmflabs.org/recitation-bot/' + doi_plain + '.html'
print "<p>Follow the upload status at <a href='%s'>%s</a> </p>" % (url, url)
status_page.make_status_page(doi=doi_plain, success=None, error_msg=None,ja=None, inqueue=True)
print "</ul>"
print "</body>"
print "</html>"