def __init__(self, section): self._config = Config(section=section) self._config.read(CONFIG_FILE) logging.debug("-------------------------------------------") logging.debug("Running section " + self._config.section) known_circular_depends = [] for kcd in self._config["known_circular_depends"].split(): known_circular_depends.append(kcd) #logging.debug("circular depends: " + kcd) logging.debug("Loading and parsing Packages file") logging.info("Fetching %s" % self._config["packages-url"]) packages_file = piupartslib.open_packages_url(self._config["packages-url"]) self._binary_db = piupartslib.packagesdb.PackagesDB() self._binary_db.read_packages_file(packages_file) self._binary_db.set_known_circular_depends(known_circular_depends) packages_file.close() if self._config["sources-url"]: logging.info("Fetching %s" % self._config["sources-url"]) sources_file = piupartslib.open_packages_url(self._config["sources-url"]) self._source_db = piupartslib.packagesdb.PackagesDB() self._source_db.read_packages_file(sources_file) sources_file.close()
def main(): # piuparts-master is always called by the slave with a section as argument if len(sys.argv) == 2: global_config = Config(section="global") global_config.read(CONFIG_FILE) master_directory = global_config["master-directory"] section = sys.argv[1] config = Config(section=section) config.read(CONFIG_FILE) setup_logging(logging.DEBUG, config["log-file"]) if not os.path.exists(os.path.join(master_directory, section)): os.makedirs(os.path.join(master_directory, section)) lock = open(os.path.join(master_directory, section, "master.lock"), "we") try: fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: print 'busy' sys.exit(1) logging.info("Fetching %s" % config["packages-url"]) packages_file = piupartslib.open_packages_url(config["packages-url"]) known_circular_depends = config["known_circular_depends"] m = Master(sys.stdin, sys.stdout, packages_file, known_circular_depends, section=section) while m.do_transaction(): pass packages_file.close() else: print 'piuparts-master needs to be called with a valid sectionname as argument, exiting...' sys.exit(1)
def load_packages_urls(self, urls, restrict_packages=None): for url in urls: logging.debug("Opening %s.*" % url) (url, stream) = piupartslib.open_packages_url(url) logging.debug("Fetching %s" % url) self._read_file(stream, restrict_packages=restrict_packages) stream.close() self._urllist.append(url)