improved logging
CI / build (push) Successful in 54s

fixed bug with scan path
This commit is contained in:
2025-12-20 13:35:37 +08:00
parent ab27da85af
commit 253483c992
5 changed files with 54 additions and 29 deletions
+23 -2
View File
@@ -11,6 +11,7 @@ from urllib.parse import urlparse, urlunparse, quote, urlencode
from urllib.request import Request
from threading import Thread, Condition
import enum
import certifi
import math
import oidc_client
@@ -25,7 +26,7 @@ from pwo import format_filesize, retry, ExceptionHandlerOutcome
from .config import load_configuration, Config
logger = logging.getLogger('jpacrepo.uploader')
logger = logging.getLogger('jpacrepo-uploader.uploader')
package_file_pattern = re.compile('.*\\.pkg\\.tar\\.(xz|zst|gz)$')
@@ -222,6 +223,7 @@ class JpacrepoClient:
raise RuntimeError(f'Received HTTP error code: {response.code}')
def packages_to_upload(self) -> tuple[Path, ...]:
logger.info('Scanned folders: [%s]' % ', '.join((f"\"{str(path)}\"" for path in self.config.repo_folders)))
package_files: dict[str, Path] = {file.name: file for ext in _supported_compression_formats for package_cache in
self.config.repo_folders
for file in package_cache.glob(f'**/*.pkg.tar.{ext}')
@@ -325,6 +327,20 @@ class JpacrepoClient:
if http_status_code != 201:
raise HttpException(http_status_code)
class LogLevel(str, enum.Enum):
CREATE = 'create'
DELETE = 'delete'
MODIFY = 'modify'
CRITICAL = 'CRITICAL'
FATAL = CRITICAL
ERROR = 'ERROR'
WARNING = 'WARNING'
WARN = WARNING
INFO = 'INFO'
DEBUG = 'DEBUG'
def __str__(self):
return self.value
def main() -> None:
parser = ArgumentParser(
@@ -351,8 +367,13 @@ def main() -> None:
default=False,
action='store_true',
help="Enable HTTP/3 protocol")
parser.add_argument('-l', '--log-level',
default=LogLevel.INFO,
type=LogLevel,
help="Set logging level")
args = parser.parse_args()
logging.basicConfig(encoding='utf-8', level=logging.INFO)
logging.basicConfig(encoding='utf-8', level=logging.getLevelNamesMapping()[args.log_level])
with JpacrepoClient(load_configuration(), **vars(args)) as client:
client.authenticate()
files = client.packages_to_upload()