I’ve been running Linux for 4 years, but this still hurts to read
Can we never joke about sensitive topics?
Isn’t humor like, our primary coping mechanism for dealing with dark topics?
that is a little more complicated
p.communicate()
will take a string (or bytes) and send it to the stdin of the process, then wait for p
to finish execution
there are ways to stream input into a running process (without waiting for the process to finish), but I don’t remember how off the top of my head
from shutil import which
from subprocess import Popen, PIPE, run
from pathlib import Path
LS = which('ls')
REV = which('rev')
ls = run([LS, Path.home()], stdout=PIPE)
p = Popen([REV], stdin=PIPE, stdout=PIPE)
stdout, stderr = p.communicate(ls.stdout)
print(stdout.decode('utf-8'))
nushell is pretty good. I use it for my main shell
although, i still prefer writing utilities in python over nu scripts
just use python instead.
subprocess.run()
, to call to system utilspathlib.Path
for file paths and reading/writing to filesshutil.which()
to resolve utilities from your Path
env varHere’s an example of some python i use to launch vscode (and terminals, but that requires dbus
)
from pathlib import Path
from shutil import which
from subprocess import run
def _run(cmds: list[str], cwd=None):
p = run(cmds, cwd=cwd)
# raises an error if return code is non-zero
p.check_returncode()
return p
VSCODE = which('code')
SUDO = which('sudo')
DOCKER = which('docker')
proj_dir = Path('/path/to/repo')
docker_compose = proj_dir / 'docker/'
windows = [
proj_dir / 'code',
proj_dir / 'more_code',
proj_dir / 'even_more_code/subfolder',
]
for w in windows:
_run([VSCODE, w])
_run([SUDO, DOCKER, 'compose', 'up', '-d'], cwd=docker_compose)
The technology behind the registry is fine (which is what I think @VinesNFluff meant)
But it’s execution in Windows was ass
In theory, a configuration manager with DB-like abilities (to maintain relationships, schematic integrity, and to abstract the file storage details), isn’t a bad idea
But the registry as it is today is pure pain