ralphlange / procServ

Wrapper to start arbitrary interactive commands in the background, with telnet or Unix domain socket access to stdin/stdout
GNU General Public License v3.0
23 stars 23 forks source link

procServUtils autocomplete and new commands #34

Open darcato opened 4 years ago

darcato commented 4 years ago

Hello, this PR adds some functionalities to the procServUtils scripts:

  1. Bash autocomplete through argcomplete
  2. New commands to restart, rename or open logs of the processes
  3. Print status as a table with color support, to be easier to read
  4. Fix some unhandled exceptions
  5. Documentation for the commands

To enable these functionalities three python dependencies are needed: argcomplete, tabulate and termcolor. Unfortunately the current installation process does not support installing dependencies so one has to install them manually through pip.

Do you think the installation process can be modified to use pip to automatically handle dependencies?

All the changes here are compatible with existing configuration files and do not break compatibility (hopefully).

ralphlange commented 3 years ago

@mdavidsaver and @mark0n, do you have opinions on this? Looks good to me. Are the additional Python packages (argcomplete, termcolor, tabulate) appropriate and reasonable?

mdavidsaver commented 3 years ago

My first benchmark for dependencies is presence in the Debian package repository. All three have been present since at least Debian 8 (10 is stable atm). argcomplete tabulate termcolor

argcomplete and tabulate appear at a glance to be healthy projects with recent releases and links to VCS repos.

termcolor appears to be defunct, with no release since 2011, and no authoritative VCS repository listed.

mdavidsaver commented 3 years ago

Personally, I would make this three optional dependencies with some try: ... import. As used, termcolor and argcomplete can be trivially stubbed out, with tabulate being only slightly more involved.

darcato commented 3 years ago

Hello @mdavidsaver, thanks for your comments. I will try to address all of them in the following days.

darcato commented 3 years ago

I made the three packages optional, adding some fallback functions that emulate almost the same behavior as before this PR. Then I fixed the systemctl calls order and reverted the check_call on systemctl disable. I also added a test function for the rename command and updated the readme.

I redirected the standard error of the systemctl reset-failed command to /dev/null because this fails when there is nothing to reset (which is the most common situation).

I didn't remove the install_requires comment, as this will be useful when the project will move to setuptools. For the moment I did not implement this change.

darcato commented 3 years ago

Lastly, since the rename command causes the service to stop, I added a dialog for the user to confirm the operation, and I added a notice to the readme.