missionpanel 1.2.5__tar.gz → 1.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {missionpanel-1.2.5 → missionpanel-1.2.7}/PKG-INFO +1 -1
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/example/__init__.py +1 -0
- missionpanel-1.2.7/missionpanel/example/subprocess.py +41 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel.egg-info/PKG-INFO +1 -1
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel.egg-info/SOURCES.txt +1 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/setup.py +1 -1
- {missionpanel-1.2.5 → missionpanel-1.2.7}/LICENSE +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/README.md +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/__init__.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/example/rsshub.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/example/ttrss.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/handler/__init__.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/handler/handler.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/orm/__init__.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/orm/core.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/orm/handler.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/submitter/__init__.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/submitter/abc.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/submitter/asynchronous.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel/submitter/submitter.py +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel.egg-info/dependency_links.txt +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel.egg-info/requires.txt +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/missionpanel.egg-info/top_level.txt +0 -0
- {missionpanel-1.2.5 → missionpanel-1.2.7}/setup.cfg +0 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
import abc
|
2
|
+
import asyncio
|
3
|
+
import logging
|
4
|
+
import chardet
|
5
|
+
from typing import List, Callable
|
6
|
+
from missionpanel.handler import AsyncHandler
|
7
|
+
from missionpanel.orm.core import Mission
|
8
|
+
from missionpanel.orm.handler import Attempt
|
9
|
+
|
10
|
+
|
11
|
+
class SubprocessAsyncHandler(AsyncHandler, abc.ABC):
|
12
|
+
def getLogger(self) -> logging.Logger:
|
13
|
+
return logging.getLogger("SubprocessAsyncHandler")
|
14
|
+
|
15
|
+
async def __readline_info(self, f):
|
16
|
+
async for line in f:
|
17
|
+
try:
|
18
|
+
line = line.decode(chardet.detect(line)['encoding']).strip()
|
19
|
+
except UnicodeDecodeError:
|
20
|
+
line = line.strip()
|
21
|
+
self.getLogger().info('stdout | %s' % line)
|
22
|
+
|
23
|
+
async def __readline_debug(self, f):
|
24
|
+
async for line in f:
|
25
|
+
try:
|
26
|
+
line = line.decode(chardet.detect(line)['encoding']).strip()
|
27
|
+
except UnicodeDecodeError:
|
28
|
+
line = line.strip()
|
29
|
+
self.getLogger().info('stderr | %s' % line)
|
30
|
+
|
31
|
+
@abc.abstractmethod
|
32
|
+
async def construct_command(self, mission: Mission, attempt: Attempt) -> List[str]:
|
33
|
+
raise NotImplementedError("Subclasses must implement construct_command")
|
34
|
+
|
35
|
+
async def execute_mission(self, mission: Mission, attempt: Attempt) -> bool:
|
36
|
+
proc = await asyncio.create_subprocess_exec(
|
37
|
+
*(await self.construct_command(mission, attempt)),
|
38
|
+
stdout=asyncio.subprocess.PIPE,
|
39
|
+
stderr=asyncio.subprocess.PIPE)
|
40
|
+
await asyncio.gather(self.__readline_info(proc.stdout), self.__readline_debug(proc.stderr))
|
41
|
+
return (await proc.wait()) == 0
|
@@ -9,6 +9,7 @@ missionpanel.egg-info/requires.txt
|
|
9
9
|
missionpanel.egg-info/top_level.txt
|
10
10
|
missionpanel/example/__init__.py
|
11
11
|
missionpanel/example/rsshub.py
|
12
|
+
missionpanel/example/subprocess.py
|
12
13
|
missionpanel/example/ttrss.py
|
13
14
|
missionpanel/handler/__init__.py
|
14
15
|
missionpanel/handler/handler.py
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|