Skip to content

Commit

Permalink
add ability to hide command options in subProc().
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyBasher committed Feb 19, 2024
1 parent 8332294 commit fd8e99b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# functions.py
#
# thomas@linuxmuster.net
# 20240210
# 20240219
#

from subprocess import Popen, PIPE
Expand Down Expand Up @@ -54,7 +54,7 @@ def flush(self):


# invoke system commands
def subProc(cmd, logfile=None):
def subProc(cmd, logfile=None, hideopts=False):
try:
rc = True
p = Popen(cmd, shell=True, universal_newlines=True,
Expand All @@ -67,6 +67,8 @@ def subProc(cmd, logfile=None):
log.write('-' * 78 + '\n')
now = str(datetime.datetime.now()).split('.')[0]
log.write('#### ' + now + ' ' * (68 - len(now)) + ' ####\n')
if hideopts:
cmd = cmd.split()[0]
log.write('#### ' + cmd + ' ' * (68 - len(cmd)) + ' ####\n')
log.write(output)
if not rc:
Expand Down

0 comments on commit fd8e99b

Please sign in to comment.