From 8b6bc0232c7ada7dff955d5de6907e6b7d292ff0 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 20 Nov 2011 11:22:39 +0100 Subject: [PATCH] logging: Make own pakfire logger. This gives us the opportunity to import the pakfire module anywhere and to not interfere with other (root-)loggers then. --- po/pakfire.pot | 220 +++++++++++++------------- python/pakfire/actions.py | 24 +-- python/pakfire/base.py | 38 ++--- python/pakfire/builder.py | 46 +++--- python/pakfire/distro.py | 8 +- python/pakfire/downloader.py | 14 +- python/pakfire/logger.py | 10 +- python/pakfire/packages/base.py | 20 +-- python/pakfire/packages/file.py | 20 +-- python/pakfire/packages/lexer.py | 1 - python/pakfire/packages/make.py | 6 +- python/pakfire/packages/packager.py | 24 +-- python/pakfire/repository/__init__.py | 7 +- python/pakfire/repository/base.py | 12 +- python/pakfire/repository/database.py | 12 +- python/pakfire/repository/index.py | 20 +-- python/pakfire/repository/local.py | 6 +- python/pakfire/repository/remote.py | 8 +- python/pakfire/satsolver.py | 3 +- python/pakfire/server.py | 26 +-- python/pakfire/transaction.py | 33 ++-- python/pakfire/util.py | 10 +- 22 files changed, 303 insertions(+), 265 deletions(-) diff --git a/po/pakfire.pot b/po/pakfire.pot index 5cac680ae..c077ed507 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-11-14 15:36+0100\n" +"POT-Creation-Date: 2011-11-20 10:47+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,130 +17,134 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: ../python/pakfire/actions.py:148 +#: ../python/pakfire/actions.py:150 #, python-format msgid "Cannot run scriptlet because no interpreter is available: %s" msgstr "" -#: ../python/pakfire/actions.py:152 +#: ../python/pakfire/actions.py:154 #, python-format msgid "Cannot run scriptlet because the interpreter is not executable: %s" msgstr "" -#: ../python/pakfire/actions.py:191 +#: ../python/pakfire/actions.py:193 #, python-format msgid "" "The scriptlet returned an error:\n" "%s" msgstr "" -#: ../python/pakfire/actions.py:194 +#: ../python/pakfire/actions.py:196 #, python-format msgid "The scriptlet ran more than %s seconds and was killed." msgstr "" -#: ../python/pakfire/actions.py:249 ../python/pakfire/actions.py:287 -#: ../python/pakfire/actions.py:310 ../python/pakfire/actions.py:333 -#: ../python/pakfire/actions.py:350 ../python/pakfire/actions.py:369 +#: ../python/pakfire/actions.py:251 ../python/pakfire/actions.py:289 +#: ../python/pakfire/actions.py:312 ../python/pakfire/actions.py:335 +#: ../python/pakfire/actions.py:352 ../python/pakfire/actions.py:371 #, python-format msgid "Running transaction test for %s" msgstr "" -#: ../python/pakfire/actions.py:258 ../python/pakfire/actions.py:362 +#: ../python/pakfire/actions.py:260 ../python/pakfire/actions.py:364 msgid "Installing" msgstr "" -#: ../python/pakfire/actions.py:296 +#: ../python/pakfire/actions.py:298 msgid "Updating" msgstr "" -#: ../python/pakfire/actions.py:316 +#: ../python/pakfire/actions.py:318 msgid "Removing" msgstr "" #. Cleaning up leftover files and stuff. -#: ../python/pakfire/actions.py:340 +#: ../python/pakfire/actions.py:342 msgid "Cleanup" msgstr "" -#: ../python/pakfire/actions.py:378 +#: ../python/pakfire/actions.py:380 msgid "Downgrading" msgstr "" -#: ../python/pakfire/base.py:205 ../python/pakfire/base.py:235 -#: ../python/pakfire/base.py:281 ../python/pakfire/base.py:332 -#: ../python/pakfire/base.py:398 ../python/pakfire/base.py:437 -#: ../python/pakfire/base.py:490 ../python/pakfire/base.py:510 +#: ../python/pakfire/base.py:207 ../python/pakfire/base.py:237 +#: ../python/pakfire/base.py:283 ../python/pakfire/base.py:334 +#: ../python/pakfire/base.py:400 ../python/pakfire/base.py:439 +#: ../python/pakfire/base.py:492 ../python/pakfire/base.py:512 msgid "Nothing to do" msgstr "" -#: ../python/pakfire/base.py:267 +#: ../python/pakfire/base.py:269 msgid "There are no packages to install." msgstr "" -#: ../python/pakfire/base.py:322 +#: ../python/pakfire/base.py:324 #, python-format msgid "Could not find any installed package providing \"%s\"." msgstr "" -#: ../python/pakfire/base.py:328 +#: ../python/pakfire/base.py:330 #, python-format msgid "Multiple reinstall candidates for \"%s\": %s" msgstr "" -#: ../python/pakfire/base.py:357 +#: ../python/pakfire/base.py:359 #, python-format msgid "Could not find package %s in a remote repository." msgstr "" -#: ../python/pakfire/base.py:426 +#: ../python/pakfire/base.py:428 #, python-format msgid "Excluding %s." msgstr "" -#: ../python/pakfire/base.py:478 +#: ../python/pakfire/base.py:480 #, python-format msgid "\"%s\" package does not seem to be installed." msgstr "" -#: ../python/pakfire/base.py:622 +#: ../python/pakfire/base.py:624 msgid "Build command has failed." msgstr "" -#: ../python/pakfire/base.py:702 +#: ../python/pakfire/base.py:704 msgid "Everything is fine." msgstr "" -#: ../python/pakfire/builder.py:122 +#: ../python/pakfire/builder.py:124 msgid "Package information:" msgstr "" #. Copy the makefile and load source tarballs. -#: ../python/pakfire/builder.py:287 +#: ../python/pakfire/builder.py:289 msgid "Extracting" msgstr "" -#: ../python/pakfire/builder.py:547 +#: ../python/pakfire/builder.py:549 msgid "The build command failed. See logfile for details." msgstr "" #. Package the result. #. Make all these little package from the build environment. -#: ../python/pakfire/builder.py:693 +#: ../python/pakfire/builder.py:696 msgid "Creating packages:" msgstr "" #. Execute the buildscript of this stage. -#: ../python/pakfire/builder.py:713 +#: ../python/pakfire/builder.py:716 #, python-format msgid "Running stage %s:" msgstr "" -#: ../python/pakfire/builder.py:731 +#: ../python/pakfire/builder.py:734 #, python-format msgid "Could not remove static libraries: %s" msgstr "" +#: ../python/pakfire/builder.py:740 +msgid "Compressing man pages did not complete successfully." +msgstr "" + #: ../python/pakfire/cli.py:43 msgid "Pakfire command line interface." msgstr "" @@ -297,7 +301,7 @@ msgstr "" msgid "Give name of at least one package to check." msgstr "" -#: ../python/pakfire/cli.py:348 ../python/pakfire/transaction.py:345 +#: ../python/pakfire/cli.py:348 ../python/pakfire/transaction.py:344 msgid "Repository" msgstr "" @@ -412,12 +416,12 @@ msgid "Do not verify build dependencies." msgstr "" #: ../python/pakfire/compress.py:133 -#: ../python/pakfire/packages/packager.py:502 +#: ../python/pakfire/packages/packager.py:504 #, python-format msgid "Compressing %s" msgstr "" -#: ../python/pakfire/downloader.py:132 +#: ../python/pakfire/downloader.py:134 msgid "Downloading source files:" msgstr "" @@ -440,7 +444,7 @@ msgstr "" msgid "Running pakfire-build in a pakfire container?" msgstr "" -#: ../python/pakfire/errors.py:85 ../python/pakfire/transaction.py:410 +#: ../python/pakfire/errors.py:85 ../python/pakfire/transaction.py:409 msgid "Transaction test was not successful" msgstr "" @@ -449,326 +453,326 @@ msgstr "" msgid "%(commas)s and %(last)s" msgstr "" -#: ../python/pakfire/packages/base.py:97 +#: ../python/pakfire/packages/base.py:99 msgid "Name" msgstr "" -#: ../python/pakfire/packages/base.py:105 ../python/pakfire/transaction.py:344 +#: ../python/pakfire/packages/base.py:107 ../python/pakfire/transaction.py:343 msgid "Arch" msgstr "" -#: ../python/pakfire/packages/base.py:108 ../python/pakfire/transaction.py:344 +#: ../python/pakfire/packages/base.py:110 ../python/pakfire/transaction.py:343 msgid "Version" msgstr "" -#: ../python/pakfire/packages/base.py:109 +#: ../python/pakfire/packages/base.py:111 msgid "Release" msgstr "" -#: ../python/pakfire/packages/base.py:113 ../python/pakfire/transaction.py:345 +#: ../python/pakfire/packages/base.py:115 ../python/pakfire/transaction.py:344 msgid "Size" msgstr "" -#: ../python/pakfire/packages/base.py:117 +#: ../python/pakfire/packages/base.py:119 msgid "Repo" msgstr "" -#: ../python/pakfire/packages/base.py:120 +#: ../python/pakfire/packages/base.py:122 msgid "Summary" msgstr "" -#: ../python/pakfire/packages/base.py:121 +#: ../python/pakfire/packages/base.py:123 msgid "Groups" msgstr "" -#: ../python/pakfire/packages/base.py:122 +#: ../python/pakfire/packages/base.py:124 msgid "URL" msgstr "" -#: ../python/pakfire/packages/base.py:123 +#: ../python/pakfire/packages/base.py:125 msgid "License" msgstr "" -#: ../python/pakfire/packages/base.py:126 +#: ../python/pakfire/packages/base.py:128 msgid "Description" msgstr "" -#: ../python/pakfire/packages/base.py:133 +#: ../python/pakfire/packages/base.py:135 msgid "Maintainer" msgstr "" -#: ../python/pakfire/packages/base.py:135 +#: ../python/pakfire/packages/base.py:137 msgid "Vendor" msgstr "" -#: ../python/pakfire/packages/base.py:137 +#: ../python/pakfire/packages/base.py:139 msgid "UUID" msgstr "" -#: ../python/pakfire/packages/base.py:138 +#: ../python/pakfire/packages/base.py:140 msgid "Build ID" msgstr "" -#: ../python/pakfire/packages/base.py:139 +#: ../python/pakfire/packages/base.py:141 msgid "Build date" msgstr "" -#: ../python/pakfire/packages/base.py:140 +#: ../python/pakfire/packages/base.py:142 msgid "Build host" msgstr "" -#: ../python/pakfire/packages/base.py:142 +#: ../python/pakfire/packages/base.py:144 msgid "Provides" msgstr "" -#: ../python/pakfire/packages/base.py:147 +#: ../python/pakfire/packages/base.py:149 msgid "Pre-requires" msgstr "" -#: ../python/pakfire/packages/base.py:152 +#: ../python/pakfire/packages/base.py:154 msgid "Requires" msgstr "" -#: ../python/pakfire/packages/base.py:157 +#: ../python/pakfire/packages/base.py:159 msgid "Conflicts" msgstr "" -#: ../python/pakfire/packages/base.py:162 +#: ../python/pakfire/packages/base.py:164 msgid "Obsoletes" msgstr "" -#: ../python/pakfire/packages/base.py:170 +#: ../python/pakfire/packages/base.py:172 msgid "File" msgstr "" -#: ../python/pakfire/packages/base.py:359 +#: ../python/pakfire/packages/base.py:361 msgid "Not set" msgstr "" -#: ../python/pakfire/packages/base.py:498 +#: ../python/pakfire/packages/base.py:500 #, python-format msgid "Config file saved as %s." msgstr "" -#: ../python/pakfire/packages/file.py:95 +#: ../python/pakfire/packages/file.py:97 #, python-format msgid "Could not extract file: /%(src)s - %(dst)s" msgstr "" -#: ../python/pakfire/packages/file.py:145 +#: ../python/pakfire/packages/file.py:147 #, python-format msgid "Filename: %s" msgstr "" -#: ../python/pakfire/packages/file.py:254 +#: ../python/pakfire/packages/file.py:256 #, python-format msgid "File in archive is missing in file metadata: /%s. Skipping." msgstr "" -#: ../python/pakfire/packages/file.py:310 +#: ../python/pakfire/packages/file.py:312 #, python-format msgid "Config file created as %s" msgstr "" -#: ../python/pakfire/packages/file.py:324 +#: ../python/pakfire/packages/file.py:326 #, python-format msgid "Could not remove file: /%s" msgstr "" -#: ../python/pakfire/packages/make.py:75 +#: ../python/pakfire/packages/make.py:77 msgid "Package name is undefined." msgstr "" -#: ../python/pakfire/packages/make.py:78 +#: ../python/pakfire/packages/make.py:80 msgid "Package version is undefined." msgstr "" #. Load progressbar. -#: ../python/pakfire/packages/packager.py:340 +#: ../python/pakfire/packages/packager.py:342 msgid "Packaging" msgstr "" -#: ../python/pakfire/packages/packager.py:628 +#: ../python/pakfire/packages/packager.py:630 #, python-format msgid "Building source package %s:" msgstr "" -#: ../python/pakfire/repository/database.py:112 +#: ../python/pakfire/repository/database.py:114 msgid "The format of the database is not supported by this version of pakfire." msgstr "" -#: ../python/pakfire/repository/database.py:220 +#: ../python/pakfire/repository/database.py:222 #, python-format msgid "Cannot use database with version greater than %s." msgstr "" -#: ../python/pakfire/repository/database.py:222 +#: ../python/pakfire/repository/database.py:224 #, python-format msgid "Migrating database from format %s to %s." msgstr "" -#: ../python/pakfire/repository/index.py:229 +#: ../python/pakfire/repository/index.py:231 #, python-format msgid "" "I cannot be forced to re-download the metadata for the repository '%s' when " "running in offline mode." msgstr "" -#: ../python/pakfire/repository/index.py:279 +#: ../python/pakfire/repository/index.py:281 #, python-format msgid "%s: package database" msgstr "" #. Create progress bar. -#: ../python/pakfire/repository/index.py:367 +#: ../python/pakfire/repository/index.py:369 #, python-format msgid "Loading from %s" msgstr "" #. Add all packages from the database to the index. -#: ../python/pakfire/repository/index.py:424 +#: ../python/pakfire/repository/index.py:426 msgid "Loading installed packages" msgstr "" -#: ../python/pakfire/repository/remote.py:106 +#: ../python/pakfire/repository/remote.py:108 #, python-format msgid "Cannot download this file in offline mode: %s" msgstr "" -#: ../python/pakfire/satsolver.py:157 +#: ../python/pakfire/satsolver.py:158 msgid "The solver returned one problem:" msgstr "" #. Ask the user if he or she want to modify the request. If not, just exit. -#: ../python/pakfire/satsolver.py:173 +#: ../python/pakfire/satsolver.py:174 msgid "Do you want to manually alter the request?" msgstr "" -#: ../python/pakfire/satsolver.py:176 +#: ../python/pakfire/satsolver.py:177 msgid "You can now try to satisfy the solver by modifying your request." msgstr "" -#: ../python/pakfire/satsolver.py:181 +#: ../python/pakfire/satsolver.py:182 msgid "Which problem to you want to resolve?" msgstr "" -#: ../python/pakfire/satsolver.py:183 +#: ../python/pakfire/satsolver.py:184 msgid "Press enter to try to re-solve the request." msgstr "" -#: ../python/pakfire/satsolver.py:214 +#: ../python/pakfire/satsolver.py:215 #, python-format msgid " Solution: %s" msgstr "" -#: ../python/pakfire/satsolver.py:223 +#: ../python/pakfire/satsolver.py:224 msgid " Solutions:" msgstr "" -#: ../python/pakfire/transaction.py:89 +#: ../python/pakfire/transaction.py:91 #, python-format msgid "file %s from %s conflicts with file from package %s" msgstr "" -#: ../python/pakfire/transaction.py:95 +#: ../python/pakfire/transaction.py:97 #, python-format msgid "file %s from %s conflicts with files from %s" msgstr "" -#: ../python/pakfire/transaction.py:104 +#: ../python/pakfire/transaction.py:106 #, python-format msgid "" "There is not enough space left on %(name)s. Need at least %(size)s to " "perform transaction." msgstr "" -#: ../python/pakfire/transaction.py:281 +#: ../python/pakfire/transaction.py:283 #, python-format msgid "Not enough space to download %s of packages." msgstr "" -#: ../python/pakfire/transaction.py:284 +#: ../python/pakfire/transaction.py:286 msgid "Downloading packages:" msgstr "" -#: ../python/pakfire/transaction.py:344 +#: ../python/pakfire/transaction.py:343 msgid "Package" msgstr "" -#: ../python/pakfire/transaction.py:349 +#: ../python/pakfire/transaction.py:348 msgid "Installing:" msgstr "" -#: ../python/pakfire/transaction.py:350 +#: ../python/pakfire/transaction.py:349 msgid "Reinstalling:" msgstr "" -#: ../python/pakfire/transaction.py:351 +#: ../python/pakfire/transaction.py:350 msgid "Updating:" msgstr "" -#: ../python/pakfire/transaction.py:352 +#: ../python/pakfire/transaction.py:351 msgid "Downgrading:" msgstr "" -#: ../python/pakfire/transaction.py:353 +#: ../python/pakfire/transaction.py:352 msgid "Removing:" msgstr "" -#: ../python/pakfire/transaction.py:359 +#: ../python/pakfire/transaction.py:358 msgid "Transaction Summary" msgstr "" -#: ../python/pakfire/transaction.py:366 +#: ../python/pakfire/transaction.py:365 msgid "package" msgstr "" -#: ../python/pakfire/transaction.py:372 +#: ../python/pakfire/transaction.py:371 #, python-format msgid "Total download size: %s" msgstr "" -#: ../python/pakfire/transaction.py:376 +#: ../python/pakfire/transaction.py:375 #, python-format msgid "Installed size: %s" msgstr "" -#: ../python/pakfire/transaction.py:379 +#: ../python/pakfire/transaction.py:378 #, python-format msgid "Freed size: %s" msgstr "" -#: ../python/pakfire/transaction.py:388 +#: ../python/pakfire/transaction.py:387 msgid "Is this okay?" msgstr "" -#: ../python/pakfire/transaction.py:391 +#: ../python/pakfire/transaction.py:390 msgid "Running Transaction Test" msgstr "" -#: ../python/pakfire/transaction.py:403 +#: ../python/pakfire/transaction.py:402 msgid "Transaction Test Succeeded" msgstr "" -#: ../python/pakfire/transaction.py:421 +#: ../python/pakfire/transaction.py:420 msgid "Running transaction" msgstr "" -#: ../python/pakfire/util.py:66 +#: ../python/pakfire/util.py:68 #, python-format msgid "%s [y/N]" msgstr "" -#: ../python/pakfire/util.py:252 +#: ../python/pakfire/util.py:254 msgid "Killing orphans..." msgstr "" -#: ../python/pakfire/util.py:259 +#: ../python/pakfire/util.py:261 #, python-format msgid "Process ID %s is still running in chroot. Killing..." msgstr "" -#: ../python/pakfire/util.py:271 +#: ../python/pakfire/util.py:273 msgid "Waiting for processes to terminate..." msgstr "" diff --git a/python/pakfire/actions.py b/python/pakfire/actions.py index 72b0aa35b..e8bb69638 100644 --- a/python/pakfire/actions.py +++ b/python/pakfire/actions.py @@ -19,13 +19,15 @@ # # ############################################################################### -import logging import os import chroot import packages import util +import logging +log = logging.getLogger("pakfire") + from constants import * from i18n import _ @@ -97,7 +99,7 @@ class Action(object): args = { "cwd" : cwd, - "logger" : logging.getLogger(), + "logger" : log, "personality" : self.pakfire.distro.personality, "shell" : False, "timeout" : SCRIPTLET_TIMEOUT, @@ -139,7 +141,7 @@ class ActionScript(Action): return # Actually run the scriplet. - logging.debug("Running scriptlet %s" % self) + log.debug("Running scriptlet %s" % self) # Check if the interpreter does exist and is executable. if self.interpreter: @@ -199,7 +201,7 @@ class ActionScript(Action): try: os.unlink(script_file) except OSError: - logging.debug("Could not remove scriptlet file: %s" % script_file) + log.debug("Could not remove scriptlet file: %s" % script_file) class ActionScriptPreIn(ActionScript): @@ -246,7 +248,7 @@ class ActionInstall(Action): type = "install" def check(self, check): - logging.debug(_("Running transaction test for %s") % self.pkg.friendly_name) + log.debug(_("Running transaction test for %s") % self.pkg.friendly_name) # Check if this package can be installed. check.install(self.pkg) @@ -277,14 +279,14 @@ class ActionInstall(Action): self.do(LDCONFIG) else: - logging.debug("ldconfig is not present or not executable.") + log.debug("ldconfig is not present or not executable.") class ActionUpdate(Action): type = "upgrade" def check(self, check): - logging.debug(_("Running transaction test for %s") % self.pkg.friendly_name) + log.debug(_("Running transaction test for %s") % self.pkg.friendly_name) # Check if this package can be updated. check.update(self.pkg) @@ -307,7 +309,7 @@ class ActionRemove(Action): assert self.pkg def check(self, check): - logging.debug(_("Running transaction test for %s") % self.pkg.friendly_name) + log.debug(_("Running transaction test for %s") % self.pkg.friendly_name) # Check if this package can be removed. check.remove(self.pkg) @@ -330,7 +332,7 @@ class ActionCleanup(Action): assert self.pkg def check(self, check): - logging.debug(_("Running transaction test for %s") % self.pkg.friendly_name) + log.debug(_("Running transaction test for %s") % self.pkg.friendly_name) # Check if this package can be removed. check.cleanup(self.pkg) @@ -347,7 +349,7 @@ class ActionReinstall(Action): type = "reinstall" def check(self, check): - logging.debug(_("Running transaction test for %s") % self.pkg.friendly_name) + log.debug(_("Running transaction test for %s") % self.pkg.friendly_name) # Check if this package can be reinstalled. check.remove(self.pkg) @@ -366,7 +368,7 @@ class ActionDowngrade(Action): type = "downgrade" def check(self, check): - logging.debug(_("Running transaction test for %s") % self.pkg.friendly_name) + log.debug(_("Running transaction test for %s") % self.pkg.friendly_name) # Check if this package can be downgraded. check.install(self.pkg) diff --git a/python/pakfire/base.py b/python/pakfire/base.py index aec3d7372..cde5992e0 100644 --- a/python/pakfire/base.py +++ b/python/pakfire/base.py @@ -19,7 +19,6 @@ # # ############################################################################### -import logging import os import random import string @@ -36,6 +35,9 @@ import satsolver import transaction import util +import logging +log = logging.getLogger("pakfire") + from constants import * from i18n import _ @@ -202,11 +204,11 @@ class Pakfire(object): if t: t.dump() else: - logging.info(_("Nothing to do")) + log.info(_("Nothing to do")) def install(self, requires, interactive=True, logger=None, **kwargs): if not logger: - logger = logging.getLogger() + logger = logging.getLogger("pakfire") # Create a new request. request = self.create_request() @@ -232,7 +234,7 @@ class Pakfire(object): if not interactive: raise DependencyError - logging.info(_("Nothing to do")) + log.info(_("Nothing to do")) return if interactive: @@ -264,7 +266,7 @@ class Pakfire(object): # Break if no packages were added at all. if not len(repo): - logging.critical(_("There are no packages to install.")) + log.critical(_("There are no packages to install.")) return # Create a new request that installs all solvables from the @@ -278,7 +280,7 @@ class Pakfire(object): # If solving was not possible, we exit here. if not t: - logging.info(_("Nothing to do")) + log.info(_("Nothing to do")) return if yes is None: @@ -319,17 +321,17 @@ class Pakfire(object): _pkgs.append(pkg) if not _pkgs: - logging.warning(_("Could not find any installed package providing \"%s\".") \ + log.warning(_("Could not find any installed package providing \"%s\".") \ % pattern) elif len(_pkgs) == 1: reinstall_pkgs.append(_pkgs[0]) #t.add("reinstall", _pkgs[0]) else: - logging.warning(_("Multiple reinstall candidates for \"%s\": %s") \ + log.warning(_("Multiple reinstall candidates for \"%s\": %s") \ % (pattern, ", ".join(p.friendly_name for p in sorted(_pkgs)))) if not reinstall_pkgs: - logging.info(_("Nothing to do")) + log.info(_("Nothing to do")) return # Packages we want to replace. @@ -354,7 +356,7 @@ class Pakfire(object): _pkgs.append(_pkg) if not _pkgs: - logging.warning(_("Could not find package %s in a remote repository.") % \ + log.warning(_("Could not find package %s in a remote repository.") % \ pkg.friendly_name) else: # Sort packages to reflect repository priorities, etc... @@ -395,7 +397,7 @@ class Pakfire(object): t.sort() if not t: - logging.info(_("Nothing to do")) + log.info(_("Nothing to do")) return if not t.cli_yesno(): @@ -423,7 +425,7 @@ class Pakfire(object): # Exclude packages that should not be updated. if excludes: for exclude in excludes: - logging.info(_("Excluding %s.") % exclude) + log.info(_("Excluding %s.") % exclude) exclude = self.create_relation(exclude) request.lock(exclude) @@ -434,7 +436,7 @@ class Pakfire(object): allow_archchange=allow_archchange) if not t: - logging.info(_("Nothing to do")) + log.info(_("Nothing to do")) # If we are running in check mode, we return a non-zero value to # indicate, that there are no updates. @@ -475,7 +477,7 @@ class Pakfire(object): best = pkg if best is None: - logging.warning(_("\"%s\" package does not seem to be installed.") % pattern) + log.warning(_("\"%s\" package does not seem to be installed.") % pattern) else: rel = self.create_relation("%s<%s" % (best.name, best.friendly_version)) request.install(rel) @@ -487,7 +489,7 @@ class Pakfire(object): allow_archchange=allow_archchange) if not t: - logging.info(_("Nothing to do")) + log.info(_("Nothing to do")) return if not t.cli_yesno(): @@ -507,7 +509,7 @@ class Pakfire(object): t = solver.solve(request, uninstall=True) if not t: - logging.info(_("Nothing to do")) + log.info(_("Nothing to do")) return # Ask the user if okay. @@ -675,7 +677,7 @@ class Pakfire(object): return [r for r in self.repos] def clean_all(self): - logging.debug("Cleaning up everything...") + log.debug("Cleaning up everything...") # Clean up repository caches. self.repos.clean() @@ -699,7 +701,7 @@ class Pakfire(object): uninstall=uninstall) if not t: - logging.info(_("Everything is fine.")) + log.info(_("Everything is fine.")) return # Ask the user if okay. diff --git a/python/pakfire/builder.py b/python/pakfire/builder.py index 49cd19aba..5beccdc86 100644 --- a/python/pakfire/builder.py +++ b/python/pakfire/builder.py @@ -21,7 +21,6 @@ import fcntl import grp -import logging import math import os import re @@ -38,6 +37,9 @@ import packages.packager import repository import util +import logging +log = logging.getLogger("pakfire") + from constants import * from i18n import _ from errors import BuildError, BuildRootLocked, Error @@ -96,7 +98,7 @@ class BuildEnviron(object): h.setFormatter(f) else: # If no logile was given, we use the root logger. - self.log = logging.getLogger() + self.log = logging.getLogger("pakfire") # Log information about pakfire and some more information, when we # are running in release mode. @@ -217,7 +219,7 @@ class BuildEnviron(object): if not os.path.exists(dir_in): os.makedirs(dir_in) - logging.debug("%s --> %s" % (file_out, file_in)) + self.log.debug("%s --> %s" % (file_out, file_in)) shutil.copy2(file_out, file_in) @@ -234,7 +236,7 @@ class BuildEnviron(object): if not os.path.exists(dir_out): os.makedirs(dir_out) - logging.debug("%s --> %s" % (file_in, file_out)) + self.log.debug("%s --> %s" % (file_in, file_out)) shutil.copy2(file_in, file_out) @@ -362,7 +364,7 @@ class BuildEnviron(object): self.copyin(i, i) def _create_node(self, filename, mode, device): - logging.debug("Create node: %s (%s)" % (filename, mode)) + self.log.debug("Create node: %s (%s)" % (filename, mode)) filename = self.chrootPath(filename) @@ -374,13 +376,13 @@ class BuildEnviron(object): os.mknod(filename, mode, device) def destroy(self): - logging.debug("Destroying environment %s" % self.path) + self.log.debug("Destroying environment %s" % self.path) if os.path.exists(self.path): util.rm(self.path) def cleanup(self): - logging.debug("Cleaning environemnt.") + self.log.debug("Cleaning environemnt.") # Remove the build directory and buildroot. dirs = ("build", "result") @@ -502,9 +504,9 @@ class BuildEnviron(object): if kwargs.has_key("env"): env.update(kwargs.pop("env")) - logging.debug("Environment:") + self.log.debug("Environment:") for k, v in sorted(env.items()): - logging.debug(" %s=%s" % (k, v)) + self.log.debug(" %s=%s" % (k, v)) # Update personality it none was set if not personality: @@ -555,7 +557,7 @@ class BuildEnviron(object): def shell(self, args=[]): if not util.cli_is_interactive(): - logging.warning("Cannot run shell on non-interactive console.") + self.log.warning("Cannot run shell on non-interactive console.") return # Install all packages that are needed to run a shell. @@ -575,7 +577,7 @@ class BuildEnviron(object): # Empty the environment command = "env -i - %s" % command - logging.debug("Shell command: %s" % command) + self.log.debug("Shell command: %s" % command) shell = os.system(command) return os.WEXITSTATUS(shell) @@ -618,9 +620,9 @@ class Builder(object): def do(self, command, shell=True, personality=None, cwd=None, *args, **kwargs): # Environment variables - logging.debug("Environment:") + log.debug("Environment:") for k, v in sorted(self.environ.items()): - logging.debug(" %s=%s" % (k, v)) + log.debug(" %s=%s" % (k, v)) # Update personality it none was set if not personality: @@ -639,7 +641,7 @@ class Builder(object): personality=personality, shell=False, env=self.environ, - logger=logging.getLogger(), + logger=logging.getLogger("pakfire"), cwd=cwd, *args, **kwargs @@ -691,27 +693,27 @@ class Builder(object): # Package the result. # Make all these little package from the build environment. - logging.info(_("Creating packages:")) + log.info(_("Creating packages:")) pkgs = [] for pkg in reversed(self.pkg.packages): packager = packages.packager.BinaryPackager(self.pakfire, pkg, self, self.buildroot) pkg = packager.run(self.resultdir) pkgs.append(pkg) - logging.info("") + log.info("") for pkg in sorted(pkgs): for line in pkg.dump(long=True).splitlines(): - logging.info(line) - logging.info("") - logging.info("") + log.info(line) + log.info("") + log.info("") def build_stage(self, stage): # Get the buildscript for this stage. buildscript = self.create_buildscript(stage) # Execute the buildscript of this stage. - logging.info(_("Running stage %s:") % stage) + log.info(_("Running stage %s:") % stage) try: self.do(buildscript, shell=False) @@ -729,13 +731,13 @@ class Builder(object): self.do("%s/remove-static-libs %s %s" % \ (SCRIPT_DIR, self.buildroot, " ".join(keep_libs))) except Error, e: - logging.warning(_("Could not remove static libraries: %s") % e) + log.warning(_("Could not remove static libraries: %s") % e) def post_compress_man_pages(self): try: self.do("%s/compress-man-pages %s" % (SCRIPT_DIR, self.buildroot)) except Error, e: - logging.warning(_("Compressing man pages did not complete successfully.")) + log.warning(_("Compressing man pages did not complete successfully.")) def cleanup(self): if os.path.exists(self.buildroot): diff --git a/python/pakfire/distro.py b/python/pakfire/distro.py index 96eb6194f..41e68704f 100644 --- a/python/pakfire/distro.py +++ b/python/pakfire/distro.py @@ -19,10 +19,12 @@ # # ############################################################################### -import logging import os import re +import logging +log = logging.getLogger("pakfire") + from errors import ConfigError from repository import Repositories @@ -52,13 +54,13 @@ class Distribution(object): return self.pakfire.config def dump(self): - logging.debug("Distribution configuration:") + log.debug("Distribution configuration:") attrs = ("name", "version", "release", "sname", "dist", "vendor", "arch", "machine", "source_dl",) for attr in attrs: - logging.debug(" %s : %s" % (attr, getattr(self, attr))) + log.debug(" %s : %s" % (attr, getattr(self, attr))) def update(self, config): if not config: diff --git a/python/pakfire/downloader.py b/python/pakfire/downloader.py index 93f23136b..3659de72c 100644 --- a/python/pakfire/downloader.py +++ b/python/pakfire/downloader.py @@ -20,10 +20,12 @@ ############################################################################### import json -import logging import os import random +import logging +log = logging.getLogger("pakfire") + from config import Config from urlgrabber.grabber import URLGrabber, URLGrabError @@ -57,7 +59,7 @@ class PakfireGrabber(URLGrabber): try: bandwidth_throttle = int(bandwidth_throttle) except ValueError: - logging.error("Configuration value for bandwidth_throttle is invalid.") + log.error("Configuration value for bandwidth_throttle is invalid.") bandwidth_throttle = 0 kwargs.update({ "throttle" : bandwidth_throttle }) @@ -129,7 +131,7 @@ class SourceDownloader(object): download_files.append(filename) if download_files: - logging.info(_("Downloading source files:")) + log.info(_("Downloading source files:")) # Create source download directory. if not os.path.exists(SOURCE_CACHE_DIR): @@ -141,7 +143,7 @@ class SourceDownloader(object): except URLGrabError, e: raise DownloadError, "%s %s" % (os.path.basename(filename), e) - logging.info("") + log.info("") return existant_files + download_files @@ -186,7 +188,7 @@ class MirrorList(object): if self.pakfire.offline: return - logging.debug("Updating mirrorlist for repository '%s' (force=%s)" % (self.repo.name, force)) + log.debug("Updating mirrorlist for repository '%s' (force=%s)" % (self.repo.name, force)) cache_filename = "mirrors/mirrorlist" @@ -208,7 +210,7 @@ class MirrorList(object): try: mirrordata = g.urlread(self.mirrorlist, limit=MIRRORLIST_MAXSIZE) except URLGrabError, e: - logging.warning("Could not update the mirrorlist for repo '%s': %s" % (self.repo.name, e)) + log.warning("Could not update the mirrorlist for repo '%s': %s" % (self.repo.name, e)) return # XXX check for empty files or damaged output diff --git a/python/pakfire/logger.py b/python/pakfire/logger.py index ac453c28d..ea3cb6140 100644 --- a/python/pakfire/logger.py +++ b/python/pakfire/logger.py @@ -19,18 +19,20 @@ # # ############################################################################### -import logging import time +import logging +log = logging.getLogger("pakfire") + def setup_logging(config=None): """ This function initialized the logger that is enabled immediately. """ - - l = logging.getLogger() + l = logging.getLogger("pakfire") + l.propagate = 0 if len(l.handlers) > 1: - logging.debug("Logging was already set up. Don't do this again.") + l.debug("Logging was already set up. Don't do this again.") return # Remove all previous defined handlers. diff --git a/python/pakfire/packages/base.py b/python/pakfire/packages/base.py index 7cbaacdf2..877aff2a0 100644 --- a/python/pakfire/packages/base.py +++ b/python/pakfire/packages/base.py @@ -20,11 +20,13 @@ ############################################################################### import datetime -import logging import os import shutil import xml.sax.saxutils +import logging +log = logging.getLogger("pakfire") + import pakfire.util as util from pakfire.constants import * @@ -48,7 +50,7 @@ class Package(object): # If UUIDs match, the packages are absolutely equal. if self.uuid == other.uuid: - #logging.debug("%s is equal to %s by UUID" % (self, other)) + #log.debug("%s is equal to %s by UUID" % (self, other)) return 0 ret = util.version_compare(self.pakfire.pool, @@ -71,11 +73,11 @@ class Package(object): ret = cmp(self.build_time, other.build_time) #if ret == 0: - # logging.debug("%s is equal to %s" % (self, other)) + # log.debug("%s is equal to %s" % (self, other)) #elif ret < 0: - # logging.debug("%s is more recent than %s" % (other, self)) + # log.debug("%s is more recent than %s" % (other, self)) #elif ret > 0: - # logging.debug("%s is more recent than %s" % (self, other)) + # log.debug("%s is more recent than %s" % (self, other)) # If no rank could be created, sort by repository priority if not ret: @@ -472,7 +474,7 @@ class Package(object): i += 1 pb.update(i) - logging.debug("Removing file: %s" % _file) + log.debug("Removing file: %s" % _file) if prefix: file = os.path.join(prefix, _file.name[1:]) @@ -503,7 +505,7 @@ class Package(object): try: os.remove(file) except OSError: - logging.error("Cannot remove file: %s. Remove manually." % _file) + log.error("Cannot remove file: %s. Remove manually." % _file) # Handle directories. # Skip removal if the directory is a mountpoint. @@ -517,10 +519,10 @@ class Package(object): # Log all unhandled types. else: - logging.warning("Cannot remove file: %s. Filetype is unhandled." % file) + log.warning("Cannot remove file: %s. Filetype is unhandled." % file) if pb: pb.finish() for msg in messages: - logging.warning(msg) + log.warning(msg) diff --git a/python/pakfire/packages/file.py b/python/pakfire/packages/file.py index 979dcfa6c..91c44382e 100644 --- a/python/pakfire/packages/file.py +++ b/python/pakfire/packages/file.py @@ -20,13 +20,15 @@ ############################################################################### import hashlib -import logging import os import re import shutil import tarfile import tempfile +import logging +log = logging.getLogger("pakfire") + import pakfire.filelist import pakfire.util as util import pakfire.compress as compress @@ -60,7 +62,7 @@ class InnerTarFile(tarfile.TarFile): # Save capabilities. caps = util.get_capabilities(name) if caps: - logging.debug("Saving capabilities for %s: %s" % (name, caps)) + log.debug("Saving capabilities for %s: %s" % (name, caps)) tarinfo.pax_headers["PAKFIRE.capabilities"] = caps # Append the tar header and data to the archive. @@ -92,7 +94,7 @@ class InnerTarFile(tarfile.TarFile): try: tarfile.TarFile.extract(self, member, path) except OSError, e: - logging.warning(_("Could not extract file: /%(src)s - %(dst)s") \ + log.warning(_("Could not extract file: /%(src)s - %(dst)s") \ % { "src" : member.name, "dst" : e, }) if path: @@ -103,7 +105,7 @@ class InnerTarFile(tarfile.TarFile): # ...and then apply the capabilities. caps = member.pax_headers.get("PAKFIRE.capabilities", None) if caps: - logging.debug("Restoring capabilities for /%s: %s" % (member.name, caps)) + log.debug("Restoring capabilities for /%s: %s" % (member.name, caps)) util.set_capabilities(target, caps) @@ -184,7 +186,7 @@ class FilePackage(Package): return tarfile.open(self.filename, format=tarfile.PAX_FORMAT) def extract(self, message=None, prefix=None): - logging.debug("Extracting package %s" % self.friendly_name) + log.debug("Extracting package %s" % self.friendly_name) if prefix is None: prefix = "" @@ -199,7 +201,7 @@ class FilePackage(Package): payload = archive.extractfile("data.img") # Decompress the payload if needed. - logging.debug("Compression: %s" % self.payload_compression) + log.debug("Compression: %s" % self.payload_compression) # Create a temporary file to store the decompressed output. garbage, tempf = tempfile.mkstemp(prefix="pakfire") @@ -251,7 +253,7 @@ class FilePackage(Package): for member in members: file = name2file.get("/%s" % member.name, None) if not file: - logging.warning(_("File in archive is missing in file metadata: /%s. Skipping.") % member.name) + log.warning(_("File in archive is missing in file metadata: /%s. Skipping.") % member.name) continue # Update progress. @@ -332,7 +334,7 @@ class FilePackage(Package): # msg += "/%s link to /%s" % (member.name, member.linkname) # else: # msg += "/%s" % member.name - # logging.debug(msg) + # log.debug(msg) payload_archive.extract(member, path=prefix) @@ -349,7 +351,7 @@ class FilePackage(Package): # Print messages. for msg in messages: - logging.warning(msg) + log.warning(msg) @property def metadata(self): diff --git a/python/pakfire/packages/lexer.py b/python/pakfire/packages/lexer.py index 06f066cdc..1bfcaacd6 100644 --- a/python/pakfire/packages/lexer.py +++ b/python/pakfire/packages/lexer.py @@ -1,6 +1,5 @@ #!/usr/bin/python -import logging import os import re diff --git a/python/pakfire/packages/make.py b/python/pakfire/packages/make.py index 308dcab57..b999e58f4 100644 --- a/python/pakfire/packages/make.py +++ b/python/pakfire/packages/make.py @@ -19,7 +19,6 @@ # # ############################################################################### -import logging import os import re import shutil @@ -32,6 +31,9 @@ from urlgrabber.progress import TextMeter import lexer import packager +import logging +log = logging.getLogger("pakfire") + import pakfire.chroot as chroot import pakfire.downloader as downloader import pakfire.util as util @@ -325,7 +327,7 @@ class Makefile(MakefileBase): pb.update(i) _f = f[dir_len:] - logging.debug("%s/%s" % (prefix, _f)) + log.debug("%s/%s" % (prefix, _f)) path = "%s/%s" % (prefix, _f) diff --git a/python/pakfire/packages/packager.py b/python/pakfire/packages/packager.py index 818a438ef..b361077bc 100644 --- a/python/pakfire/packages/packager.py +++ b/python/pakfire/packages/packager.py @@ -23,7 +23,6 @@ import collections import fnmatch import glob import hashlib -import logging import lzma import os import progressbar @@ -36,6 +35,9 @@ import time import uuid import zlib +import logging +log = logging.getLogger("pakfire") + import pakfire.compress import pakfire.util as util @@ -57,7 +59,7 @@ class Packager(object): if not os.path.exists(file): continue - logging.debug("Removing tmpfile: %s" % file) + log.debug("Removing tmpfile: %s" % file) if os.path.isdir(file): util.rm(file) @@ -119,7 +121,7 @@ class Packager(object): if not arcname: arcname = os.path.basename(filename) - logging.debug("Adding %s (as %s) to tarball." % (filename, arcname)) + log.debug("Adding %s (as %s) to tarball." % (filename, arcname)) self.files.append((arcname, filename)) def create_package_format(self): @@ -138,7 +140,7 @@ class Packager(object): datafile = InnerTarFile(datafile) for m in datafile.getmembers(): - logging.debug(" %s %-8s %-8s %s %6s %s" % \ + log.debug(" %s %-8s %-8s %s %6s %s" % \ (tarfile.filemode(m.mode), m.uname, m.gname, "%d-%02d-%02d %02d:%02d:%02d" % time.localtime(m.mtime)[:6], util.format_size(m.size), m.name)) @@ -170,7 +172,7 @@ class Packager(object): f.write("\n") - logging.info("") + log.info("") datafile.close() f.close() @@ -320,7 +322,7 @@ class BinaryPackager(Packager): # Skip orphan directories. if file in orphan_directories and not os.listdir(file): - logging.debug("Found an orphaned directory: %s" % file) + log.debug("Found an orphaned directory: %s" % file) continue files.append(file) @@ -543,7 +545,7 @@ class BinaryPackager(Packager): os.makedirs(resultdir) resultfile = os.path.join(resultdir, self.pkg.package_filename) - logging.info("Saving package to %s" % resultfile) + log.info("Saving package to %s" % resultfile) try: os.link(tempfile, resultfile) except OSError: @@ -625,7 +627,7 @@ class SourcePackager(Packager): def run(self, resultdirs=[]): assert resultdirs - logging.info(_("Building source package %s:") % self.pkg.package_filename) + log.info(_("Building source package %s:") % self.pkg.package_filename) # Add datafile to package. datafile = self.create_datafile() @@ -656,7 +658,7 @@ class SourcePackager(Packager): os.makedirs(resultdir) resultfile = os.path.join(resultdir, self.pkg.package_filename) - logging.info("Saving package to %s" % resultfile) + log.info("Saving package to %s" % resultfile) try: os.link(tempfile, resultfile) except OSError: @@ -665,5 +667,5 @@ class SourcePackager(Packager): # Dump package information. pkg = SourcePackage(self.pakfire, self.pakfire.repos.dummy, tempfile) for line in pkg.dump(long=True).splitlines(): - logging.info(line) - logging.info("") + log.info(line) + log.info("") diff --git a/python/pakfire/repository/__init__.py b/python/pakfire/repository/__init__.py index 283ff7f54..f99d6ee50 100644 --- a/python/pakfire/repository/__init__.py +++ b/python/pakfire/repository/__init__.py @@ -20,6 +20,7 @@ ############################################################################### import logging +log = logging.getLogger("pakfire") import pakfire.packages as packages @@ -116,7 +117,7 @@ class Repositories(object): try: del self.__repos[repo.name] except KeyError: - logging.debug("Repository that was to be removed does not exist: %s" % repo.name) + log.debug("Repository that was to be removed does not exist: %s" % repo.name) def get_repo(self, name): """ @@ -141,7 +142,7 @@ class Repositories(object): pass def update(self, force=False, offline=False): - logging.debug("Updating all repository indexes (force=%s)" % force) + log.debug("Updating all repository indexes (force=%s)" % force) # update all indexes if necessary or forced for repo in self: @@ -154,7 +155,7 @@ class Repositories(object): yield packages.SolvPackage(self.pakfire, solv) def clean(self): - logging.info("Cleaning up all repository caches...") + log.info("Cleaning up all repository caches...") for repo in self: repo.clean() diff --git a/python/pakfire/repository/base.py b/python/pakfire/repository/base.py index 241fc3ec0..56ece2ea1 100644 --- a/python/pakfire/repository/base.py +++ b/python/pakfire/repository/base.py @@ -21,9 +21,11 @@ import fnmatch import glob -import logging import re +import logging +log = logging.getLogger("pakfire") + import cache import pakfire.packages as packages import pakfire.satsolver as satsolver @@ -38,7 +40,7 @@ class RepositoryFactory(object): self.solver_repo = satsolver.Repo(self.pool, self.name) self.solver_repo.set_priority(self.priority) - logging.debug("Initialized new repository: %s" % self) + log.debug("Initialized new repository: %s" % self) # Create an cache object self.cache = cache.RepositoryCache(self.pakfire, self) @@ -76,9 +78,9 @@ class RepositoryFactory(object): self.solver_repo.set_enabled(val) if val: - logging.debug("Enabled repository '%s'." % self.name) + log.debug("Enabled repository '%s'." % self.name) else: - logging.debug("Disabled repository '%s'." % self.name) + log.debug("Disabled repository '%s'." % self.name) enabled = property(get_enabled, set_enabled) @@ -119,7 +121,7 @@ class RepositoryFactory(object): """ Cleanup all temporary files of this repository. """ - logging.info("Cleaning up repository '%s'..." % self.name) + log.info("Cleaning up repository '%s'..." % self.name) self.cache.destroy() assert self.index diff --git a/python/pakfire/repository/database.py b/python/pakfire/repository/database.py index fb548497b..8c23ec57d 100644 --- a/python/pakfire/repository/database.py +++ b/python/pakfire/repository/database.py @@ -19,13 +19,15 @@ # # ############################################################################### -import logging import os import random import shutil import sqlite3 import time +import logging +log = logging.getLogger("pakfire") + import pakfire.packages as packages from pakfire.constants import * @@ -59,7 +61,7 @@ class Database(object): def open(self): if self._db is None: - logging.debug("Open database %s" % self.filename) + log.debug("Open database %s" % self.filename) dirname = os.path.dirname(self.filename) if not os.path.exists(dirname): @@ -219,7 +221,7 @@ class DatabaseLocal(Database): if self.format > DATABASE_FORMAT: raise DatabaseError, _("Cannot use database with version greater than %s.") % DATABASE_FORMAT - logging.info(_("Migrating database from format %s to %s.") % (self.format, DATABASE_FORMAT)) + log.info(_("Migrating database from format %s to %s.") % (self.format, DATABASE_FORMAT)) # Get a database cursor. c = self.cursor() @@ -246,7 +248,7 @@ class DatabaseLocal(Database): c.close() def add_package(self, pkg, reason=None): - logging.debug("Adding package to database: %s" % pkg.friendly_name) + log.debug("Adding package to database: %s" % pkg.friendly_name) c = self.cursor() @@ -323,7 +325,7 @@ class DatabaseLocal(Database): c.close() def rem_package(self, pkg): - logging.debug("Removing package from database: %s" % pkg.friendly_name) + log.debug("Removing package from database: %s" % pkg.friendly_name) assert pkg.uuid diff --git a/python/pakfire/repository/index.py b/python/pakfire/repository/index.py index 7e0df1aae..a73fa76a9 100644 --- a/python/pakfire/repository/index.py +++ b/python/pakfire/repository/index.py @@ -19,9 +19,11 @@ # # ############################################################################### -import logging import os +import logging +log = logging.getLogger("pakfire") + import database import metadata @@ -87,12 +89,12 @@ class Index(object): def add_package(self, pkg): # XXX Skip packages without a UUID #if not pkg.uuid: - # logging.warning("Skipping package which lacks UUID: %s" % pkg) + # log.warning("Skipping package which lacks UUID: %s" % pkg) # return if not pkg.build_time: return - logging.debug("Adding package to index %s: %s" % (self, pkg)) + log.debug("Adding package to index %s: %s" % (self, pkg)) solvable = satsolver.Solvable(self.solver_repo, pkg.name, pkg.friendly_version, pkg.arch) @@ -209,7 +211,7 @@ class IndexSolv(Index): age = self.cache.age(filename) if age and age < TIME_10M: download = False - logging.debug("Metadata is recent enough. I don't download it again.") + log.debug("Metadata is recent enough. I don't download it again.") # Open old metadata for comparison. old_metadata = metadata.Metadata(self.pakfire, self, @@ -233,7 +235,7 @@ class IndexSolv(Index): # We are supposed to download new metadata, but we are running in # offline mode. That's okay. Just doing nothing. if not offline: - logging.debug("Going to (re-)download the repository metadata.") + log.debug("Going to (re-)download the repository metadata.") # Initialize a grabber for download. grabber = downloader.MetadataDownloader(self.pakfire) @@ -245,7 +247,7 @@ class IndexSolv(Index): new_metadata = metadata.Metadata(self.pakfire, self, metadata=data) if old_metadata and new_metadata < old_metadata: - logging.warning("The downloaded metadata was less recent than the current one. Trashing that.") + log.warning("The downloaded metadata was less recent than the current one. Trashing that.") else: # We explicitely rewrite the metadata if it is equal to have @@ -331,7 +333,7 @@ class IndexDir(Index): return path def update(self, force=False, offline=False): - logging.debug("Updating repository index '%s' (force=%s)" % (self.path, force)) + log.debug("Updating repository index '%s' (force=%s)" % (self.path, force)) # Do nothing if the update is not forced but populate the database # if no packages are present. @@ -342,7 +344,7 @@ class IndexDir(Index): self.collect_packages(self.path) def collect_packages(self, path): - logging.debug("Collecting all packages from %s" % path) + log.debug("Collecting all packages from %s" % path) pkgs = [] # Get a filelist of all files that could possibly be packages. @@ -380,7 +382,7 @@ class IndexDir(Index): # Check for binary packages if the architecture matches. if isinstance(package, packages.BinaryPackage) and \ not package.arch in (self.repo.arch, "noarch"): - logging.warning("Skipped package with wrong architecture: %s (%s)" \ + log.warning("Skipped package with wrong architecture: %s (%s)" \ % (package.filename, package.arch)) continue diff --git a/python/pakfire/repository/local.py b/python/pakfire/repository/local.py index 8e41f5e07..fd4a9967f 100644 --- a/python/pakfire/repository/local.py +++ b/python/pakfire/repository/local.py @@ -19,10 +19,12 @@ # # ############################################################################### -import logging import os import shutil +import logging +log = logging.getLogger("pakfire") + import base import index import metadata @@ -93,7 +95,7 @@ class RepositoryDir(base.RepositoryFactory): del pkg_exists if copy: - logging.debug("Copying package '%s' to repository." % pkg) + log.debug("Copying package '%s' to repository." % pkg) repo_dirname = os.path.dirname(repo_filename) if not os.path.exists(repo_dirname): os.makedirs(repo_dirname) diff --git a/python/pakfire/repository/remote.py b/python/pakfire/repository/remote.py index 617d5616d..caf220e16 100644 --- a/python/pakfire/repository/remote.py +++ b/python/pakfire/repository/remote.py @@ -19,9 +19,11 @@ # # ############################################################################### -import logging import os +import logging +log = logging.getLogger("pakfire") + import base import index @@ -88,7 +90,7 @@ class RepositorySolv(base.RepositoryFactory): # Check if file already exists in cache. if self.cache.exists(cache_filename): - logging.debug("File exists in cache: %s" % filename) + log.debug("File exists in cache: %s" % filename) # If the file does already exist, we check if the hash1 matches. if hash1 and self.cache.verify(cache_filename, hash1): @@ -99,7 +101,7 @@ class RepositorySolv(base.RepositoryFactory): cache.remove(cache_filename) if download: - logging.debug("Going to download %s" % filename) + log.debug("Going to download %s" % filename) # If we are in offline mode, we cannot download any files. if self.pakfire.offline and not self.url.startswith("file://"): diff --git a/python/pakfire/satsolver.py b/python/pakfire/satsolver.py index d91d9acec..d2ae1ad30 100644 --- a/python/pakfire/satsolver.py +++ b/python/pakfire/satsolver.py @@ -20,6 +20,7 @@ ############################################################################### import logging +log = logging.getLogger("pakfire") import _pakfire from _pakfire import * @@ -117,7 +118,7 @@ class Solver(object): # If no logger was provided, we use the root logger. if logger is None: - logger = logging.getLogger() + logger = log # Create a new solver. solver = _pakfire.Solver(self.pool) diff --git a/python/pakfire/server.py b/python/pakfire/server.py index 5f7c82348..369b2348c 100644 --- a/python/pakfire/server.py +++ b/python/pakfire/server.py @@ -20,7 +20,6 @@ ############################################################################### import hashlib -import logging import os import random import socket @@ -29,6 +28,9 @@ import tempfile import time import xmlrpclib +import logging +log = logging.getLogger("pakfire") + import pakfire.api import pakfire.base import pakfire.config @@ -90,7 +92,7 @@ class Source(object): cmd = "cd %s && git %s" % (path, cmd) - logging.debug("Running command: %s" % cmd) + log.debug("Running command: %s" % cmd) return subprocess.check_output(["/bin/sh", "-c", cmd]) @@ -181,13 +183,13 @@ class XMLRPCTransport(xmlrpclib.Transport): except xmlrpclib.ProtocolError, e: # Log all XMLRPC protocol errors. - logging.error("XMLRPC protocol error:") - logging.error(" URL: %s" % e.url) - logging.error(" HTTP headers:") + log.error("XMLRPC protocol error:") + log.error(" URL: %s" % e.url) + log.error(" HTTP headers:") for header in e.headers.items(): - logging.error(" %s: %s" % header) - logging.error(" Error code: %s" % e.errcode) - logging.error(" Error message: %s" % e.errmsg) + log.error(" %s: %s" % header) + log.error(" Error code: %s" % e.errcode) + log.error(" Error message: %s" % e.errmsg) raise else: @@ -196,12 +198,12 @@ class XMLRPCTransport(xmlrpclib.Transport): # If the request was not successful, we wait a little time to try # it again. - logging.debug("Request was not successful, we wait a little bit and try it again.") + log.debug("Request was not successful, we wait a little bit and try it again.") time.sleep(30) tries -= 1 else: - logging.error("Maximum number of tries was reached. Giving up.") + log.error("Maximum number of tries was reached. Giving up.") # XXX need better exception here. raise Exception, "Could not fulfill request." @@ -214,7 +216,7 @@ class Server(object): server = self.config._slave.get("server") - logging.info("Establishing RPC connection to: %s" % server) + log.info("Establishing RPC connection to: %s" % server) self.conn = xmlrpclib.ServerProxy(server, transport=XMLRPCTransport(), allow_none=True) @@ -293,7 +295,7 @@ class Server(object): break chunk += 1 - logging.info("Uploading chunk %s/%s of %s." % (chunk, chunks, + log.info("Uploading chunk %s/%s of %s." % (chunk, chunks, os.path.basename(filename))) data = xmlrpclib.Binary(data) diff --git a/python/pakfire/transaction.py b/python/pakfire/transaction.py index 15961421f..11a05efe3 100644 --- a/python/pakfire/transaction.py +++ b/python/pakfire/transaction.py @@ -19,7 +19,6 @@ # # ############################################################################### -import logging import os import progressbar import sys @@ -31,6 +30,9 @@ import satsolver import system import util +import logging +log = logging.getLogger("pakfire") + from constants import * from i18n import _ from pakfire._pakfire import sync @@ -85,13 +87,13 @@ class TransactionCheck(object): pkgs = [f.pkg.friendly_name for f in files] if len(files) == 2: - logging.critical( + log.critical( _("file %s from %s conflicts with file from package %s") % \ (name, pkgs[0], pkgs[1]) ) elif len(files) >= 3: - logging.critical( + log.critical( _("file %s from %s conflicts with files from %s") % \ (name, pkgs[0], i18n.list(pkgs[1:])) ) @@ -101,7 +103,7 @@ class TransactionCheck(object): continue print util.format_size(mp.free), util.format_size(mp.disk_usage) - logging.critical(_("There is not enough space left on %(name)s. Need at least %(size)s to perform transaction.") \ + log.critical(_("There is not enough space left on %(name)s. Need at least %(size)s to perform transaction.") \ % { "name" : mp.path, "size" : util.format_size(mp.space_needed) }) def load_filelist(self): @@ -281,7 +283,7 @@ class Transaction(object): raise DownloadError, _("Not enough space to download %s of packages.") \ % util.format_size(download_size) - logging.info(_("Downloading packages:")) + log.info(_("Downloading packages:")) time_start = time.time() i = 0 @@ -293,7 +295,7 @@ class Transaction(object): width, height = util.terminal_size() # Print a nice line. - logging.info("-" * width) + log.info("-" * width) # Format and calculate download information. time_stop = time.time() @@ -306,8 +308,8 @@ class Transaction(object): line = "%s | %5sB %s " % \ (download_speed, download_size, download_time) line = " " * (width - len(line)) + line - logging.info(line) - logging.info("") + log.info(line) + log.info("") def dump_pkg(self, pkg): ret = [] @@ -332,10 +334,7 @@ class Transaction(object): s.append("") return s - def dump(self, logger=None): - if not logger: - logger = logging.getLogger() - + def dump(self, logger=log): width = 80 line = "=" * width @@ -388,7 +387,7 @@ class Transaction(object): return util.ask_user(_("Is this okay?")) def check(self): - logging.info(_("Running Transaction Test")) + log.info(_("Running Transaction Test")) # Initialize the check object. check = TransactionCheck(self.pakfire, self) @@ -400,7 +399,7 @@ class Transaction(object): raise if check.successful: - logging.info(_("Transaction Test Succeeded")) + log.info(_("Transaction Test Succeeded")) return # In case of an unsuccessful transaction test, we print the error @@ -418,15 +417,15 @@ class Transaction(object): # Run the transaction test self.check() - logging.info(_("Running transaction")) + log.info(_("Running transaction")) # Run all actions in order and catch all kinds of ActionError. for action in self.actions: try: action.run() except ActionError, e: - logging.error("Action finished with an error: %s - %s" % (action, e)) + log.error("Action finished with an error: %s - %s" % (action, e)) - logging.info("") + log.info("") # Call sync to make sure all buffers are written to disk. sync() diff --git a/python/pakfire/util.py b/python/pakfire/util.py index 3492253f7..5efa5044f 100644 --- a/python/pakfire/util.py +++ b/python/pakfire/util.py @@ -23,7 +23,6 @@ from __future__ import division import fcntl import hashlib -import logging import math import os import progressbar @@ -36,6 +35,9 @@ import sys import termios import time +import logging +log = logging.getLogger("pakfire") + from constants import * from i18n import _ @@ -249,14 +251,14 @@ def orphans_kill(root, killsig=signal.SIGTERM): """ kill off anything that is still chrooted. """ - logging.debug(_("Killing orphans...")) + log.debug(_("Killing orphans...")) killed = False for fn in [d for d in os.listdir("/proc") if d.isdigit()]: try: r = os.readlink("/proc/%s/root" % fn) if os.path.realpath(root) == os.path.realpath(r): - logging.warning(_("Process ID %s is still running in chroot. Killing...") % fn) + log.warning(_("Process ID %s is still running in chroot. Killing...") % fn) killed = True pid = int(fn, 10) @@ -268,7 +270,7 @@ def orphans_kill(root, killsig=signal.SIGTERM): # If something was killed, wait a couple of seconds to make sure all file descriptors # are closed and we can proceed with umounting the filesystems. if killed: - logging.warning(_("Waiting for processes to terminate...")) + log.warning(_("Waiting for processes to terminate...")) time.sleep(3) # Calling ourself again to make sure all processes were killed. -- 2.39.5