Permalink
Browse files

Merge pull request #3071 from s0undt3ch/hotfix/pylint/C0103

Fixes for pylint's C0103 msgid
  • Loading branch information...
2 parents 111947a + e3dda9a commit a601af6955103f3cdff194ef5e8fddf82b51ac6b @thatch45 thatch45 committed Dec 31, 2012
Showing with 1,874 additions and 1,636 deletions.
  1. +1 −1 .pylintrc
  2. +2 −0 salt/_compat.py
  3. +25 −16 salt/auth/ldap.py
  4. +2 −2 salt/cli/caller.py
  5. +9 −9 salt/client.py
  6. +23 −23 salt/config.py
  7. +15 −12 salt/crypt.py
  8. +17 −15 salt/fileclient.py
  9. +15 −8 salt/fileserver/__init__.py
  10. +4 −4 salt/fileserver/gitfs.py
  11. +3 −2 salt/fileserver/roots.py
  12. +12 −15 salt/grains/core.py
  13. +13 −13 salt/loader.py
  14. +21 −21 salt/log.py
  15. +6 −6 salt/master.py
  16. +6 −6 salt/minion.py
  17. +8 −8 salt/modules/aliases.py
  18. +2 −2 salt/modules/apache.py
  19. +5 −7 salt/modules/apt.py
  20. +7 −7 salt/modules/at.py
  21. +5 −6 salt/modules/augeas_cfg.py
  22. +15 −15 salt/modules/cassandra.py
  23. +6 −4 salt/modules/cmdmod.py
  24. +4 −4 salt/modules/config.py
  25. +7 −4 salt/modules/cp.py
  26. +2 −2 salt/modules/cron.py
  27. +4 −3 salt/modules/daemontools.py
  28. +2 −5 salt/modules/debconfmod.py
  29. +11 −12 salt/modules/djangomod.py
  30. +20 −16 salt/modules/ebuild.py
  31. +31 −28 salt/modules/file.py
  32. +13 −13 salt/modules/freebsd_sysctl.py
  33. +18 −15 salt/modules/freebsdjail.py
  34. +5 −5 salt/modules/freebsdpkg.py
  35. +12 −8 salt/modules/freebsdservice.py
  36. +13 −6 salt/modules/gem.py
  37. +30 −27 salt/modules/glance.py
  38. +18 −16 salt/modules/grains.py
  39. +9 −8 salt/modules/hosts.py
  40. +82 −73 salt/modules/keystone.py
  41. +3 −3 salt/modules/kvm_hyper.py
  42. +27 −17 salt/modules/ldapmod.py
  43. +71 −45 salt/modules/mongodb.py
  44. +21 −18 salt/modules/mount.py
  45. +92 −91 salt/modules/mysql.py
  46. +26 −21 salt/modules/network.py
  47. +53 −46 salt/modules/nova.py
  48. +13 −14 salt/modules/openbsdpkg.py
  49. +2 −2 salt/modules/openbsdservice.py
  50. +6 −5 salt/modules/parted.py
  51. +4 −6 salt/modules/pecl.py
  52. +1 −1 salt/modules/pip.py
  53. +47 −46 salt/modules/pkg_resource.py
  54. +6 −8 salt/modules/pkgng.py
  55. +5 −5 salt/modules/postgres.py
  56. +6 −6 salt/modules/poudriere.py
  57. +25 −23 salt/modules/ps.py
  58. +6 −6 salt/modules/rabbitmq.py
  59. +6 −5 salt/modules/reg.py
  60. +56 −50 salt/modules/rh_ip.py
  61. +15 −13 salt/modules/rvm.py
  62. +15 −15 salt/modules/saltutil.py
  63. +5 −5 salt/modules/service.py
  64. +4 −4 salt/modules/solaris_shadow.py
  65. +35 −31 salt/modules/solarispkg.py
  66. +31 −25 salt/modules/solr.py
  67. +18 −6 salt/modules/sqlite3.py
  68. +9 −9 salt/modules/ssh.py
  69. +10 −7 salt/modules/status.py
  70. +3 −3 salt/modules/systemd.py
  71. +4 −4 salt/modules/test.py
  72. +11 −9 salt/modules/tls.py
  73. +2 −2 salt/modules/upstart.py
  74. +23 −15 salt/modules/virt.py
  75. +14 −8 salt/modules/win_disk.py
  76. +16 −16 salt/modules/win_file.py
  77. +7 −7 salt/modules/win_network.py
  78. +3 −4 salt/modules/win_pkg.py
  79. +63 −61 salt/modules/yumpkg.py
  80. +7 −8 salt/modules/yumpkg5.py
  81. +15 −18 salt/modules/zpool.py
  82. +2 −2 salt/payload.py
  83. +31 −21 salt/pillar/mongo.py
  84. +25 −19 salt/pillar/pillar_ldap.py
  85. +1 −1 salt/renderers/jinja.py
  86. +25 −25 salt/renderers/stateconf.py
  87. +8 −8 salt/renderers/yaml.py
  88. +6 −6 salt/returners/cassandra_return.py
  89. +28 −28 salt/returners/mongo_future_return.py
  90. +20 −20 salt/returners/mongo_return.py
  91. +16 −14 salt/returners/mysql.py
  92. +21 −4 salt/returners/postgres.py
  93. +3 −3 salt/returners/redis_return.py
  94. +1 −1 salt/runners/manage.py
  95. +15 −15 salt/runners/network.py
  96. +3 −3 salt/search/whoosh_search.py
  97. +12 −8 salt/state.py
  98. +46 −46 salt/states/cmd.py
  99. +16 −14 salt/states/cron.py
  100. +36 −34 salt/states/file.py
  101. +6 −1 salt/states/gem.py
  102. +2 −2 salt/states/host.py
  103. +1 −1 salt/states/module.py
  104. +1 −1 salt/states/stateconf.py
  105. +2 −2 salt/states/user.py
  106. +16 −16 salt/states/virtualenv.py
  107. +14 −14 salt/template.py
  108. +13 −11 salt/utils/__init__.py
  109. +41 −39 salt/utils/atomicfile.py
  110. +7 −8 salt/utils/dictupdate.py
  111. +14 −10 salt/utils/filebuffer.py
  112. +41 −36 salt/utils/find.py
  113. +7 −7 salt/utils/gzip_util.py
  114. +2 −2 salt/utils/jinja.py
  115. +18 −10 salt/utils/process.py
  116. +6 −1 salt/utils/saltminionservice.py
  117. +5 −0 salt/utils/socket_util.py
  118. +13 −13 salt/utils/templates.py
  119. +10 −10 salt/utils/verify.py
  120. +7 −7 salt/utils/winservice.py
  121. +2 −2 salt/utils/yaml.py
  122. +40 −34 salt/version.py
  123. +2 −2 tests/unit/stateconf_test.py
