diff --git a/callback_plugins/logdetail.py b/callback_plugins/logdetail.py index 5af8e2d82b..21aa97caae 100644 --- a/callback_plugins/logdetail.py +++ b/callback_plugins/logdetail.py @@ -60,7 +60,7 @@ MSG_FORMAT = "%(now)s\t%(count)s\t%(category)s\t%(name)s\t%(data)s\n" def getlogin(): try: user = os.getlogin() - except OSError as e: + except OSError: user = pwd.getpwuid(os.geteuid())[0] return user diff --git a/roles/batcave/files/koji_sar.py b/roles/batcave/files/koji_sar.py index 610e9a5dac..d9bab4adec 100644 --- a/roles/batcave/files/koji_sar.py +++ b/roles/batcave/files/koji_sar.py @@ -6,7 +6,6 @@ import os import json import subprocess import sys -import time import koji diff --git a/roles/batcave/files/oshift_mod.py b/roles/batcave/files/oshift_mod.py index b3057e4cb9..96c99282db 100644 --- a/roles/batcave/files/oshift_mod.py +++ b/roles/batcave/files/oshift_mod.py @@ -18,7 +18,6 @@ import time import traceback import json -import base64 import requests diff --git a/roles/bodhi2/backend/files/bodhi-automated-pushes.py b/roles/bodhi2/backend/files/bodhi-automated-pushes.py index 2c2875b733..dcb8100d93 100644 --- a/roles/bodhi2/backend/files/bodhi-automated-pushes.py +++ b/roles/bodhi2/backend/files/bodhi-automated-pushes.py @@ -2,9 +2,7 @@ from __future__ import print_function import sys import requests -import json import subprocess -import logging req = requests.get('https://bodhi.fedoraproject.org/composes/') bodhi_composes = req.json() diff --git a/roles/cloudstats/files/cloud-image-stat.py b/roles/cloudstats/files/cloud-image-stat.py index ab212db9d0..05dd3ce44a 100644 --- a/roles/cloudstats/files/cloud-image-stat.py +++ b/roles/cloudstats/files/cloud-image-stat.py @@ -1,6 +1,6 @@ from glob import glob from datetime import date -from os import walk,listdir +from os import listdir from os.path import exists from bz2 import BZ2File import smtplib diff --git a/roles/collectd/fedmsg-activation/files/fedmsg-map.py b/roles/collectd/fedmsg-activation/files/fedmsg-map.py index ccf6ea9d86..8cdb85ac6c 100644 --- a/roles/collectd/fedmsg-activation/files/fedmsg-map.py +++ b/roles/collectd/fedmsg-activation/files/fedmsg-map.py @@ -73,7 +73,7 @@ def scan_all(): info() if 'verbose' in sys.argv: - import pprint; + import pprint pprint.pprint(dict(active)) pprint.pprint(dict(inactive)) diff --git a/roles/epylog/files/modules/common_unparsed_mod.py b/roles/epylog/files/modules/common_unparsed_mod.py index d2aa635fbb..c2e29ecfea 100644 --- a/roles/epylog/files/modules/common_unparsed_mod.py +++ b/roles/epylog/files/modules/common_unparsed_mod.py @@ -16,7 +16,6 @@ import difflib from operator import itemgetter import tempfile import os -import shutil ## # This is for testing purposes, so you can invoke this from the @@ -24,7 +23,7 @@ import shutil # file. # sys.path.insert(0, '../py/') -from epylog import Result, InternalModule +from epylog import InternalModule class common_unparsed_mod(InternalModule): def __init__(self, opts, logger): diff --git a/roles/epylog/files/modules/kojiload_mod.py b/roles/epylog/files/modules/kojiload_mod.py index 3945b8b0f7..0c2be613ca 100644 --- a/roles/epylog/files/modules/kojiload_mod.py +++ b/roles/epylog/files/modules/kojiload_mod.py @@ -32,7 +32,7 @@ import re # file. # sys.path.insert(0, '../py/') -from epylog import Result, InternalModule +from epylog import InternalModule class kojiload_mod(InternalModule): ## diff --git a/roles/epylog/files/modules/logins_mod.py b/roles/epylog/files/modules/logins_mod.py index b4889599c8..8e5b476b57 100644 --- a/roles/epylog/files/modules/logins_mod.py +++ b/roles/epylog/files/modules/logins_mod.py @@ -34,7 +34,7 @@ import time import os import sqlite3 as sqlite sys.path.insert(0, '../py/') -from epylog import Result, InternalModule +from epylog import InternalModule def executeSQL(cursor, query, params=None): diff --git a/roles/epylog/files/modules/selinux_mod.py b/roles/epylog/files/modules/selinux_mod.py index 0e40b2033c..8b1fc4c5bd 100644 --- a/roles/epylog/files/modules/selinux_mod.py +++ b/roles/epylog/files/modules/selinux_mod.py @@ -14,7 +14,7 @@ import re # file. # sys.path.insert(0, '../py/') -from epylog import Result, InternalModule +from epylog import InternalModule class selinux_mod(InternalModule): def __init__(self, opts, logger): diff --git a/roles/epylog/files/modules/sudo_mod.py b/roles/epylog/files/modules/sudo_mod.py index d411b9fd35..19907681b8 100644 --- a/roles/epylog/files/modules/sudo_mod.py +++ b/roles/epylog/files/modules/sudo_mod.py @@ -14,7 +14,7 @@ import re # file. # sys.path.insert(0, '../py/') -from epylog import Result, InternalModule +from epylog import InternalModule class sudo_mod(InternalModule): def __init__(self, opts, logger): diff --git a/roles/grobisplitter/files/splitter-upstream-20220531.py b/roles/grobisplitter/files/splitter-upstream-20220531.py index 1d0123f792..07f0a71a50 100755 --- a/roles/grobisplitter/files/splitter-upstream-20220531.py +++ b/roles/grobisplitter/files/splitter-upstream-20220531.py @@ -13,7 +13,6 @@ import tempfile import os import subprocess import sys -import time import logging # Look for a specific version of modulemd. The 1.x series does not @@ -89,7 +88,7 @@ def _get_modulemd(directory=None, repo_info=None): elif myfile.endswith(".xz"): openfunc=lzma.LZMAFile else: - print("This file type is not fixed in this hack. Please fix code. (2021-05-20)"); + print("This file type is not fixed in this hack. Please fix code. (2021-05-20)") sys.exit(1) with openfunc(filename=myfile, mode='r') as zipf: mmdcts = zipf.read().decode('utf-8') @@ -270,7 +269,7 @@ def _get_recursive_dependencies(all_deps, idx, stream, ignore_missing_deps): try: _get_recursive_dependencies( local_deps, idx, inner_stream, ignore_missing_deps) - except FileNotFoundError as e: + except FileNotFoundError: # Could not find all of this stream's dependencies in # the repo continue diff --git a/roles/grobisplitter/files/splitter.py b/roles/grobisplitter/files/splitter.py index 9b40d0e5d2..f338feda81 100755 --- a/roles/grobisplitter/files/splitter.py +++ b/roles/grobisplitter/files/splitter.py @@ -13,8 +13,6 @@ import tempfile import os import subprocess import sys -import time -import logging # Look for a specific version of modulemd. The 1.x series does not # have the tools we need. @@ -116,7 +114,7 @@ def _parse_repository_modular(repo_info, package_sack): elif myfile.endswith(".xz"): openfunc=lzma.LZMAFile else: - print("This file type is not fixed in this hack. Please fix code. (2021-05-20)"); + print("This file type is not fixed in this hack. Please fix code. (2021-05-20)") sys.exit(1) with openfunc(filename=myfile, mode='r') as gzf: mmdcts = gzf.read().decode('utf-8') @@ -212,7 +210,7 @@ def get_default_modules(directory): elif myfile.endswith(".xz"): openfunc=lzma.LZMAFile else: - print("This file type is not fixed in this hack. Please fix code. (2021-05-20)"); + print("This file type is not fixed in this hack. Please fix code. (2021-05-20)") sys.exit(1) with openfunc(filename=myfile, mode='r') as gzf: mmdcts = gzf.read().decode('utf-8') diff --git a/roles/ipsilon/templates/prepare-saml2-metadata.py b/roles/ipsilon/templates/prepare-saml2-metadata.py index da75b2d9ef..f53e5e0090 100644 --- a/roles/ipsilon/templates/prepare-saml2-metadata.py +++ b/roles/ipsilon/templates/prepare-saml2-metadata.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 from ipsilon.providers.saml2idp import IdpMetadataGenerator, Certificate -from datetime import timedelta cert = Certificate() cert.import_cert('/etc/ipsilon/root/saml2/idp.crt', '/etc/ipsilon/root/saml2/idp.key') #meta = IdpMetadataGenerator('https://id{{ env_suffix }}.fedoraproject.org', cert, timedelta(3600)) diff --git a/roles/mirror_pagure_ansible/templates/mirror_from_pagure_bus.py b/roles/mirror_pagure_ansible/templates/mirror_from_pagure_bus.py index 70bf6286b1..02591338b6 100644 --- a/roles/mirror_pagure_ansible/templates/mirror_from_pagure_bus.py +++ b/roles/mirror_pagure_ansible/templates/mirror_from_pagure_bus.py @@ -4,15 +4,12 @@ hosted in pagure.io """ from __future__ import print_function -import datetime import logging import os -import sched import subprocess -import sys import time -from fedora_messaging import api, config, message +from fedora_messaging import config, message _log = logging.getLogger("mirror_from_pagure_bus") diff --git a/roles/nagios_client/files/scripts/check_fedmsg_consumer_backlog.py b/roles/nagios_client/files/scripts/check_fedmsg_consumer_backlog.py index 833d218e3b..902d610b67 100644 --- a/roles/nagios_client/files/scripts/check_fedmsg_consumer_backlog.py +++ b/roles/nagios_client/files/scripts/check_fedmsg_consumer_backlog.py @@ -2,7 +2,6 @@ import json import os -import socket import sys import zmq diff --git a/roles/nagios_client/files/scripts/check_fedmsg_consumer_exceptions.py b/roles/nagios_client/files/scripts/check_fedmsg_consumer_exceptions.py index 7219b0267e..2e994ea711 100644 --- a/roles/nagios_client/files/scripts/check_fedmsg_consumer_exceptions.py +++ b/roles/nagios_client/files/scripts/check_fedmsg_consumer_exceptions.py @@ -2,7 +2,6 @@ import json import os -import socket import sys import zmq diff --git a/roles/nagios_client/files/scripts/check_fedmsg_producers_consumers.py b/roles/nagios_client/files/scripts/check_fedmsg_producers_consumers.py index 5029a5b5f9..d4e11ab83a 100644 --- a/roles/nagios_client/files/scripts/check_fedmsg_producers_consumers.py +++ b/roles/nagios_client/files/scripts/check_fedmsg_producers_consumers.py @@ -2,7 +2,6 @@ import json import os -import socket import sys import zmq diff --git a/roles/nagios_server/files/nagios/plugins/check_fedmsg_consumer_backlog.py b/roles/nagios_server/files/nagios/plugins/check_fedmsg_consumer_backlog.py index 2357dd0008..0a50e9fbd9 100644 --- a/roles/nagios_server/files/nagios/plugins/check_fedmsg_consumer_backlog.py +++ b/roles/nagios_server/files/nagios/plugins/check_fedmsg_consumer_backlog.py @@ -2,7 +2,6 @@ import json import os -import socket import sys import zmq diff --git a/roles/nagios_server/files/nagios/plugins/check_fedmsg_consumer_exceptions.py b/roles/nagios_server/files/nagios/plugins/check_fedmsg_consumer_exceptions.py index a07d30cad5..b3ecda8fe9 100644 --- a/roles/nagios_server/files/nagios/plugins/check_fedmsg_consumer_exceptions.py +++ b/roles/nagios_server/files/nagios/plugins/check_fedmsg_consumer_exceptions.py @@ -2,7 +2,6 @@ import json import os -import socket import sys import zmq diff --git a/roles/nagios_server/files/nagios/plugins/check_fedmsg_producers_consumers.py b/roles/nagios_server/files/nagios/plugins/check_fedmsg_producers_consumers.py index d71aad7b12..4423afffa4 100644 --- a/roles/nagios_server/files/nagios/plugins/check_fedmsg_producers_consumers.py +++ b/roles/nagios_server/files/nagios/plugins/check_fedmsg_producers_consumers.py @@ -2,7 +2,6 @@ import json import os -import socket import sys import zmq diff --git a/roles/nagios_server/files/nagios/scripts/check_nagios_notifications.py b/roles/nagios_server/files/nagios/scripts/check_nagios_notifications.py index 4d2190d6e9..d5c796a818 100755 --- a/roles/nagios_server/files/nagios/scripts/check_nagios_notifications.py +++ b/roles/nagios_server/files/nagios/scripts/check_nagios_notifications.py @@ -86,7 +86,7 @@ def main(): hard_states = [ x for x in [int(x["last_hard_state"]) for x in host["services"]] - if not x in [0, 1] + if x not in [0, 1] ] need_newline = False if host["notifications_enabled"] == "0" and not hard_states: diff --git a/roles/openshift-apps/kerneltest/templates/wsgi.py b/roles/openshift-apps/kerneltest/templates/wsgi.py index 6c50977104..e69de29bb2 100644 --- a/roles/openshift-apps/kerneltest/templates/wsgi.py +++ b/roles/openshift-apps/kerneltest/templates/wsgi.py @@ -1 +0,0 @@ -from kerneltest.app import APP as application \ No newline at end of file diff --git a/roles/pagure/files/pagure_stream_server.py b/roles/pagure/files/pagure_stream_server.py index 64462140f2..bb3761ccff 100644 --- a/roles/pagure/files/pagure_stream_server.py +++ b/roles/pagure/files/pagure_stream_server.py @@ -212,7 +212,7 @@ def handle_client(client_reader, client_writer): except OSError: log.info("Client closed connection") - except ConnectionResetError as err: + except ConnectionResetError: log.exception("ERROR: ConnectionResetError in handle_client") except Exception as err: log.exception("ERROR: Exception in handle_client") @@ -274,7 +274,7 @@ def main(): loop.run_forever() except KeyboardInterrupt: pass - except ConnectionResetError as err: + except ConnectionResetError: log.exception("ERROR: ConnectionResetError in main") except Exception: log.exception("ERROR: Exception in main") diff --git a/roles/people/files/make-people-page.py b/roles/people/files/make-people-page.py index 922d62aa6e..b0b9f8caf6 100644 --- a/roles/people/files/make-people-page.py +++ b/roles/people/files/make-people-page.py @@ -21,9 +21,7 @@ import grp import hashlib import logging -import os import pwd -import stat from pathlib import Path from jinja2 import Template diff --git a/roles/postgresql_server/files/datagrepper_sar.py b/roles/postgresql_server/files/datagrepper_sar.py index 1cf93f9e59..e60a75c944 100644 --- a/roles/postgresql_server/files/datagrepper_sar.py +++ b/roles/postgresql_server/files/datagrepper_sar.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals, print_function import os -import string import subprocess import sys diff --git a/roles/repo2json/files/rhel_to_json.py b/roles/repo2json/files/rhel_to_json.py index a484b434e5..e5910ffea5 100644 --- a/roles/repo2json/files/rhel_to_json.py +++ b/roles/repo2json/files/rhel_to_json.py @@ -13,20 +13,18 @@ requires: # These two lines are needed to run on EL6 __requires__ = ['SQLAlchemy >= 0.7'] -import pkg_resources import contextlib import json import os import shutil -import sys import tempfile # Database related part -from sqlalchemy import Column, ForeignKey, Integer, Text, create_engine +from sqlalchemy import Column, Integer, Text, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker diff --git a/roles/web-data-analysis/files/mirrorlist.py b/roles/web-data-analysis/files/mirrorlist.py index 293c4382fa..0f6612b07c 100644 --- a/roles/web-data-analysis/files/mirrorlist.py +++ b/roles/web-data-analysis/files/mirrorlist.py @@ -23,7 +23,6 @@ import sys import re import optparse import os -import string ''' diff --git a/roles/zabbix/zabbix_server/library/zabbix_retrieve_sysadmin_noc_group_membership.py b/roles/zabbix/zabbix_server/library/zabbix_retrieve_sysadmin_noc_group_membership.py index 975b702fbb..6698c8d593 100644 --- a/roles/zabbix/zabbix_server/library/zabbix_retrieve_sysadmin_noc_group_membership.py +++ b/roles/zabbix/zabbix_server/library/zabbix_retrieve_sysadmin_noc_group_membership.py @@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function import json -import re import requests from ansible.module_utils.basic import AnsibleModule