summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEUcancER <root@euer.krebsco.de>2011-11-11 17:03:31 +0100
committerEUcancER <root@euer.krebsco.de>2011-11-11 17:03:31 +0100
commit29340f39ee60caf36449be35c15f670fa71e379a (patch)
tree2905cb02511226151d341cebfcef8f83bd843f53
parentb37cb6566653a2b51dc1548c3056fa5969cd7f76 (diff)
//punani/tightnani: initial commit
tightnani-web is a web API for the (currently) nonexistant tightnani client which resolves common packages to their packer counterparts like apt-get,pacman etc.
-rwxr-xr-xpunani/tightnani/tightnani-web.py48
-rw-r--r--punani/tightnani/tightnani_db25
2 files changed, 73 insertions, 0 deletions
diff --git a/punani/tightnani/tightnani-web.py b/punani/tightnani/tightnani-web.py
new file mode 100755
index 00000000..52f5004f
--- /dev/null
+++ b/punani/tightnani/tightnani-web.py
@@ -0,0 +1,48 @@
+#!/usr/bin/python
+
+import web
+import json
+
+urls = (
+ '/', 'Index',
+ '/dump','Dump',
+ '/reload','Reload',
+ '/(.+)/(.+)', 'ArchFinder',
+)
+
+
+PDB_FILE="tightnani_db"
+
+pdb= json.load(open(PDB_FILE))
+
+class Index:
+ def GET(self):
+ ret = """Welcome to the Tightnani API<br/>
+Retrieve a package name for your distribution with: /ARCH/PKG"""
+ return ret
+
+class Reload:
+ def GET(self):
+ pdb= json.load(open(PDB_FILE))
+ return "DB reloaded"
+
+
+class Dump:
+ def GET(self):
+ return json.dumps(pdb,sort_keys=True,indent=4)
+
+class ArchFinder:
+ def GET(self,packer,package):
+ if not packer or not package: web.BadRequest()
+ else:
+ packer = pdb['packer-symlinks'].get(packer,packer) #try to resolve similar packers
+ ret = pdb.get(package,{}).get(packer,False)
+ if not ret: web.NotFound()
+ else: return ret
+
+
+
+if __name__ == "__main__":
+ app = web.application(urls,globals())
+ app.internalerror = web.debugerror
+ app.run()
diff --git a/punani/tightnani/tightnani_db b/punani/tightnani/tightnani_db
new file mode 100644
index 00000000..d15a9ad4
--- /dev/null
+++ b/punani/tightnani/tightnani_db
@@ -0,0 +1,25 @@
+{
+ "packer-symlinks" : {
+ "packer" : "yaourt",
+ "aptitude" : "apt-get",
+ "bauerbill" : "yaourt"
+ },
+ "vim" : {
+ "apt-get" : "vim",
+ "pacman" : "vim",
+ "brew" : "vim",
+ "yum" : "vim"
+ },
+ "python" : {
+ "apt-get" : "python",
+ "pacman" : "python2"
+ },
+ "python2" : {
+ "apt-get" : "python",
+ "pacman" : "python2"
+ },
+ "python3" : {
+ "apt-get" : "python3",
+ "pacman" : "python"
+ }
+}