procServ icon indicating copy to clipboard operation
procServ copied to clipboard

procServUtils autocomplete and new commands

Open darcato opened this issue 4 years ago • 6 comments

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).

darcato avatar Mar 19 '20 16:03 darcato

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

ralphlange avatar Oct 29 '20 13:10 ralphlange

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 avatar Nov 05 '20 22:11 mdavidsaver

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.

mdavidsaver avatar Nov 05 '20 22:11 mdavidsaver

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

darcato avatar Nov 06 '20 14:11 darcato

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 avatar Nov 09 '20 14:11 darcato

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.

darcato avatar Nov 09 '20 15:11 darcato