mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 15:27:17 +00:00
enable lock for web service
This commit is contained in:
parent
c6555cf2c7
commit
9e4e3b701b
@ -929,7 +929,8 @@ def _set_web_parser(root: SubParserAction) -> argparse.ArgumentParser:
|
||||
argparse.ArgumentParser: created argument parser
|
||||
"""
|
||||
parser = root.add_parser("web", help="web server", description="start web server", formatter_class=_formatter)
|
||||
parser.set_defaults(handler=handlers.Web, lock=None, report=False, parser=_parser)
|
||||
parser.set_defaults(handler=handlers.Web, lock=Path(tempfile.gettempdir()) / "ahriman-web.lock", report=False,
|
||||
parser=_parser)
|
||||
return parser
|
||||
|
||||
|
||||
|
@ -21,7 +21,6 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
|
||||
from pathlib import Path
|
||||
from types import TracebackType
|
||||
from typing import Literal, Optional, Type
|
||||
|
||||
@ -68,7 +67,8 @@ class Lock(LazyLogging):
|
||||
architecture(str): repository architecture
|
||||
configuration(Configuration): configuration instance
|
||||
"""
|
||||
self.path = Path(f"{args.lock}_{architecture}") if args.lock is not None else None
|
||||
self.path = args.lock.with_stem(f"{args.lock.stem}_{architecture}") if args.lock is not None else None
|
||||
print(self.path)
|
||||
self.force = args.force
|
||||
self.unsafe = args.unsafe
|
||||
|
||||
|
@ -754,11 +754,10 @@ def test_subparsers_user_remove_architecture(parser: argparse.ArgumentParser) ->
|
||||
|
||||
def test_subparsers_web(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
web command must imply lock, report and parser
|
||||
web command must imply report and parser
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "web"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.lock is None
|
||||
assert not args.report
|
||||
assert args.parser is not None and args.parser()
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import argparse
|
||||
import pytest
|
||||
import tempfile
|
||||
|
||||
@ -7,11 +8,26 @@ from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman import version
|
||||
from ahriman.application.lock import Lock
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import DuplicateRunError, UnsafeRunError
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.internal_status import InternalStatus
|
||||
|
||||
|
||||
def test_path(args: argparse.Namespace, configuration: Configuration) -> None:
|
||||
"""
|
||||
must create path variable correctly
|
||||
"""
|
||||
assert Lock(args, "x86_64", configuration).path is None
|
||||
|
||||
args.lock = Path("/run/ahriman.lock")
|
||||
assert Lock(args, "x86_64", configuration).path == Path("/run/ahriman_x86_64.lock")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
args.lock = Path("/")
|
||||
Lock(args, "x86_64", configuration).path # special case
|
||||
|
||||
|
||||
def test_check_version(lock: Lock, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must check version correctly
|
||||
|
Loading…
Reference in New Issue
Block a user