Skip to content

Commit

Permalink
Don't use percent-string anymore
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <[email protected]>
  • Loading branch information
abompard committed Jul 8, 2024
1 parent 9f69f1c commit 13ceaff
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 113 deletions.
2 changes: 1 addition & 1 deletion mirrormanager2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def api_mirroradmins():
site = host.site

if not site:
jsonout = flask.jsonify({"message": "No host or site found for %s" % name})
jsonout = flask.jsonify({"message": f"No host or site found for {name}"})
jsonout.status_code = 400
return jsonout

Expand Down
2 changes: 1 addition & 1 deletion mirrormanager2/crawler/rsync_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _run(self, url):
"time": fields[3],
}
except IndexError:
logger.debug("invalid rsync line: %s\n" % line)
logger.debug("invalid rsync line: %s", line)

# run_rsync() returns a temporary file which needs to be closed
listing.close()
Expand Down
8 changes: 4 additions & 4 deletions mirrormanager2/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ def validate_netblocks(form, field):
max_ipv4_netblock_size = current_app.config.get("MM_IPV4_NETBLOCK_SIZE", "/16")
max_ipv6_netblock_size = current_app.config.get("MM_IPV6_NETBLOCK_SIZE", "/32")

emsg = "Error: IPv4 netblocks larger than %s" % max_ipv4_netblock_size
emsg += ", and IPv6 netblocks larger than %s" % max_ipv6_netblock_size
emsg = f"Error: IPv4 netblocks larger than {max_ipv4_netblock_size}"
emsg += f", and IPv6 netblocks larger than {max_ipv6_netblock_size}"
emsg += " can only be created by mirrormanager administrators."
emsg += " Please ask the mirrormanager administrators for assistance."

ipv4_block = IPy.IP("10.0.0.0%s" % max_ipv4_netblock_size)
ipv6_block = IPy.IP("fec0::%s" % max_ipv6_netblock_size)
ipv4_block = IPy.IP(f"10.0.0.0{max_ipv4_netblock_size}")
ipv6_block = IPy.IP(f"fec0::{max_ipv6_netblock_size}")

try:
ip = IPy.IP(field.data, make_net=True)
Expand Down
12 changes: 5 additions & 7 deletions mirrormanager2/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ def add_admin_to_site(session, site, admin):
admins = [sa.username for sa in query.all()]

if admin in admins:
return "%s was already listed as an admin" % admin
return f"{admin} was already listed as an admin"
else:
sa = model.SiteAdmin(site_id=site_id, username=admin)
session.add(sa)
session.flush()
return "%s added as an admin" % admin
return f"{admin} added as an admin"


def get_mirrors(
Expand Down Expand Up @@ -940,11 +940,9 @@ def compare_dir(hcdir, files):
pass
deleted += 1

message += "Category {} directories updated: {} added: {} deleted {}\n".format(
cat.category.name,
marked_up2date,
added,
deleted,
message += (
f"Category {cat.category.name} directories updated: {marked_up2date} "
f"added: {added} deleted {deleted}\n"
)
host.last_checked_in = datetime.datetime.utcnow()
session.add(hc)
Expand Down
10 changes: 5 additions & 5 deletions mirrormanager2/lib/hostconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@
def validate_config(config):
message = ""
if not isinstance(config, dict):
logging.critical("NON-DICT SUBMITTED: %s" % config)
logging.critical("NON-DICT SUBMITTED: %s", config)
message += "config file is not a dict.\n" "Please update your copy of report_mirror.\n"
return (False, message)
if "version" not in config:
message += "config file has no version field.\n"
return (False, message)
# this field is an integer
if config["version"] != 0:
message += "config file version is not 0, is %s.\n" % (config["version"])
message += "config file version is not 0, is {}.\n".format(config["version"])
return (False, message)

for section in ["global", "site", "host"]:
if section not in config:
message += "config file missing section %s.\n" % (section)
message += f"config file missing section {section}.\n"
return (False, message)

globl = config["global"]
Expand All @@ -56,13 +56,13 @@ def validate_config(config):
site = config["site"]
for opt in ["name", "password"]:
if opt not in site:
message += "config file [site] missing required option %s." "\n" % (opt)
message += f"config file [site] missing required option {opt}." "\n"
return (False, message)

host = config["host"]
for opt in ["name"]:
if opt not in host:
message += "section [host] missing required option %s.\n" % (opt)
message += f"section [host] missing required option {opt}.\n"
return (False, message)

for category in list(config.keys()):
Expand Down
Loading

0 comments on commit 13ceaff

Please sign in to comment.