Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging: Update deprecated log.warn to log.warning #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pretty_bad_protocol/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _find_agent(cls):
except psutil.Error as err:
# Exception when getting proc info, possibly because the
# process is zombie / process no longer exist. Just ignore it.
log.warn("Error while attempting to find gpg-agent process: %s" % err)
log.warning("Error while attempting to find gpg-agent process: %s" % err)
# Next code must be inside for operator.
# Otherwise to _agent_proc will be saved not "gpg-agent" process buth an other.
if ownership_match:
Expand Down Expand Up @@ -678,7 +678,7 @@ def _read_response(self, stream, result):
if not ignore:
# Log gpg's userland messages at our own levels:
if keyword.upper().startswith("WARNING"):
log.warn("%s" % value)
log.warning("%s" % value)
elif keyword.upper().startswith("FATAL"):
log.critical("%s" % value)
# Handle the gpg2 error where a missing trustdb.gpg is,
Expand Down Expand Up @@ -841,8 +841,8 @@ def _sign_file(self, file, default_key=None, passphrase=None,
if clearsign:
args.append("--clearsign")
if detach:
log.warn("Cannot use both --clearsign and --detach-sign.")
log.warn("Using default GPG behaviour: --clearsign only.")
log.warning("Cannot use both --clearsign and --detach-sign.")
log.warning("Using default GPG behaviour: --clearsign only.")
elif detach and not clearsign:
args.append("--detach-sign")

Expand Down
18 changes: 9 additions & 9 deletions pretty_bad_protocol/_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _check_keyserver(location):
if location.startswith(proto):
url = location.replace(proto, str())
host, slash, extra = url.partition('/')
if extra: log.warn("URI text for %s: '%s'" % (host, extra))
if extra: log.warning("URI text for %s: '%s'" % (host, extra))
log.debug("Got host string for keyserver setting: '%s'" % host)

host = _fix_unsafe(host)
Expand Down Expand Up @@ -214,7 +214,7 @@ class and its name will need to be added to this
assert hyphenated in allowed
except AssertionError as ae:
dropped = _fix_unsafe(hyphenated)
log.warn("_is_allowed(): Dropping option '%s'..." % dropped)
log.warning("_is_allowed(): Dropping option '%s'..." % dropped)
raise ProtectedOption("Option '%s' not supported." % dropped)
else:
return input
Expand Down Expand Up @@ -306,7 +306,7 @@ def _check_option(arg, value):
flag = _is_allowed(arg)
assert flag is not None, "_check_option(): got None for flag"
except (AssertionError, ProtectedOption) as error:
log.warn("_check_option(): %s" % str(error))
log.warning("_check_option(): %s" % str(error))
else:
checked += (flag + ' ')

Expand Down Expand Up @@ -414,7 +414,7 @@ def _make_groups(filo):
log.debug("Got value: %s" % filo[0])
groups[last] += filo.pop()
else:
log.warn("_make_groups(): Got solitary value: %s" % last)
log.warning("_make_groups(): Got solitary value: %s" % last)
groups["xxx"] = last
return groups

Expand All @@ -428,7 +428,7 @@ def _check_groups(groups):
log.debug("Appending option: %s" % safe)
checked_groups.append(safe)
else:
log.warn("Dropped option: '%s %s'" % (a,v))
log.warning("Dropped option: '%s %s'" % (a,v))
return checked_groups

if args is not None:
Expand All @@ -449,7 +449,7 @@ def _check_groups(groups):
arg.reverse()
option_groups.update(_make_groups(arg))
else:
log.warn("Got non-str/list arg: '%s', type '%s'"
log.warning("Got non-str/list arg: '%s', type '%s'"
% (arg, type(arg)))
checked = _check_groups(option_groups)
sanitised = ' '.join(x for x in checked)
Expand Down Expand Up @@ -979,7 +979,7 @@ def _handle_status(self, key, value):
elif key == "PROGRESS":
self.status = progress(value.split(' ', 1)[0])
elif key == "PINENTRY_LAUNCHED":
log.warn(("GnuPG has just attempted to launch whichever pinentry "
log.warning(("GnuPG has just attempted to launch whichever pinentry "
"program you have configured, in order to obtain the "
"passphrase for this key. If you did not use the "
"`passphrase=` parameter, please try doing so. Otherwise, "
Expand Down Expand Up @@ -1254,7 +1254,7 @@ def _handle_status(self, key, value):
# this duplicates info we already see in import_ok & import_problem
pass
elif key == "PINENTRY_LAUNCHED":
log.warn(("GnuPG has just attempted to launch whichever pinentry "
log.warning(("GnuPG has just attempted to launch whichever pinentry "
"program you have configured, in order to obtain the "
"passphrase for this key. If you did not use the "
"`passphrase=` parameter, please try doing so. Otherwise, "
Expand Down Expand Up @@ -1562,7 +1562,7 @@ def _handle_status(self, key, value):
# case of WARNING or ERROR) additional text.
# Have fun figuring out what it means.
self.status = value
log.warn("%s status emitted from gpg process: %s" % (key, value))
log.warning("%s status emitted from gpg process: %s" % (key, value))
elif key == "NO_PUBKEY":
self.valid = False
self.key_id = value
Expand Down
6 changes: 3 additions & 3 deletions pretty_bad_protocol/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def _make_passphrase(length=None, save=False, file=None):
os.chmod(file, stat.S_IRUSR | stat.S_IWUSR)
os.chown(file, ruid, gid)

log.warn("Generated passphrase saved to %s" % file)
log.warning("Generated passphrase saved to %s" % file)
return passphrase

def _make_random_string(length):
Expand Down Expand Up @@ -702,10 +702,10 @@ def _can_allow(p):
if not os.access(p, flags):
return False
if abspath_only and not os.path.abspath(p):
log.warn('Ignoring %r (path is not absolute)', p)
log.warning('Ignoring %r (path is not absolute)', p)
return False
if disallow_symlinks and os.path.islink(p):
log.warn('Ignoring %r (path is a symlink)', p)
log.warning('Ignoring %r (path is a symlink)', p)
return False
return True

Expand Down
4 changes: 2 additions & 2 deletions pretty_bad_protocol/gnupg.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def sign(self, data, **kwargs):
log.info("Signing message '%r' with keyid: %s"
% (data, kwargs['default_key']))
else:
log.warn("No 'default_key' given! Using first key on secring.")
log.warning("No 'default_key' given! Using first key on secring.")

if hasattr(data, 'read'):
result = self._sign_file(data, **kwargs)
Expand All @@ -257,7 +257,7 @@ def sign(self, data, **kwargs):
result = self._sign_file(stream, **kwargs)
stream.close()
else:
log.warn("Unable to sign message '%s' with type %s"
log.warning("Unable to sign message '%s' with type %s"
% (data, type(data)))
result = None
return result
Expand Down
16 changes: 8 additions & 8 deletions pretty_bad_protocol/test/test_gnupg.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def tearDown(self):
except OSError as ose:
log.error(ose)
else:
log.warn("Can't delete homedir: '%s' not a directory"
log.warning("Can't delete homedir: '%s' not a directory"
% self.homedir)

def test_parsers_fix_unsafe(self):
Expand Down Expand Up @@ -835,8 +835,8 @@ def test_signature_string_verification(self):
verified = self.gpg.verify(sig.data)
self.assertIsNotNone(verified.fingerprint)
if key.fingerprint != verified.fingerprint:
log.warn("key fingerprint: %r", key.fingerprint)
log.warn("verified fingerprint: %r", verified.fingerprint)
log.warning("key fingerprint: %r", key.fingerprint)
log.warning("verified fingerprint: %r", verified.fingerprint)
self.assertEqual(key.fingerprint, verified.fingerprint,
"Fingerprints must match")
self.assertEqual(verified.status, 'signature valid')
Expand All @@ -863,8 +863,8 @@ def test_signature_verification_clearsign(self):
except UnicodeDecodeError: #happens in Python 2.6
verified = self.gpg.verify_file(io.BytesIO(sig.data))
if key.fingerprint != verified.fingerprint:
log.warn("key fingerprint: %r", key.fingerprint)
log.warn("verified fingerprint: %r", verified.fingerprint)
log.warning("key fingerprint: %r", key.fingerprint)
log.warning("verified fingerprint: %r", verified.fingerprint)
self.assertEqual(key.fingerprint, verified.fingerprint)

def test_signature_verification_detached(self):
Expand Down Expand Up @@ -892,8 +892,8 @@ def test_signature_verification_detached(self):
verified = self.gpg.verify_file(datafd, sig_file=sigfn)

if key.fingerprint != verified.fingerprint:
log.warn("key fingerprint: %r", key.fingerprint)
log.warn("verified fingerprint: %r", verified.fingerprint)
log.warning("key fingerprint: %r", key.fingerprint)
log.warning("verified fingerprint: %r", verified.fingerprint)
self.assertEqual(key.fingerprint, verified.fingerprint)

if os.path.isfile(sigfn):
Expand Down Expand Up @@ -1775,7 +1775,7 @@ def before_run():
os.rename(ring, os.path.join(genkeysdir, fn))
except OSError as err:
## if we can't move the files it won't kill us:
log.warn(err)
log.warning(err)

if __name__ == "__main__":

Expand Down