Files
Andreas Wrede 0543266c92 Major refactoring of the codebase, including restructuring of files and directories, renaming of modules and classes, and improvements to the overall organization and readability of the code. This refactoring aims to enhance maintainability, scalability, and clarity of the codebase while preserving existing functionality. The changes include:
- Restructuring of the project directory into client and server components
- Renaming of modules and classes to better reflect their purpose and functionality
- Moving common utilities and configurations to a shared location
- Updating import statements to reflect the new structure
- Adding new documentation files for better clarity on various aspects of the project
- Removing deprecated or unused code to streamline the codebase
- Ensuring that all existing functionality is preserved and that the codebase remains functional after the refactoring.
2026-03-29 11:13:40 -04:00

36 lines
841 B
Python

"""Utility helpers extracted from the original script."""
def shortname(name: str) -> str:
return name.split(".")[0]
def dur(sec: int) -> str:
sec = int(sec)
h = int(sec / 3600)
m = int((sec - h * 3600) / 60)
s = int((sec - h * 3600) % 60)
if h > 0:
return "%d:%02d:%02d" % (h, m, s)
if m > 0:
return "%d:%02d" % (m, s)
return "0:%02d" % s
def initlog(logfile: str):
"""Open logfile for appending; fall back to creating it or returning stderr.
This mirrors the original behaviour from the monolithic script.
"""
try:
return open(logfile, "a+")
except Exception:
pass
try:
return open(logfile, "w")
except Exception as e:
import sys
print(f"cannot open logfile {logfile}, using STDERR: {e}")
return sys.stderr