process null lock file

This commit is contained in:
Evgenii Alekseev 2021-03-11 01:58:33 +03:00
parent 262d8d8647
commit 2fca108fa4
4 changed files with 34 additions and 10 deletions

View File

@ -2,6 +2,14 @@
Wrapper for managing custom repository inspired by [repo-scripts](https://github.com/arcan1s/repo-scripts). Wrapper for managing custom repository inspired by [repo-scripts](https://github.com/arcan1s/repo-scripts).
## Features
* Install-configure-forget manager for own repository
* VCS packages support
* Sign support with gpg
* Synchronization to remote services and report generation
* Repository status interface
## Installation and run ## Installation and run
* Install package as usual. * Install package as usual.

View File

@ -24,7 +24,7 @@ source=("https://github.com/arcan1s/ahriman/releases/download/$pkgver/$pkgname-$
'ahriman.sudoers' 'ahriman.sudoers'
'ahriman.sysusers' 'ahriman.sysusers'
'ahriman.tmpfiles') 'ahriman.tmpfiles')
sha512sums=('c1051769f0ce307c9a9a69ba721a3e5abe0a0df0e7ce07f1e482f931a52e715820cda69186c8d65ee8407f1f013c51c2633b15f35e1964732af3c4d3e137665a' sha512sums=('c9d270fd1f9474071fe1e1b3e1a2ca5e1cff50460af269ce9bc33c228d93b8ed2faa57e6f08c38360da3ccdec0eb48715583c5d69499373ebfdaef5facb0f6d6'
'8c9b5b63ac3f7b4d9debaf801a1e9c060877c33d3ecafe18010fcca778e5fa2f2e46909d3d0ff1b229ff8aa978445d8243fd36e1fc104117ed678d5e21901167' '8c9b5b63ac3f7b4d9debaf801a1e9c060877c33d3ecafe18010fcca778e5fa2f2e46909d3d0ff1b229ff8aa978445d8243fd36e1fc104117ed678d5e21901167'
'13718afec2c6786a18f0b223ef8e58dccf0688bca4cdbe203f14071f5031ed20120eb0ce38b52c76cfd6e8b6581a9c9eaa2743eb11abbaca637451a84c33f075' '13718afec2c6786a18f0b223ef8e58dccf0688bca4cdbe203f14071f5031ed20120eb0ce38b52c76cfd6e8b6581a9c9eaa2743eb11abbaca637451a84c33f075'
'55b20f6da3d66e7bbf2add5d95a3b60632df121717d25a993e56e737d14f51fe063eb6f1b38bd81cc32e05db01c0c1d80aaa720c45cde87f238d8b46cdb8cbc4') '55b20f6da3d66e7bbf2add5d95a3b60632df121717d25a993e56e737d14f51fe063eb6f1b38bd81cc32e05db01c0c1d80aaa720c45cde87f238d8b46cdb8cbc4')

View File

@ -5,7 +5,7 @@
</head> </head>
<body> <body>
<h1>ArchLinux custom repository</h1> <h1>Archlinux custom repository</h1>
{% if pgp_key is not none %} {% if pgp_key is not none %}
<p>This repository is signed with <a href="http://keys.gnupg.net/pks/lookup?search=0x{{ pgp_key|e }}" title="key search">{{ pgp_key|e }}</a>.</p> <p>This repository is signed with <a href="http://keys.gnupg.net/pks/lookup?search=0x{{ pgp_key|e }}" title="key search">{{ pgp_key|e }}</a>.</p>

View File

@ -20,6 +20,8 @@
import argparse import argparse
import os import os
from typing import Optional
import ahriman.version as version import ahriman.version as version
from ahriman.application.application import Application from ahriman.application.application import Application
@ -38,7 +40,22 @@ def _get_config(config_path: str) -> Configuration:
return config return config
def _remove_lock(path: str) -> None: def _lock_check(path: Optional[str]) -> None:
if path is None:
return
if os.path.exists(args.lock):
raise RuntimeError('Another application instance is run')
def _lock_create(path: Optional[str]) -> None:
if path is None:
return
open(path, 'w').close()
def _lock_remove(path: Optional[str]) -> None:
if path is None:
return
if os.path.exists(path): if os.path.exists(path):
os.remove(path) os.remove(path)
@ -120,22 +137,21 @@ if __name__ == '__main__':
update_parser.set_defaults(fn=update) update_parser.set_defaults(fn=update)
web_parser = subparsers.add_parser('web', description='start web server') web_parser = subparsers.add_parser('web', description='start web server')
web_parser.set_defaults(fn=web, lock='/tmp/ahriman-web.lock') web_parser.set_defaults(fn=web, lock=None)
args = parser.parse_args() args = parser.parse_args()
if args.force: if args.force:
_remove_lock(args.lock) _lock_remove(args.lock)
if os.path.exists(args.lock): _lock_check(args.lock)
raise RuntimeError('Another application instance is run')
if 'fn' not in args: if 'fn' not in args:
parser.print_help() parser.print_help()
exit(1) exit(1)
try: try:
open(args.lock, 'w').close() _lock_create(args.lock)
args.fn(args) args.fn(args)
finally: finally:
_remove_lock(args.lock) _lock_remove(args.lock)