tomerfiliba / plumbum

Plumbum: Shell Combinators
https://plumbum.readthedocs.io
MIT License
2.81k stars 183 forks source link

Path operations as root #330

Open AndydeCleyre opened 7 years ago

AndydeCleyre commented 7 years ago

Hi,

As discussed a bit over at #9, the way path-operations-as-root must be done presently is not as pythonic as possible, and introduces a wide syntax disparity between those operations and the "same" operations done as the normal user.

I propose that all path operations gain a keyword argument to either activate sudo for that operation, or (more flexibly) specify a user to run that operation as. So something akin to sudo=False, root=False, as_root=False, as_user=None, user=None, or sudo_user=None.

"path operations" refers to these, at least:

AndydeCleyre commented 7 years ago

I somehow just noticed (or forgot) about the existing local.as_user context manager. Does that work when nesting path commands?

kepi commented 4 years ago

Please do not forget to about RemotePath. In case of servers where only non-root SSH is possible, code becomes ugly fast.

I suppose this could be added to all methods, but in case list above would be used, please add also mkdir.