import os.path
-class ContentsWriter(object):
+class BinaryContentsWriter(object):
'''
- ContentsWriter writes the Contents-$arch.gz files.
+ BinaryContentsWriter writes the Contents-$arch.gz files.
'''
def __init__(self, suite, architecture, overridetype, component = None):
- '''
- The constructor clones its arguments into a new session object to make
- sure that the new ContentsWriter object can be executed in a different
- thread.
- '''
self.suite = suite
self.architecture = architecture
self.overridetype = overridetype
os.chmod(temp_filename, 0664)
os.rename(temp_filename, final_filename)
+
+def generate_helper(suite_id, arch_id, overridetype_id, component_id = None):
+ '''
+ This function is called in a new subprocess.
+ '''
+ session = DBConn().session()
+ suite = Suite.get(suite_id, session)
+ architecture = Architecture.get(arch_id, session)
+ overridetype = OverrideType.get(overridetype_id, session)
+ log_message = [suite.suite_name, architecture.arch_string, overridetype.overridetype]
+ if component_id is None:
+ component = None
+ else:
+ component = Component.get(component_id, session)
+ log_message.append(component.component_name)
+ contents_writer = BinaryContentsWriter(suite, architecture, overridetype, component)
+ contents_writer.write_file()
+ return log_message
+
+class ContentsWriter(object):
+ '''
+ Loop over all suites, architectures, overridetypes, and components to write
+ all contents files.
+ '''
@classmethod
def log_result(class_, result):
'''
pool.join()
session.close()
-def generate_helper(suite_id, arch_id, overridetype_id, component_id = None):
- '''
- This function is called in a new subprocess.
- '''
- session = DBConn().session()
- suite = Suite.get(suite_id, session)
- architecture = Architecture.get(arch_id, session)
- overridetype = OverrideType.get(overridetype_id, session)
- log_message = [suite.suite_name, architecture.arch_string, overridetype.overridetype]
- if component_id is None:
- component = None
- else:
- component = Component.get(component_id, session)
- log_message.append(component.component_name)
- contents_writer = ContentsWriter(suite, architecture, overridetype, component)
- contents_writer.write_file()
- return log_message
-
class BinaryContentsScanner(object):
'''
from db_test import DBDakTestCase, fixture
from daklib.dbconn import *
-from daklib.contents import ContentsWriter, BinaryContentsScanner, \
+from daklib.contents import BinaryContentsWriter, BinaryContentsScanner, \
UnpackedSource, SourceContentsScanner
from os.path import normpath
self.assertEqual(self.override['hello_sid_main_udeb'], \
self.otype['udeb'].overrides.one())
- def test_contentswriter(self):
+ def test_binarycontentswriter(self):
'''
- Test the ContentsWriter class.
+ Test the BinaryContentsWriter class.
'''
self.setup_suites()
self.setup_architectures()
self.setup_overrides()
self.binary['hello_2.2-1_i386'].contents.append(BinContents(file = '/usr/bin/hello'))
self.session.commit()
- cw = ContentsWriter(self.suite['squeeze'], self.arch['i386'], self.otype['deb'])
+ cw = BinaryContentsWriter(self.suite['squeeze'], self.arch['i386'], self.otype['deb'])
self.assertEqual(['/usr/bin/hello python/hello\n'], \
cw.get_list())
# test formatline and sort order
# test output_filename
self.assertEqual('tests/fixtures/ftp/dists/squeeze/Contents-i386.gz', \
normpath(cw.output_filename()))
- cw = ContentsWriter(self.suite['squeeze'], self.arch['i386'], \
+ cw = BinaryContentsWriter(self.suite['squeeze'], self.arch['i386'], \
self.otype['udeb'], self.comp['main'])
self.assertEqual('tests/fixtures/ftp/dists/squeeze/main/Contents-i386.gz', \
normpath(cw.output_filename()))