]>
git.ipfire.org Git - ipfire.org.git/blob - www/pages/source/__init__.py
3 SOURCE_BASE
="/srv/sources"
4 SOURCE_HASHES
="/srv/www/ipfire.org/source/hashes.db"
6 SOURCE_URL
="http://source.ipfire.org"
10 from pysqlite2
import dbapi2
as sqlite
15 def __init__(self
, db
, file):
17 self
.name
= os
.path
.basename(file)
22 self
.db
= sqlite
.connect(SOURCE_HASHES
)
24 c
.execute("CREATE TABLE IF NOT EXISTS hashes(file, sha1)")
28 f
= open(self
.file, "rb")
33 def getHash(self
, type="sha1"):
36 c
.execute("SELECT %s FROM hashes WHERE file = '%s'" % (type, self
.name
,))
38 hash = c
.fetchone()[0]
44 hash = sha
.new(self
.data()).hexdigest()
46 c
.execute("INSERT INTO hashes(file, sha1) VALUES('%s', '%s')" % \
53 class Content(web
.Content
):
54 def __init__(self
, name
):
55 web
.Content
.__init
__(self
, name
)
60 db
= sqlite
.connect(SOURCE_HASHES
)
62 for dir, subdirs
, files
in os
.walk(SOURCE_BASE
):
68 file = os
.path
.join(dir, file)
69 fileobjects
.append(SourceObject(db
, file))
70 self
.dirs
.append((os
.path
.basename(dir), fileobjects
))
72 def __call__(self
, lang
):
74 self
.w("<h3>IPFire Source Base</h3>")
75 for dir, files
in self
.dirs
:
79 b
.w("""<li style="font-family: courier;">%(hash)s | <a href="%(url)s/%(dir)s/%(file)s">%(file)s</a></li>""" % \
81 "hash" : file.getHash() or "0000000000000000000000000000000000000000",
83 "url" : SOURCE_URL
, })