mirror of
https://github.com/isjerryxiao/pacroller.git
synced 2024-11-22 15:50:43 +08:00
fix several bugs
This commit is contained in:
parent
8de777b4cc
commit
fbcaae3db9
2 changed files with 5 additions and 4 deletions
|
@ -165,7 +165,7 @@ def read_db() -> Iterator[dict]:
|
|||
entry = json.loads(line)
|
||||
yield entry
|
||||
|
||||
def has_previous_error() -> Exception:
|
||||
def has_previous_error() -> str:
|
||||
for entry in read_db():
|
||||
return entry.get('error')
|
||||
else:
|
||||
|
|
|
@ -5,6 +5,7 @@ from typing import List, BinaryIO, Iterator
|
|||
from io import DEFAULT_BUFFER_SIZE
|
||||
from time import mktime
|
||||
from datetime import datetime
|
||||
from signal import SIGINT, SIGTERM, Signals
|
||||
logger = logging.getLogger()
|
||||
|
||||
class UnknownQuestionError(subprocess.SubprocessError):
|
||||
|
@ -19,8 +20,8 @@ def execute_with_io(command: List[str], timeout: int = 3600) -> List[str]:
|
|||
captures stdout and stderr and
|
||||
automatically handles [y/n] questions of pacman
|
||||
'''
|
||||
def terminate(p: subprocess.Popen, timeout: int = 30) -> None:
|
||||
p.terminate()
|
||||
def terminate(p: subprocess.Popen, timeout: int = 30, signal: Signals = SIGTERM) -> None:
|
||||
p.send_signal(signal)
|
||||
try:
|
||||
p.wait(timeout=30)
|
||||
except subprocess.TimeoutExpired:
|
||||
|
@ -55,7 +56,7 @@ def execute_with_io(command: List[str], timeout: int = 3600) -> List[str]:
|
|||
p.stdin.write('y\n')
|
||||
p.stdin.flush()
|
||||
elif line.lower().endswith('[y/n]'):
|
||||
terminate(p)
|
||||
terminate(p, signal=SIGINT)
|
||||
raise UnknownQuestionError(line, output)
|
||||
|
||||
if (ret := p.wait()) != 0:
|
||||
|
|
Loading…
Reference in a new issue