'''
The class method scan_all() scans all binaries using multiple threads.
The number of binaries to be scanned can be limited with the limit
- argument.
+ argument. Returns the number of processed and remaining packages as a
+ dict.
'''
session = DBConn().session()
query = session.query(DBBinary).filter(DBBinary.contents == None)
+ remaining = query.count
if limit is not None:
query = query.limit(limit)
+ processed = query.count()
threadpool = ThreadPool()
for binary in query.yield_per(100):
threadpool.queueTask(ContentsScanner(binary).scan)
threadpool.joinAll()
+ remaining = remaining()
session.close()
+ return { 'processed': processed, 'remaining': remaining }
iso8859-1 encoding.
'''
fullpath = self.poolfile.fullpath
- debdata = Popen(['dpkg-deb', '--fsys-tarfile', fullpath],
- stdout = PIPE).stdout
- tar = TarFile.open(fileobj = debdata, mode = 'r|')
+ dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE)
+ tar = TarFile.open(fileobj = dpkg.stdout, mode = 'r|')
for member in tar.getmembers():
if member.isfile():
try:
name = member.name.decode('iso8859-1')
yield normpath(name)
tar.close()
- debdata.close()
+ dpkg.stdout.close()
+ dpkg.wait()
__all__.append('DBBinary')
connstr = "postgres:///%s" % cnf["DB::Name"]
if cnf["DB::Port"] and cnf["DB::Port"] != "-1":
connstr += "?port=%s" % cnf["DB::Port"]
-
- self.db_pg = create_engine(connstr, echo=self.debug)
+ if not cnf.has_key('DB::PoolSize'):
+ cnf['DB::PoolSize'] = '5'
+ if not cnf.has_key('DB::MaxOverflow'):
+ cnf['DB::MaxOverflow'] = '10'
+
+ self.db_pg = create_engine(connstr, echo=self.debug,
+ pool_size=int(cnf['DB::PoolSize']),
+ max_overflow=int(cnf['DB::MaxOverflow']))
self.db_meta = MetaData()
self.db_meta.bind = self.db_pg
self.db_smaker = sessionmaker(bind=self.db_pg,
self.otype['udeb'], self.comp['main'])
self.assertEqual('tests/fixtures/ftp/squeeze/main/Contents-i386.gz', \
cw.output_filename())
+ # test delete cascading
+ self.session.delete(self.binary['hello_2.2-1_i386'])
+ self.session.commit()
def test_scan_contents(self):
self.setup_binaries()