Skip to content
Merged
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
10 changes: 5 additions & 5 deletions contrib/python/compare_RecordsConfigcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
try:
src_dir = sys.argv[1]
except IndexError:
print("Usage: %s [trafficserver_source_dir]" % sys.argv[0])
print(f"Usage: {sys.argv[0]} [trafficserver_source_dir]")
print("Compares values in RecordsConfig.cc with the default records.config file")
sys.exit(1)

Expand All @@ -45,7 +45,7 @@
rc_doc = {} # documented values

# Process RecordsConfig.cc
with open("%s/mgmt/RecordsConfig.cc" % src_dir) as fh:
with open(f"{src_dir}/mgmt/RecordsConfig.cc") as fh:
cc_re = re.compile(r'\{RECT_(?:CONFIG|LOCAL), "([^"]+)", RECD_([A-Z]+), (.+?), ')
for line in fh:
m = cc_re.search(line)
Expand All @@ -56,7 +56,7 @@
rc_cc[m.group(1)] = (m.group(2), value)

# Process records.config.default.in
with open("%s/configs/records.config.default.in" % src_dir) as fh:
with open(f"{src_dir}/configs/records.config.default.in") as fh:
in_re = re.compile(r'(?:CONFIG|LOCAL) (\S+)\s+(\S+)\s+(\S+)')
for line in fh:
m = in_re.match(line)
Expand All @@ -65,7 +65,7 @@

# Process records.config documentation.
# eg. .. ts:cv:: CONFIG proxy.config.proxy_binary STRING traffic_server
with open("%s/doc/admin-guide/files/records.config.en.rst" % src_dir) as fh:
with open(f"{src_dir}/doc/admin-guide/files/records.config.en.rst") as fh:
doc_re = re.compile(r'ts:cv:: CONFIG (\S+)\s+(\S+)\s+(\S+)')
for line in fh:
m = doc_re.search(line)
Expand Down Expand Up @@ -109,4 +109,4 @@
print()
print("Stale documentation:")
for s in sorted(stale):
print("\t%s" % (s))
print(f"\t{s}")
4 changes: 2 additions & 2 deletions contrib/python/compare_records_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def parse_records_file(filename):
try:
settings[parts[1]] = parts[3]
except IndexError:
sys.stderr.write("Skipping malformed line: %s\n" % line)
sys.stderr.write(f"Skipping malformed line: {line}\n")
continue
return settings

Expand All @@ -61,7 +61,7 @@ def compare_settings(old, new):
# Skip predefined values
continue
if old[key] != new[key]:
print("%s %s -> %s" % (key, old[key], new[key]))
print(f"{key} {old[key]} -> {new[key]}")


if __name__ == '__main__':
Expand Down
8 changes: 4 additions & 4 deletions doc/checkvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
min_sphinx_version_info = (1, 7, 5)
min_sphinx_version = '.'.join(str(x) for x in min_sphinx_version_info)

print('checking for sphinx version >= {0}... '.format(min_sphinx_version), end="")
print(f'checking for sphinx version >= {min_sphinx_version}... ', end="")
# Need at least 1.5.1 to use svg
# version >= 1.2 guarantees sphinx.version_info is available.
try:
import sphinx

if 'version_info' in dir(sphinx):
print('Found Sphinx version {0}'.format(sphinx.version_info))
print(f'Found Sphinx version {sphinx.version_info}')
else:
version = sphinx.__version__
print('Found Sphinx version (old) {0}'.format(sphinx.__version__))
print(f'Found Sphinx version (old) {sphinx.__version__}')
sphinx.version_info = version.split('.')

if sphinx.version_info < min_sphinx_version_info:
print('sphinx version is older than {0}'.format(min_sphinx_version))
print(f'sphinx version is older than {min_sphinx_version}')
sys.exit(1)

except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

# General information about the project.
project = u'Apache Traffic Server'
copyright = u'{}, dev@trafficserver.apache.org'.format(date.today().year)
copyright = f'{date.today().year}, dev@trafficserver.apache.org'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
12 changes: 6 additions & 6 deletions plugins/experimental/ssl_session_reuse/tests/plug-load.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@
server.addResponse("sessionfile.log", request_header, response_header)
ts.Disk.records_config.update({
'proxy.config.diags.debug.enabled': 1,
'proxy.config.diags.debug.tags': '{0}'.format(pluginName),
'proxy.config.diags.debug.tags': f'{pluginName}',
})

ts.Disk.plugin_config.AddLine(
'# {1}/{0}.so {2}'.format(pluginName, path, configFile)
f'# {path}/{pluginName}.so {configFile}'
)
ts.Disk.remap_config.AddLine(
'map http://www.example.com http://127.0.0.1:{0}'.format(server.Variables.Port)
f'map http://www.example.com http://127.0.0.1:{server.Variables.Port}'
)

goldFile = os.path.join(Test.RunDirectory, "{0}.gold".format(pluginName))
goldFile = os.path.join(Test.RunDirectory, f"{pluginName}.gold")
with open(goldFile, 'w+') as jf:
jf.write("``loading plugin ``{0}.so``".format(pluginName))
jf.write(f"``loading plugin ``{pluginName}.so``")

# call localhost straight
tr = Test.AddTestRun()
tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com" --verbose'.format(ts.Variables.port)
tr.Processes.Default.Command = f'curl --proxy 127.0.0.1:{ts.Variables.port} "http://www.example.com" --verbose'
tr.Processes.Default.ReturnCode = 0
# time delay as proxy.config.http.wait_for_cache could be broken
tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port))
Expand Down
14 changes: 7 additions & 7 deletions plugins/experimental/traffic_dump/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def write_sessions(sessions, filename, indent):
new_json["sessions"] = deepcopy(sessions)
with open(filename, "w") as f:
json.dump(new_json, f, ensure_ascii=False, indent=indent)
logging.debug("{} has {} sessions".format(filename, len(sessions)))
logging.debug(f"{filename} has {len(sessions)} sessions")


class ParseJSONError(PostProcessError):
Expand Down Expand Up @@ -274,11 +274,11 @@ def readAndCombine(replay_dir, num_sessions_per_file, indent, fabricate_proxy_re
session_count += 1
transaction_count += len(session["transactions"])
if len(sessions) >= num_sessions_per_file:
write_sessions(sessions, "{}/{}_{}.json".format(out_dir, base_name, batch_count), indent)
write_sessions(sessions, f"{out_dir}/{base_name}_{batch_count}.json", indent)
sessions = []
batch_count += 1
if sessions:
write_sessions(sessions, "{}/{}_{}.json".format(out_dir, base_name, batch_count), indent)
write_sessions(sessions, f"{out_dir}/{base_name}_{batch_count}.json", indent)

return session_count, transaction_count, error_count

Expand Down Expand Up @@ -409,17 +409,17 @@ def main():
transaction_count += count_tuple[1]
for e in count_tuple[2]:
errors[e] += count_tuple[2][e]
summary = "Total {} sessions and {} transactions.".format(session_count, transaction_count)
summary = f"Total {session_count} sessions and {transaction_count} transactions."
logging.info(summary)
if errors:
logging.info("Total errors:")
for e in errors:
logging.info("{}: {}".format(e, errors[e]))
logging.info(f"{e}: {errors[e]}")
else:
logging.info("Total errors: 0")

with open("{}/summary.txt".format(args.out_dir), "w", encoding="ascii") as f:
f.write("{}\n".format(summary))
with open(f"{args.out_dir}/summary.txt", "w", encoding="ascii") as f:
f.write(f"{summary}\n")


if __name__ == "__main__":
Expand Down