View
@@ -51,7 +51,7 @@ disable=W0142
output-format=text
# Include message's id in output
-include-ids=no
+include-ids=yes
# Put messages in a separate file for each module / package specified on the
# command line instead of printing them on stdout. Reports (if any) will be
View
@@ -19,6 +19,7 @@
else:
MAX_SIZE = sys.maxint
+# pylint: disable-msg=C0103
if PY3:
string_types = str,
integer_types = int,
@@ -145,3 +146,4 @@ def url_unquote_native(v, encoding='utf-8', errors='replace'):
from io import StringIO
else:
from StringIO import StringIO
+# pylint: enable-msg=C0103
View
@@ -71,17 +71,20 @@ def __init__(self, server, port, tls, binddn, bindpw):
self.binddn = binddn
self.bindpw = bindpw
try:
- self.LDAP = ldap.initialize('ldap://%s:%s' %
- (self.server, self.port))
- self.LDAP.protocol_version = 3 # ldap.VERSION3
- self.LDAP.set_option(ldap.OPT_REFERRALS, 0) # Needed for AD
+ self.ldap = ldap.initialize(
+ 'ldap://{0}:{1}'.format(self.server, self.port)
+ )
+ self.ldap.protocol_version = 3 # ldap.VERSION3
+ self.ldap.set_option(ldap.OPT_REFERRALS, 0) # Needed for AD
if self.tls:
- self.LDAP.start_tls_s()
- self.LDAP.simple_bind_s(self.binddn, self.bindpw)
+ self.ldap.start_tls_s()
+ self.ldap.simple_bind_s(self.binddn, self.bindpw)
except Exception:
- msg = 'Failed to bind to LDAP server %s:%s as %s' % \
- (self.server, self.port, self.binddn)
- raise CommandExecutionError(msg)
+ raise CommandExecutionError(
+ 'Failed to bind to LDAP server {0}:{1} as {2}'.format(
+ self.server, self.port, self.binddn
+ )
+ )
def auth(username, password):
@@ -96,11 +99,14 @@ def auth(username, password):
for name in ['server', 'port', 'tls', 'binddn', 'bindpw']:
connargs[name] = _config(name)
# Initial connection with config basedn and bindpw
- _ldap = _LDAPConnection(**connargs).LDAP
+ _ldap = _LDAPConnection(**connargs).ldap
# Search for user dn
- msg = 'Running LDAP user dn search with filter:%s, dn:%s, scope:%s' %\
- (filter, basedn, scope)
- log.debug(msg)
+ log.debug(
+ 'Running LDAP user dn search with filter:{0}, dn:{1}, '
+ 'scope:{2}'.format(
+ filter, basedn, scope
+ )
+ )
result = _ldap.search_s(basedn, int(scope), filter)
if len(result) < 1:
log.warn('Unable to find user {0}'.format(username))
@@ -115,10 +121,13 @@ def auth(username, password):
# Attempt bind with user dn and password
log.debug('Attempting LDAP bind with user dn: {0}'.format(authdn))
try:
- _LDAPConnection(**connargs).LDAP
+ _LDAPConnection(**connargs).ldap
except:
log.warn('Failed to authenticate user dn via LDAP: {0}'.format(authdn))
return False
- msg = 'Successfully authenticated user dn via LDAP: {0}'.format(authdn)
- log.debug(msg)
+ log.debug(
+ 'Successfully authenticated user dn via LDAP: {0}'.format(
+ authdn
+ )
+ )
return True
View
@@ -58,7 +58,7 @@ def call(self):
sys.stderr.write('Function {0} is not available\n'.format(fun))
sys.exit(1)
try:
- args, kw = salt.minion.detect_kwargs(
+ args, kwargs = salt.minion.detect_kwargs(
self.minion.functions[fun], self.opts['arg'])
sdata = {
'fun': fun,
@@ -67,7 +67,7 @@ def call(self):
'tgt': 'salt-call'}
with salt.utils.fopen(proc_fn, 'w+') as fp_:
fp_.write(self.serial.dumps(sdata))
- ret['return'] = self.minion.functions[fun](*args, **kw)
+ ret['return'] = self.minion.functions[fun](*args, **kwargs)
except (TypeError, CommandExecutionError) as exc:
msg = 'Error running \'{0}\': {1}\n'
active_level = LOG_LEVELS.get(
View
@@ -45,10 +45,10 @@
from salt.exceptions import EauthAuthenticationError
# Try to import range from https://github.com/ytoolshed/range
-has_range = False
+HAS_RANGE = False
try:
import seco.range
- has_range = True
+ HAS_RANGE = True
except ImportError:
pass
@@ -96,8 +96,8 @@ def __read_master_key(self):
salt.utils.verify.check_path_traversal(self.opts['cachedir'], key_user)
try:
- with salt.utils.fopen(keyfile, 'r') as KEY:
- return KEY.read()
+ with salt.utils.fopen(keyfile, 'r') as key:
+ return key.read()
except (OSError, IOError):
# Fall back to eauth
return ''
@@ -125,8 +125,8 @@ def _convert_range_to_list(self, tgt):
range = seco.range.Range(self.opts['range_server'])
try:
return range.expand(tgt)
- except seco.range.RangeException as e:
- print(("Range server exception: {0}".format(e)))
+ except seco.range.RangeException as err:
+ print("Range server exception: {0}".format(err))
return []
def _get_timeout(self, timeout):
@@ -943,7 +943,7 @@ def pub(self,
# Convert a range expression to a list of nodes and change expression
# form to list
- if expr_form == 'range' and has_range:
+ if expr_form == 'range' and HAS_RANGE:
tgt = self._convert_range_to_list(tgt)
expr_form = 'list'
@@ -1067,5 +1067,5 @@ def function(self, fun, *args, **kwargs):
Call a single salt function
'''
func = self.sminion.functions[fun]
- args, kw = salt.minion.detect_kwargs(func, args, kwargs)
- return func(*args, **kw)
+ args, kwargs = salt.minion.detect_kwargs(func, args, kwargs)
+ return func(*args, **kwargs)
View
@@ -28,10 +28,10 @@
log = logging.getLogger(__name__)
-_dflt_log_datefmt = '%H:%M:%S'
-_dflt_log_datefmt_logfile = '%Y-%m-%d %H:%M:%S'
-_dflt_log_fmt_console = '[%(levelname)-8s] %(message)s'
-_dflt_log_fmt_logfile = (
+_DFLT_LOG_DATEFMT = '%H:%M:%S'
+_DFLT_LOG_DATEFMT_LOGFILE = '%Y-%m-%d %H:%M:%S'
+_DFLT_LOG_FMT_CONSOLE = '[%(levelname)-8s] %(message)s'
+_DFLT_LOG_FMT_LOGFILE = (
'%(asctime)s,%(msecs)03.0f [%(name)-17s][%(levelname)-8s] %(message)s'
)
@@ -96,21 +96,21 @@ def load_config(opts, path, env_var):
if os.path.isfile(template):
import salt.utils # TODO: Need to re-import, need to find out why
with salt.utils.fopen(path, 'w') as out:
- with salt.utils.fopen(template, 'r') as f:
- f.readline() # skip first line
- out.write(f.read())
+ with salt.utils.fopen(template, 'r') as ifile:
+ ifile.readline() # skip first line
+ out.write(ifile.read())
if os.path.isfile(path):
try:
opts.update(_read_conf_file(path))
opts['conf_file'] = path
- except Exception as e:
+ except Exception as err:
import salt.log
msg = 'Error parsing configuration file: {0} - {1}'
if salt.log.is_console_configured():
- log.warn(msg.format(path, e))
+ log.warn(msg.format(path, err))
else:
- print(msg.format(path, e))
+ print(msg.format(path, err))
else:
log.debug('Missing configuration file: {0}'.format(path))
@@ -148,10 +148,10 @@ def include_config(include, opts, orig_path, verbose):
for fn_ in glob.glob(path):
try:
opts.update(_read_conf_file(fn_))
- except Exception as e:
+ except Exception as err:
log.warn(
'Error parsing configuration file: {0} - {1}'.format(
- fn_, e
+ fn_, err
)
)
return opts
@@ -222,10 +222,10 @@ def minion_config(path, check_dns=True):
'log_file': '/var/log/salt/minion',
'log_level': None,
'log_level_logfile': None,
- 'log_datefmt': _dflt_log_datefmt,
- 'log_datefmt_logfile': _dflt_log_datefmt_logfile,
- 'log_fmt_console': _dflt_log_fmt_console,
- 'log_fmt_logfile': _dflt_log_fmt_logfile,
+ 'log_datefmt': _DFLT_LOG_DATEFMT,
+ 'log_datefmt_logfile': _DFLT_LOG_DATEFMT_LOGFILE,
+ 'log_fmt_console': _DFLT_LOG_FMT_CONSOLE,
+ 'log_fmt_logfile': _DFLT_LOG_FMT_LOGFILE,
'log_granular_levels': {},
'test': False,
'cython_enable': False,
@@ -377,10 +377,10 @@ def master_config(path):
'log_file': '/var/log/salt/master',
'log_level': None,
'log_level_logfile': None,
- 'log_datefmt': _dflt_log_datefmt,
- 'log_datefmt_logfile': _dflt_log_datefmt_logfile,
- 'log_fmt_console': _dflt_log_fmt_console,
- 'log_fmt_logfile': _dflt_log_fmt_logfile,
+ 'log_datefmt': _DFLT_LOG_DATEFMT,
+ 'log_datefmt_logfile': _DFLT_LOG_DATEFMT_LOGFILE,
+ 'log_fmt_console': _DFLT_LOG_FMT_CONSOLE,
+ 'log_fmt_logfile': _DFLT_LOG_FMT_LOGFILE,
'log_granular_levels': {},
'pidfile': '/var/run/salt-master.pid',
'cluster_masters': [],
@@ -450,12 +450,12 @@ def master_config(path):
ignore_regex = opts['file_ignore_regex']
opts['file_ignore_regex'] = []
- for r in ignore_regex:
+ for regex in ignore_regex:
try:
# Can't store compiled regex itself in opts (breaks
# serialization)
- re.compile(r)
- opts['file_ignore_regex'].append(r)
+ re.compile(regex)
+ opts['file_ignore_regex'].append(regex)
except:
log.warning(
'Unable to parse file_ignore_regex. Skipping: {0}'.format(
View
@@ -14,23 +14,26 @@
# Import third party libs
from M2Crypto import RSA
from Crypto.Cipher import AES
-try:
- import win32api
- import win32con
- is_windows = True
-except ImportError:
- is_windows = False
-# Import salt utils
+# Import salt libs
import salt.utils
import salt.payload
import salt.utils.verify
import salt.version
-from salt.exceptions import AuthenticationError, SaltClientError, SaltReqTimeoutError
+from salt.exceptions import (
+ AuthenticationError, SaltClientError, SaltReqTimeoutError
+)
log = logging.getLogger(__name__)
+try:
+ import win32api
+ import win32con
+except ImportError:
+ pass
+
+
def clean_old_key(rsa_path):
'''
Read in an old m2crypto key and save it back in the clear so
@@ -44,7 +47,7 @@ def foo_pass(self, data=''):
except (IOError, OSError):
pass
# Set write permission for minion.pem file - reverted after saving the key
- if is_windows:
+ if salt.utils.is_windows():
win32api.SetFileAttributes(rsa_path, win32con.FILE_ATTRIBUTE_NORMAL)
try:
mkey.save_key(rsa_path, None)
@@ -54,7 +57,7 @@ def foo_pass(self, data=''):
'releases may not be able to use this key').format(rsa_path)
)
# Set read-only permission for minion.pem file
- if is_windows:
+ if salt.utils.is_windows():
win32api.SetFileAttributes(rsa_path, win32con.FILE_ATTRIBUTE_READONLY)
return mkey
@@ -374,8 +377,8 @@ def decrypt(self, data):
log.warning('Failed to authenticate message')
raise AuthenticationError('message authentication failed')
result = 0
- for x, y in zip(mac_bytes, sig):
- result |= ord(x) ^ ord(y)
+ for zipped_x, zipped_y in zip(mac_bytes, sig):
+ result |= ord(zipped_x) ^ ord(zipped_y)
if result != 0:
log.warning('Failed to authenticate message')
raise AuthenticationError('message authentication failed')
Oops, something went wrong.

0 comments on commit a601af6

Please sign in to comment.