MCPcopy Create free account
hub / github.com/StackStorm/st2 / get_platform

Function get_platform

pants-plugins/uses_services/platform_rules.py:41–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39 level=LogLevel.DEBUG,
40)
41async def get_platform() -> Platform:
42 script_path = "./inspect_platform.py"
43
44 # pants is already watching this directory as it is under a source root.
45 # So, we don't need to double watch with PathGlobs, just open it.
46 with open(inspect_platform_full_path, "rb") as script_file:
47 script_contents = script_file.read()
48
49 script_digest, distro_pex = await MultiGet(
50 Get(
51 Digest,
52 CreateDigest([FileContent(script_path, script_contents)]),
53 ),
54 Get(
55 VenvPex,
56 PexRequest(
57 output_filename="distro.pex",
58 internal_only=True,
59 requirements=PexRequirements({"distro"}),
60 ),
61 ),
62 )
63
64 result = await Get(
65 ProcessResult,
66 VenvPexProcess(
67 distro_pex,
68 argv=(script_path,),
69 input_digest=script_digest,
70 description="Introspecting platform (arch, os, distro)",
71 # this can change from run to run, so don't cache results.
72 cache_scope=ProcessCacheScope.PER_RESTART_SUCCESSFUL,
73 level=LogLevel.DEBUG,
74 ),
75 )
76 platform = json.loads(result.stdout)
77 return Platform(**platform)
78
79
80def rules():

Callers

nothing calls this directly

Calls 2

PlatformClass · 0.90
readMethod · 0.45

Tested by

no test coverage detected