Skip to content

Commit

Permalink
Remove version checks, and use AttributeError exception to skip if ne…
Browse files Browse the repository at this point in the history
…eded
  • Loading branch information
zas committed Sep 18, 2023
1 parent 6d1dac7 commit b467581
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 5 additions & 1 deletion picard/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def audit(event, args):
secs = time.time() - start_time
print(f'audit:{matched}:{tid}:{secs} {event} args={args}')

sys.addaudithook(audit)
try:
sys.addaudithook(audit)
except AttributeError:
# sys.addaudithook() appeared in Python 3.8
pass


def list_from_prefixes_string(prefixes_string):
Expand Down
14 changes: 6 additions & 8 deletions picard/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ def __init__(self, picard_args, localedir, autoupdate, pipe_handler=None):
if picard_args.debug or "PICARD_DEBUG" in os.environ:
self.set_log_level(logging.DEBUG)

if sys.version_info[:3] > (3, 8):
if picard_args.audit:
setup_audit(picard_args.audit)
if picard_args.audit:
setup_audit(picard_args.audit)

# Main thread pool used for most background tasks
self.thread_pool = QtCore.QThreadPool(self)
Expand Down Expand Up @@ -1442,11 +1441,10 @@ def process_picard_args():
parser.add_argument("-display", nargs=1, help=argparse.SUPPRESS)

# Picard specific arguments
if sys.version_info[:3] > (3, 8):
parser.add_argument("-a", "--audit", action='store',
default=None,
help="audit events passed as a comma-separated list, prefixes supported, "
"use all to match any (see https://docs.python.org/3/library/audit_events.html#audit-events)")
parser.add_argument("-a", "--audit", action='store',
default=None,
help="audit events passed as a comma-separated list, prefixes supported, "
"use all to match any (see https://docs.python.org/3/library/audit_events.html#audit-events)")
parser.add_argument("-c", "--config-file", action='store',
default=None,
help="location of the configuration file")
Expand Down

0 comments on commit b467581

Please sign in to comment.