54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
#!/usr/bin/python3
|
|
|
|
import sys
|
|
## lo siento, pero tiene que ser así
|
|
from BootLib import *
|
|
from CacheLib import *
|
|
from DiskLib import *
|
|
from FileLib import *
|
|
from FileSystemLib import *
|
|
from ImageLib import *
|
|
from InventoryLib import *
|
|
from NetLib import *
|
|
from PostConfLib import *
|
|
from ProtocolLib import *
|
|
from RegistryLib import *
|
|
from StringLib import *
|
|
from SystemLib import *
|
|
from UEFILib import *
|
|
|
|
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
|
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
|
ogHelp ('ogExecAndLog', 'ogExecAndLog str_logfile ... str_command ...', ['ogExecAndLog COMMAND ls -al /'])
|
|
sys.exit (0)
|
|
|
|
logtypes = []
|
|
while True:
|
|
if sys.argv[1] in ['command', 'log', 'session']:
|
|
logtypes.append (sys.argv.pop (1))
|
|
else: break
|
|
|
|
fun_name = sys.argv.pop (1)
|
|
try:
|
|
fun = locals()[fun_name]
|
|
except KeyError:
|
|
print (f'not implemented: {fun_name}')
|
|
sys.exit (1)
|
|
|
|
args = []
|
|
kwargs = {}
|
|
for arg in sys.argv[1:]:
|
|
if '=' in arg:
|
|
k, v = arg.split ('=')
|
|
kwargs[k] = v
|
|
else:
|
|
args.append (arg)
|
|
|
|
## args has to be a tuple
|
|
args = tuple (args)
|
|
|
|
ret = ogExecAndLog (logtypes, fun, *args, **kwargs)
|
|
if ret is not None:
|
|
if ret == True: sys.exit (0)
|
|
elif ret == False: sys.exit (1)
|