1. David Wilson
  2. pypi-search

Commits

David Wilson  committed ece6e88

Snapshot random bits.

  • Participants
  • Parent commits 97c8564
  • Branches master

Comments (0)

Files changed (6)

File dbcopy.py

View file
+
+import lmdb
+
+d = lmdb.open('data.lmdb')
+d2 = lmdb.open('d2.lmdb', map_size=1048576 * 1024, sync=False,
+    writemap=True)
+
+with d2.begin(write=True) as txn:
+    for key, value in d.cursor(buffers=True):
+        txn.put(key, value, append=True)
+

File go.sh

View file
+#!/bin/bash
+gunicorn -w 32 -b 127.0.0.1:5000 run:app

File mirror.py

View file
     return xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
 
 
-def init_store():
+def init_store(path=None):
     global engine
     global store
     global workqueue
     global releases
 
     #, sync=False, map_async=True)
-    engine = centidb.support.LmdbEngine(path='data.lmdb',
+    engine = centidb.support.LmdbEngine(path=path or 'data.lmdb',
         map_size=1048576*1024, sync=False)
     store = centidb.Store(engine)
     workqueue = centidb.Collection(store, 'workqueue')

File run.py

View file
     t_1 = now(True)
 
     n0 = now(True)
-    enq.set_query(query);
-    matches = enq.get_mset(0, 100);
+    enq.set_query(query)
+    matches = enq.get_mset(0, 25);
     print 'get_mset:', now(True) - n0
     print 'len', len(matches)
     n1 = now(True)
         hit = {
             'rank': m.rank,
             'percent': m.percent,
-            'name': m.document.get_value(0),
-            'release': m.document.get_value(1),
             'pkg': m.document.get_value(2)
         }
         hit['pkg'] = eval(hit['pkg'])
+        [hit['pkg'].pop(k) for k in  hit['pkg'].keys()
+         if not index.remove_null(hit['pkg'][k] or '')]
         #hit['pkg'] = mirror.releases.get((hit['name'], hit['release']))
         from pprint import pformat
         results.append(pformat(hit))

File templates/index.html

View file
 
 
 {% if results %}
+<hr>
 <p>
-Search took {{ took }}ms (DB lookup takes much longer due to centidb
-alpha-quality code). Showing first {{ resultlen }} results of approximately {{
-estimated }}..
+Search took {{ took }}ms, showing first {{ resultlen }} results of
+approximately {{ estimated }}..
 </p>
 
 
 <pre>
 {% for hit in results %}
+{{ hit }}
 
-    {{ hit }}
-   
 {% endfor %}