forked from postgrespro/testgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinternal_platform_utils.py
More file actions
62 lines (50 loc) · 2.14 KB
/
internal_platform_utils.py
File metadata and controls
62 lines (50 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from __future__ import annotations
import enum
import typing
from testgres.operations.os_ops import OsOperations
class InternalPlatformUtils:
class FindPostmasterResultCode(enum.Enum):
ok = 0
not_found = 1,
not_implemented = 2
many_processes = 3
has_problems = 4
class FindPostmasterResult:
code: InternalPlatformUtils.FindPostmasterResultCode
pid: typing.Optional[int]
def __init__(
self,
code: InternalPlatformUtils.FindPostmasterResultCode,
pid: typing.Optional[int]
):
assert type(code) is InternalPlatformUtils.FindPostmasterResultCode
assert pid is None or type(pid) is int
self.code = code
self.pid = pid
return
@staticmethod
def create_ok(pid: int) -> InternalPlatformUtils.FindPostmasterResult:
assert type(pid) is int
return __class__(InternalPlatformUtils.FindPostmasterResultCode.ok, pid)
@staticmethod
def create_not_found() -> InternalPlatformUtils.FindPostmasterResult:
return __class__(InternalPlatformUtils.FindPostmasterResultCode.not_found, None)
@staticmethod
def create_not_implemented() -> InternalPlatformUtils.FindPostmasterResult:
return __class__(InternalPlatformUtils.FindPostmasterResultCode.not_implemented, None)
@staticmethod
def create_many_processes() -> InternalPlatformUtils.FindPostmasterResult:
return __class__(InternalPlatformUtils.FindPostmasterResultCode.many_processes, None)
@staticmethod
def create_has_problems() -> InternalPlatformUtils.FindPostmasterResult:
return __class__(InternalPlatformUtils.FindPostmasterResultCode.has_problems, None)
def FindPostmaster(
self,
os_ops: OsOperations,
bin_dir: str,
data_dir: str
) -> FindPostmasterResult:
assert isinstance(os_ops, OsOperations)
assert type(bin_dir) is str
assert type(data_dir) is str
raise NotImplementedError("InternalPlatformUtils::FindPostmaster is not implemented.")