Alien-SVN
view release on metacpan or search on metacpan
src/subversion/tools/dist/collect_sigs.py view on Meta::CPAN
curs = db.cursor()
like_filename = 'subversion-%s.%%' % config.version
curs.execute('''SELECT filename, signature FROM signatures
WHERE filename LIKE ?''', (like_filename, ) )
for filename, signature in curs:
fd = _open(filename)
fd.write(signature)
for fd in fds.values():
fd.flush()
fd.close()
actions = {
'make_config' : make_config,
'make_db' : make_db,
'make_asc' : generate_asc_files,
}
if __name__ == '__main__':
if len(sys.argv) > 1:
if sys.argv[1] in actions:
actions[sys.argv[1]]()
sys.exit(0)
# Stuff below this line is the web-facing side
# ======================================================================
import cgi
import cgitb
cgitb.enable()
import string, subprocess, re
try:
sys.path.append(os.path.dirname(sys.argv[0]))
import config
except:
print 'Content-type: text/plain'
print
print 'Cannot find config file'
sys.exit(1)
r = re.compile('^\[GNUPG\:\] GOODSIG (\w*) (.*)')
def files():
for f in os.listdir(config.filesdir):
if config.version in f and (f.endswith('.tar.gz') or f.endswith('.zip') or f.endswith('.tar.bz2')):
yield f
def ordinal(N):
try:
return [None, 'first', 'second', 'third', 'fourth', 'fifth', 'sixth'][N]
except:
# Huh? We only have six files to sign.
return "%dth" % N
shell_content = '''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Signature collection for Subversion $version</title>
</head>
<body style="font-size: 14pt; text-align: justify;
background-color: #f0f0f0; padding: 0 5%%">
<p>This page is used to collect <a href="%s/list">signatures</a> for the
proposed release of Apache Subversion $version.</p>
$content
</body>
</html>
''' % os.getenv('SCRIPT_NAME')
signature_area = '''
<hr/>
<form method="post" action="%s">
<p>Paste one or more signatures in the area below:<br/>
<textarea name="signatures" rows="20" cols="80"></textarea>
</p>
<input type="submit" value="Submit" />
<p>Any text not between the <tt>BEGIN PGP SIGNATURE</tt>
and <tt>END PGP SIGNATURE</tt> lines will be ignored.</p>
</form>
<hr/>
''' % os.getenv('SCRIPT_NAME')
def split(sigs):
lines = []
for line in sigs.split('\n'):
if lines or '--BEGIN' in line:
lines.append(line)
if '--END' in line:
yield "\n".join(lines) + "\n"
lines = []
def list_signatures():
db = sqlite3.connect(os.path.join(config.sigdir, 'sigs.db'))
template = '''
<hr/>
<p>The following signature files are available:</p>
<p>%s</p>
'''
lines = ""
curs = db.cursor()
like_filename = 'subversion-%s.%%' % config.version
curs.execute('''SELECT filename, COUNT(*) FROM signatures
WHERE filename LIKE ?
GROUP BY filename ORDER BY filename''',
(like_filename, ) )
for filename, count in curs:
lines += '<a href="%s/%s.asc">%s.asc</a>: %d signature%s<br/>\n' \
% (os.getenv('SCRIPT_NAME'), filename, filename,
count, ['s', ''][count == 1])
return (template % lines) + signature_area
def save_valid_sig(db, filename, keyid, signature):
( run in 1.329 second using v1.01-cache-2.11-cpan-8644d7adfcd )