fixed bug with scan path
This commit is contained in:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "jpacrepo-uploader"
|
||||
version = "0.0.4"
|
||||
version = "0.0.5"
|
||||
authors = [
|
||||
{ name="Walter Oggioni", email="oggioni.walter@gmail.com" },
|
||||
]
|
||||
|
||||
@@ -2,44 +2,44 @@
|
||||
# This file is autogenerated by pip-compile with Python 3.13
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile --allow-unsafe --extra=dev --output-file=requirements-dev.txt
|
||||
# pip-compile --cert=None --client-cert=None --extra=dev --index-url=None --output-file=requirements-dev.txt --pip-args=None --strip-extras pyproject.toml
|
||||
#
|
||||
--index-url https://gitea.woggioni.net/api/packages/woggioni/pypi/simple
|
||||
--extra-index-url https://pypi.org/simple
|
||||
|
||||
asttokens==3.0.0
|
||||
asttokens==3.0.1
|
||||
# via stack-data
|
||||
build==1.3.0
|
||||
# via
|
||||
# jpacrepo-uploader (pyproject.toml)
|
||||
# pip-tools
|
||||
certifi==2025.8.3
|
||||
certifi==2025.11.12
|
||||
# via
|
||||
# jpacrepo-uploader (pyproject.toml)
|
||||
# requests
|
||||
cffi==2.0.0
|
||||
# via cryptography
|
||||
charset-normalizer==3.4.3
|
||||
charset-normalizer==3.4.4
|
||||
# via requests
|
||||
click==8.3.0
|
||||
click==8.3.1
|
||||
# via pip-tools
|
||||
cryptography==46.0.2
|
||||
cryptography==46.0.3
|
||||
# via secretstorage
|
||||
decorator==5.2.1
|
||||
# via
|
||||
# ipdb
|
||||
# ipython
|
||||
docutils==0.22.2
|
||||
docutils==0.22.4
|
||||
# via readme-renderer
|
||||
executing==2.2.1
|
||||
# via stack-data
|
||||
id==1.5.0
|
||||
# via twine
|
||||
idna==3.10
|
||||
idna==3.11
|
||||
# via requests
|
||||
ipdb==0.13.13
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
ipython==9.6.0
|
||||
ipython==9.8.0
|
||||
# via ipdb
|
||||
ipython-pygments-lexers==1.1.1
|
||||
# via ipython
|
||||
@@ -55,11 +55,13 @@ jeepney==0.9.0
|
||||
# via
|
||||
# keyring
|
||||
# secretstorage
|
||||
keyring==25.6.0
|
||||
keyring==25.7.0
|
||||
# via twine
|
||||
librt==0.7.4
|
||||
# via mypy
|
||||
markdown-it-py==4.0.0
|
||||
# via rich
|
||||
matplotlib-inline==0.1.7
|
||||
matplotlib-inline==0.2.1
|
||||
# via ipython
|
||||
mdurl==0.1.2
|
||||
# via markdown-it-py
|
||||
@@ -67,11 +69,11 @@ more-itertools==10.8.0
|
||||
# via
|
||||
# jaraco-classes
|
||||
# jaraco-functools
|
||||
mypy==1.18.2
|
||||
mypy==1.19.1
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
mypy-extensions==1.1.0
|
||||
# via mypy
|
||||
nh3==0.3.0
|
||||
nh3==0.3.2
|
||||
# via readme-renderer
|
||||
oidc-client==0.2.6
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
@@ -85,7 +87,7 @@ pathspec==0.12.1
|
||||
# via mypy
|
||||
pexpect==4.9.0
|
||||
# via ipython
|
||||
pip-tools==7.5.0
|
||||
pip-tools==7.5.2
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
progress==1.6.1
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
@@ -122,9 +124,9 @@ requests-toolbelt==1.0.0
|
||||
# via twine
|
||||
rfc3986==2.0.0
|
||||
# via twine
|
||||
rich==14.1.0
|
||||
rich==14.2.0
|
||||
# via twine
|
||||
secretstorage==3.4.0
|
||||
secretstorage==3.5.0
|
||||
# via keyring
|
||||
stack-data==0.6.3
|
||||
# via ipython
|
||||
@@ -134,14 +136,14 @@ traitlets==5.14.3
|
||||
# matplotlib-inline
|
||||
twine==6.2.0
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
types-pycurl==7.45.7.20250926
|
||||
types-pycurl==7.45.7.20251101
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
typing-extensions==4.15.0
|
||||
# via
|
||||
# jpacrepo-uploader (pyproject.toml)
|
||||
# mypy
|
||||
# pwo
|
||||
urllib3==2.5.0
|
||||
urllib3==2.6.2
|
||||
# via
|
||||
# requests
|
||||
# twine
|
||||
@@ -151,7 +153,5 @@ wheel==0.45.1
|
||||
# via pip-tools
|
||||
|
||||
# The following packages are considered to be unsafe in a requirements file:
|
||||
pip==25.2
|
||||
# via pip-tools
|
||||
setuptools==80.9.0
|
||||
# via pip-tools
|
||||
# pip
|
||||
# setuptools
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
# This file is autogenerated by pip-compile with Python 3.13
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile --allow-unsafe --output-file=requirements.txt
|
||||
# pip-compile --cert=None --client-cert=None --index-url=None --output-file=requirements.txt --pip-args=None --strip-extras pyproject.toml
|
||||
#
|
||||
--index-url https://gitea.woggioni.net/api/packages/woggioni/pypi/simple
|
||||
--extra-index-url https://pypi.org/simple
|
||||
|
||||
certifi==2025.8.3
|
||||
certifi==2025.11.12
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
oidc-client==0.2.6
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
@@ -17,7 +17,7 @@ pwo==0.0.7
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
pycurl==7.45.7
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
types-pycurl==7.45.7.20250926
|
||||
types-pycurl==7.45.7.20251101
|
||||
# via jpacrepo-uploader (pyproject.toml)
|
||||
typing-extensions==4.15.0
|
||||
# via
|
||||
|
||||
@@ -5,9 +5,12 @@ from pathlib import Path
|
||||
from itertools import chain
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
import logging
|
||||
|
||||
_config_file_name = 'client.properties'
|
||||
|
||||
logger = logging.getLogger('jpacrepo-uploader.config')
|
||||
|
||||
|
||||
@dataclass
|
||||
class Config:
|
||||
@@ -27,7 +30,7 @@ config_file_candidates = [
|
||||
.filter(Path.exists)),
|
||||
(Maybe.of_nullable(environ['HOME'])
|
||||
.map(Path)
|
||||
.map(lambda home: home / '.config' / _config_file_name)
|
||||
.map(lambda home: home / '.config' / 'jpacrepo' /_config_file_name)
|
||||
.filter(Path.exists))
|
||||
]
|
||||
|
||||
@@ -41,6 +44,7 @@ def load_configuration() -> Config:
|
||||
client_secret: Optional[str] = None
|
||||
for config_file_maybe in config_file_candidates:
|
||||
def process_configuration(config_file: Path) -> None:
|
||||
logger.debug('Looking for configuration file in %s' % config_file)
|
||||
nonlocal server_url, auth_server_url, client_id, client_secret
|
||||
config = RawConfigParser()
|
||||
with open(config_file, 'r') as lines:
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user