diff options
Diffstat (limited to 'src/lib/Bcfg2')
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/APT.py | 18 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/BundleDeps.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/Chkconfig.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/DebInit.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/POSIX/Augeas.py | 9 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/RcUpdate.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/Tools/SYSV.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/XML.py | 2 | ||||
-rw-r--r-- | src/lib/Bcfg2/Client/__init__.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/DBSettings.py | 11 | ||||
-rw-r--r-- | src/lib/Bcfg2/Logger.py | 7 | ||||
-rw-r--r-- | src/lib/Bcfg2/Options/Parser.py | 4 | ||||
-rw-r--r-- | src/lib/Bcfg2/Utils.py | 2 | ||||
-rwxr-xr-x | src/lib/Bcfg2/manage.py | 20 |
14 files changed, 55 insertions, 42 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/APT.py b/src/lib/Bcfg2/Client/Tools/APT.py index 9b3dded99..4350f6067 100644 --- a/src/lib/Bcfg2/Client/Tools/APT.py +++ b/src/lib/Bcfg2/Client/Tools/APT.py @@ -42,10 +42,10 @@ class APT(Bcfg2.Client.Tools.Tool): if reqdir not in path_entries: os.environ['PATH'] = os.environ['PATH'] + ':' + reqdir self.pkgcmd = '%s ' % self.aptget + \ - '-o DPkg::Options::=--force-confold ' + \ - '-o DPkg::Options::=--force-confmiss ' + \ - '--reinstall ' + \ - '--force-yes ' + '-o DPkg::Options::=--force-confold ' + \ + '-o DPkg::Options::=--force-confmiss ' + \ + '--reinstall ' + \ + '--force-yes ' if not Bcfg2.Options.setup.debug: self.pkgcmd += '-q=2 ' self.pkgcmd += '-y install %s' @@ -158,8 +158,8 @@ class APT(Bcfg2.Client.Tools.Tool): (entry.attrib['name'])) return False pkgname = entry.get('name') - if pkgname not in self.pkg_cache or \ - not self.pkg_cache[pkgname].is_installed: + if (pkgname not in self.pkg_cache or + not self.pkg_cache[pkgname].is_installed): self.logger.info("Package %s not installed" % (entry.get('name'))) entry.set('current_exists', 'false') return False @@ -183,9 +183,9 @@ class APT(Bcfg2.Client.Tools.Tool): return False else: # version matches - if not Bcfg2.Options.setup.quick \ - and entry.get('verify', 'true') == 'true' \ - and checksums: + if (not Bcfg2.Options.setup.quick and + entry.get('verify', 'true') == 'true' and + checksums): pkgsums = self.VerifyDebsums(entry, modlist) return pkgsums return True diff --git a/src/lib/Bcfg2/Client/Tools/BundleDeps.py b/src/lib/Bcfg2/Client/Tools/BundleDeps.py index aaa090633..c1af3f7f1 100644 --- a/src/lib/Bcfg2/Client/Tools/BundleDeps.py +++ b/src/lib/Bcfg2/Client/Tools/BundleDeps.py @@ -28,7 +28,7 @@ class BundleDeps(Bcfg2.Client.Tools.Tool): bundle_name = entry.get('name') for bundle in self.config.findall('./Bundle/Bundle'): - if bundle.get('name') == bundle_name and \ - bundle not in self.modified: + if (bundle.get('name') == bundle_name and + bundle not in self.modified): self.modified.append(bundle) return dict() diff --git a/src/lib/Bcfg2/Client/Tools/Chkconfig.py b/src/lib/Bcfg2/Client/Tools/Chkconfig.py index b535de191..b1abb376a 100644 --- a/src/lib/Bcfg2/Client/Tools/Chkconfig.py +++ b/src/lib/Bcfg2/Client/Tools/Chkconfig.py @@ -88,8 +88,8 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): if bootstatus is not None: if bootstatus == 'on': # make sure service is enabled on boot - bootcmd = '/sbin/chkconfig %s %s' % \ - (entry.get('name'), bootstatus) + bootcmd = ('/sbin/chkconfig %s %s' % + (entry.get('name'), bootstatus)) elif bootstatus == 'off': # make sure service is disabled on boot bootcmd = '/sbin/chkconfig %s %s' % (entry.get('name'), diff --git a/src/lib/Bcfg2/Client/Tools/DebInit.py b/src/lib/Bcfg2/Client/Tools/DebInit.py index 53e5e7ec6..35768f0fe 100644 --- a/src/lib/Bcfg2/Client/Tools/DebInit.py +++ b/src/lib/Bcfg2/Client/Tools/DebInit.py @@ -142,8 +142,8 @@ class DebInit(Bcfg2.Client.Tools.SvcTool): # 'disabled' means we don't attempt to modify running svcs return bootcmdrv and seqcmdrv buildmode = Bcfg2.Options.setup.service_mode == 'build' - if (entry.get('status') == 'on' and not buildmode) and \ - entry.get('current_status') == 'off': + if ((entry.get('status') == 'on' and not buildmode) and + entry.get('current_status') == 'off'): svccmdrv = self.start_service(entry) elif (entry.get('status') == 'off' or buildmode) and \ entry.get('current_status') == 'on': diff --git a/src/lib/Bcfg2/Client/Tools/POSIX/Augeas.py b/src/lib/Bcfg2/Client/Tools/POSIX/Augeas.py index f4f1ee4bf..bcd695058 100644 --- a/src/lib/Bcfg2/Client/Tools/POSIX/Augeas.py +++ b/src/lib/Bcfg2/Client/Tools/POSIX/Augeas.py @@ -5,6 +5,7 @@ import Bcfg2.Client.XML from augeas import Augeas from Bcfg2.Client.Tools.POSIX.base import POSIXTool from Bcfg2.Client.Tools.POSIX.File import POSIXFile +from Bcfg2.Compat import all # pylint: disable=W0622 class AugeasCommand(object): @@ -249,8 +250,8 @@ class POSIXAugeas(POSIXTool): for cmd in self.get_commands(entry): try: if not cmd.verify(): - err = "Augeas: Command has not been applied to %s: %s" % \ - (entry.get("name"), cmd) + err = ("Augeas: Command has not been applied to %s: %s" % + (entry.get("name"), cmd)) self.logger.debug(err) entry.set('qtext', "\n".join([entry.get('qtext', ''), err])) @@ -259,8 +260,8 @@ class POSIXAugeas(POSIXTool): else: cmd.command.set("verified", "true") except: # pylint: disable=W0702 - err = "Augeas: Unexpected error verifying %s: %s: %s" % \ - (entry.get("name"), cmd, sys.exc_info()[1]) + err = ("Augeas: Unexpected error verifying %s: %s: %s" % + (entry.get("name"), cmd, sys.exc_info()[1])) self.logger.error(err) entry.set('qtext', "\n".join([entry.get('qtext', ''), err])) rv = False diff --git a/src/lib/Bcfg2/Client/Tools/RcUpdate.py b/src/lib/Bcfg2/Client/Tools/RcUpdate.py index a482dbc00..21257f64b 100644 --- a/src/lib/Bcfg2/Client/Tools/RcUpdate.py +++ b/src/lib/Bcfg2/Client/Tools/RcUpdate.py @@ -102,8 +102,8 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): # 'disabled' means we don't attempt to modify running svcs return bootcmdrv buildmode = Bcfg2.Options.setup.service_mode == 'build' - if (entry.get('status') == 'on' and not buildmode) and \ - entry.get('current_status') == 'off': + if ((entry.get('status') == 'on' and not buildmode) and + entry.get('current_status') == 'off'): svccmdrv = self.start_service(entry) elif (entry.get('status') == 'off' or buildmode) and \ entry.get('current_status') == 'on': diff --git a/src/lib/Bcfg2/Client/Tools/SYSV.py b/src/lib/Bcfg2/Client/Tools/SYSV.py index 332638de4..4eea0273f 100644 --- a/src/lib/Bcfg2/Client/Tools/SYSV.py +++ b/src/lib/Bcfg2/Client/Tools/SYSV.py @@ -119,8 +119,8 @@ class SYSV(Bcfg2.Client.Tools.PkgTool): self.logger.debug("Package %s not installed" % entry.get("name")) else: - if Bcfg2.Options.setup.quick or \ - entry.attrib.get('verify', 'true') == 'false': + if (Bcfg2.Options.setup.quick or + entry.attrib.get('verify', 'true') == 'false'): return True rv = self.cmd.run("/usr/sbin/pkgchk -n %s" % entry.get('name')) if rv.success: diff --git a/src/lib/Bcfg2/Client/XML.py b/src/lib/Bcfg2/Client/XML.py index 4ba06abae..93e4facdb 100644 --- a/src/lib/Bcfg2/Client/XML.py +++ b/src/lib/Bcfg2/Client/XML.py @@ -2,7 +2,7 @@ # library will use lxml, then builtin xml.etree, then ElementTree -# pylint: disable=E0611,W0611,W0613,C0103 +# pylint: disable=E0611,E1101,W0611,W0613,C0103 try: from lxml.etree import Element, SubElement, tostring, XMLParser diff --git a/src/lib/Bcfg2/Client/__init__.py b/src/lib/Bcfg2/Client/__init__.py index dc4dfb983..157cc7f65 100644 --- a/src/lib/Bcfg2/Client/__init__.py +++ b/src/lib/Bcfg2/Client/__init__.py @@ -921,8 +921,8 @@ class Client(object): """Generate XML summary of execution statistics.""" states = {} for (item, val) in list(self.states.items()): - if not Bcfg2.Options.setup.only_important or \ - item.get('important', 'false').lower() == 'true': + if (not Bcfg2.Options.setup.only_important or + item.get('important', 'false').lower() == 'true'): states[item] = val feedback = XML.Element("upload-statistics") diff --git a/src/lib/Bcfg2/DBSettings.py b/src/lib/Bcfg2/DBSettings.py index 254dfa4b8..ddcf66b44 100644 --- a/src/lib/Bcfg2/DBSettings.py +++ b/src/lib/Bcfg2/DBSettings.py @@ -21,7 +21,8 @@ try: except ImportError: HAS_SOUTH = False -settings = dict( # pylint: disable=C0103 +# pylint: disable=C0103 +settings = dict( TIME_ZONE=None, TEMPLATE_DEBUG=False, DEBUG=False, @@ -106,8 +107,8 @@ def finalize_django_config(opts=None, silent=False): OPTIONS=opts.db_opts, SCHEMA=opts.db_schema)) - if hasattr(opts, "reporting_db_engine") and \ - opts.reporting_db_engine is not None: + if (hasattr(opts, "reporting_db_engine") and + opts.reporting_db_engine is not None): settings['DATABASES']['Reporting'] = dict( ENGINE="django.db.backends.%s" % opts.reporting_db_engine, NAME=opts.reporting_db_name, @@ -180,9 +181,9 @@ def upgrade_to_django_migrations(database, logger): cursor.cursor.execute('SELECT migration FROM south_migrationhistory') applied_migrations = [name for (name,) in cursor.fetchall()] last_migration = sorted(applied_migrations).pop() + # django.db.DatabaseError is not working here, because we are + # using the low level api to interact directly with the database except: # pylint: disable=W0702 - # django.db.DatabaseError is not working here, because we are - # using the low level api to interact directly with the database logger.debug("No south migration detected for database: %s." % database) diff --git a/src/lib/Bcfg2/Logger.py b/src/lib/Bcfg2/Logger.py index e5f316a18..a26971df4 100644 --- a/src/lib/Bcfg2/Logger.py +++ b/src/lib/Bcfg2/Logger.py @@ -133,10 +133,11 @@ class FragmentingSysLogHandler(logging.handlers.SysLogHandler): logging.WARNING), self.format(reconn))) self.socket.send(msg) + + # If we still fail then drop it. Running + # bcfg2-server as non-root can trigger permission + # denied exceptions. except: # pylint: disable=W0702 - # If we still fail then drop it. Running - # bcfg2-server as non-root can trigger permission - # denied exceptions. pass diff --git a/src/lib/Bcfg2/Options/Parser.py b/src/lib/Bcfg2/Options/Parser.py index ced61c591..51e41850c 100644 --- a/src/lib/Bcfg2/Options/Parser.py +++ b/src/lib/Bcfg2/Options/Parser.py @@ -12,12 +12,14 @@ __all__ = ["setup", "OptionParserException", "Parser", "get_parser", "new_parser"] +# pylint: disable=C0103 #: The repository option. This is specified here (and imported into #: :module:`Bcfg2.Options.Common`) rather than vice-versa due to #: circular imports. -repository = PathOption( # pylint: disable=C0103 +repository = PathOption( '-Q', '--repository', cf=('server', 'repository'), default='/var/lib/bcfg2', help="Server repository path") +# pylint: enable=C0103 #: A module-level :class:`argparse.Namespace` object that stores all diff --git a/src/lib/Bcfg2/Utils.py b/src/lib/Bcfg2/Utils.py index 2fdc0c3e0..b043fd11c 100644 --- a/src/lib/Bcfg2/Utils.py +++ b/src/lib/Bcfg2/Utils.py @@ -338,7 +338,7 @@ class classproperty(object): # pylint: disable=C0103 self.getter = getter def __get__(self, instance, owner): - return self.getter(owner) + return classmethod(self.getter).__get__(None, owner)() def is_string(strng, encoding): diff --git a/src/lib/Bcfg2/manage.py b/src/lib/Bcfg2/manage.py index b156deb0f..9675a3db1 100755 --- a/src/lib/Bcfg2/manage.py +++ b/src/lib/Bcfg2/manage.py @@ -1,5 +1,6 @@ #!/usr/bin/env python -import os +""" Wrapper for the django manage.py with the Bcfg2 Opitons parsing. """ + import sys import django import Bcfg2.Options @@ -10,14 +11,21 @@ try: except ImportError: pass -parser = Bcfg2.Options.get_parser() -parser.add_options([Bcfg2.Options.PositionalArgument('django_command', nargs='*')]) -parser.parse() -if __name__ == "__main__": +def main(): + parser = Bcfg2.Options.get_parser() + parser.add_options([ + Bcfg2.Options.PositionalArgument('django_command', nargs='*')]) + parser.parse() + if django.VERSION[0] == 1 and django.VERSION[1] >= 6: from django.core.management import execute_from_command_line - execute_from_command_line(sys.argv[:1] + Bcfg2.Options.setup.django_command) + execute_from_command_line( + sys.argv[:1] + Bcfg2.Options.setup.django_command) else: from django.core.management import execute_manager execute_manager(Bcfg2.DBSettings.settings) + + +if __name__ == "__main__": + main() |