def deprecated_db(self): """Returns the cutout dataabse, if this is deprecated""" db_name = os.path.join(self.dir, 'deprecated') if not os.path.exists(db_name): raise IOError("File does not exist: %r" % db_name) db = Database(db_name) return db
def db(self): """Returns the cutout database""" if self.is_deprecated: raise StorageDeprecated() db_name = os.path.join(self.dir, 'database') db = Database(db_name) return db
def load_users(dir, user_count, records, size, audience='example.com'): now = int(time.time()) for i in xrange(user_count): user = '******' % i if isinstance(records, tuple): rec = random.randint(*records) else: rec = records fn = os.path.join(dir, urllib.quote(audience, ''), urllib.quote(user, '') + '.db') db = Database(fn) items = [] for count in xrange(rec): if isinstance(size, tuple): s = random.randint(*size) else: s = size items.append('{"id": "item-%s-%s", "data": "%s"}' % (now, count, 'a'*s)) db.extend(items) sys.stdout.write('.') sys.stdout.flush() print 'done.'
def create_db(): db = Database(tmp_filename) db.clear() return db
def queue_db(self): """The queue cutout database""" db_name = os.path.join(self.dir, 'queue') db = Database(db_name) return db