Compare commits
2 commits
0562772dc8
...
09f39befa7
Author | SHA1 | Date | |
---|---|---|---|
09f39befa7 | |||
24f0338897 |
2 changed files with 23 additions and 21 deletions
|
@ -1,4 +1,4 @@
|
||||||
__version__ = "0.2.5-5"
|
__version__ = "v0.2.5-6"
|
||||||
__author__ = "Reid D. 'arrdem' McKenzie <me@arrdem.com>"
|
__author__ = "Reid D. 'arrdem' McKenzie <me@arrdem.com>"
|
||||||
__copyright__ = "Copyright 2020"
|
__copyright__ = "Copyright 2020"
|
||||||
__license__ = "https://anticapitalist.software/"
|
__license__ = "https://anticapitalist.software/"
|
||||||
|
|
|
@ -17,11 +17,14 @@ if sys.version_info <= (3, 9, 0):
|
||||||
Path.readlink = lambda p: Path(os.readlink(str(p)))
|
Path.readlink = lambda p: Path(os.readlink(str(p)))
|
||||||
|
|
||||||
|
|
||||||
def sh(global_config,
|
def sh(global_config, cmd: List[str], /, env: Optional[dict] = None):
|
||||||
cmd: List[str], /,
|
shell = (
|
||||||
env: Optional[dict] = None):
|
(global_config or {})
|
||||||
|
.get("cram", {})
|
||||||
shell = (global_config or {}).get("cram", {}).get("task", {}).get("apply", {}).get("shell", SHELL)
|
.get("task", {})
|
||||||
|
.get("apply", {})
|
||||||
|
.get("shell", SHELL)
|
||||||
|
)
|
||||||
|
|
||||||
prefix = []
|
prefix = []
|
||||||
if env:
|
if env:
|
||||||
|
@ -93,21 +96,20 @@ class Package(object):
|
||||||
def expandvars(s: str) -> str:
|
def expandvars(s: str) -> str:
|
||||||
def _repl(m: re.Match) -> str:
|
def _repl(m: re.Match) -> str:
|
||||||
var = m.group(0).lower()
|
var = m.group(0).lower()
|
||||||
match var:
|
if var == "${hostname}":
|
||||||
case "${hostname}":
|
return os.uname()[1].split(".")[0]
|
||||||
return os.uname()[1].split(".")[0]
|
elif var == "${fqdn}":
|
||||||
case "${fqdn}":
|
return os.uname()[1]
|
||||||
return os.uname()[1]
|
elif var == "${home}":
|
||||||
case "${home}":
|
return os.path.expanduser("~")
|
||||||
return os.path.expanduser("~")
|
elif var == "${uname}" | "${sysname}":
|
||||||
case "${uname}" | "${sysname}":
|
return platform.system().lower()
|
||||||
return platform.system().lower()
|
elif var == "${arch}":
|
||||||
case "${arch}":
|
return platform.machine()
|
||||||
return platform.machine()
|
elif var == "${release}":
|
||||||
case "${release}":
|
return platform.release()
|
||||||
return platform.release()
|
else:
|
||||||
case _:
|
return os.path.expandvars(m.group(0))
|
||||||
return os.path.expandvars(m.group(0))
|
|
||||||
|
|
||||||
s = re.sub(r"\${?([^\s}]+)}?", "${\\1}", s)
|
s = re.sub(r"\${?([^\s}]+)}?", "${\\1}", s)
|
||||||
return re.sub(r"\$\{.*?\}", _repl, s)
|
return re.sub(r"\$\{.*?\}", _repl, s)
|
||||||
|
|
Loading…
Reference in a new issue