proud-dentist-22844
05/15/2021, 3:06 PMDigest
? I can do CreateDigest([FileContent(script_path, <string>)])
but how do I grab the contents of a separate file to add to FileContent
? Can I just open()
it within the @rule
?
Here's the input_digest in the plugin: https://github.com/st2sandbox/st2/blob/pants/pants-plugins/uses_services/platform.py#L30-L37
Here's the script that it needs to run: https://github.com/st2sandbox/st2/blob/pants/pants-plugins/uses_services/inspect_platform.py
Note that the file to include is in the same directory as the plugin python file.hundreds-father-404
05/15/2021, 3:21 PMproud-dentist-22844
05/15/2021, 3:22 PMPathGlobs
?hundreds-father-404
05/15/2021, 3:22 PMhundreds-father-404
05/15/2021, 3:24 PMproud-dentist-22844
05/15/2021, 3:28 PMscript_path = "pants-plugins/uses_services/inspect_platform.py"
script_digest = await Get(Digest, PathGlobs([script_path]))
proud-dentist-22844
05/15/2021, 3:28 PMhundreds-father-404
05/15/2021, 3:30 PMhundreds-father-404
05/15/2021, 3:31 PMproud-dentist-22844
05/15/2021, 3:31 PMproud-dentist-22844
05/15/2021, 3:31 PMhundreds-father-404
05/15/2021, 3:32 PMhundreds-father-404
05/15/2021, 3:33 PMproud-dentist-22844
05/15/2021, 3:38 PMscript_path = "pants-plugins/uses_services/inspect_platform.py"
script_digest = await Get(
Digest,
PathGlobs([script_path]),
glob_match_error_behavior=GlobMatchErrorBehavior.error,
)
result = await Get(
ProcessResult,
VenvPexProcess(
distro_pex,
argv=[script_path],
input_digest=script_digest,
description=f"Introspecting platform (arch, os, distro)",
# this can change from run to run, so don't cache results.
cache_scope=ProcessCacheScope.PER_RESTART, # NEVER?
level=LogLevl.DEBUG,
),
)
proud-dentist-22844
05/15/2021, 3:43 PMenough-analyst-54434
05/15/2021, 3:51 PMopen()
or importlib.resources
or an embedded bytes literal.proud-dentist-22844
05/15/2021, 3:57 PMproud-dentist-22844
05/15/2021, 3:57 PMenough-analyst-54434
05/15/2021, 3:58 PMproud-dentist-22844
05/15/2021, 4:00 PMenough-analyst-54434
05/15/2021, 5:19 PMopen(os.path.join(os.path.dirname(__file__), "inspect_platform.py"))
.