ITP WiP
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
|
||||
from . import Entry
|
||||
from ..io_buffer import IOBuffer
|
||||
@@ -11,12 +11,12 @@ from .single_entry import SingleEntry
|
||||
from .write_entry import WriteEntry
|
||||
|
||||
class EntryFactory:
|
||||
def create_entry(data: dict, io_buffer: IOBuffer) -> Entry:
|
||||
def create_entry(data: dict, work_dir: Path, io_buffer: IOBuffer) -> Entry:
|
||||
entry_type = data.get("type")
|
||||
entry_id = data.get("id")
|
||||
|
||||
if entry_type == "background":
|
||||
return BackgroundEntry(entry_id, data["script"])
|
||||
return BackgroundEntry(entry_id, work_dir, data["script"])
|
||||
|
||||
elif entry_type == "read_stdin":
|
||||
return ReadEntry(entry_id, io_buffer)
|
||||
@@ -27,6 +27,7 @@ class EntryFactory:
|
||||
elif entry_type == "repeat":
|
||||
return RepeatEntry(
|
||||
entry_id,
|
||||
work_dir,
|
||||
data["script"],
|
||||
data.get("timeout"),
|
||||
data.get("limit")
|
||||
@@ -35,6 +36,7 @@ class EntryFactory:
|
||||
elif entry_type == "single":
|
||||
return SingleEntry(
|
||||
entry_id,
|
||||
work_dir,
|
||||
data["script"],
|
||||
data.get("timeout"),
|
||||
data.get("limit")
|
||||
@@ -51,6 +53,8 @@ class EntryFactory:
|
||||
entry.id = data["id"]
|
||||
|
||||
if isinstance(entry, SingleEntry):
|
||||
if "work_dir" in data:
|
||||
entry.work_dir = Path(data["work_dir"])
|
||||
if "script" in data:
|
||||
entry.script = data["script"]
|
||||
if "timeout" in data:
|
||||
@@ -69,6 +73,8 @@ class EntryFactory:
|
||||
entry.timed_out = bool(data["timed_out"])
|
||||
|
||||
if isinstance(entry, RepeatEntry):
|
||||
if "work_dir" in data:
|
||||
entry.work_dir = Path(data["work_dir"])
|
||||
if "script" in data:
|
||||
entry.script = data["script"]
|
||||
if "timeout" in data:
|
||||
@@ -87,6 +93,8 @@ class EntryFactory:
|
||||
entry.timed_out = bool(data["timed_out"])
|
||||
|
||||
elif isinstance(entry, BackgroundEntry):
|
||||
if "work_dir" in data:
|
||||
entry.work_dir = Path(data["work_dir"])
|
||||
if "script" in data:
|
||||
entry.script = data["script"]
|
||||
if "stdout" in data:
|
||||
|
||||
Reference in New Issue
Block a user