|
@@ -1,20 +1,18 @@
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
-##Forkato da labcalcoloctl di Elisa Aliverti
|
|
|
##Autore: Nicolo' Palazzini
|
|
|
-##Ultima modifica: 2/05/2019
|
|
|
+##Liberamente ispirato a labcalcoloctl di Elisa Aliverti (all rights reserved)
|
|
|
+##Ultima modifica: Maggio 2019
|
|
|
|
|
|
from time import time
|
|
|
start = time()
|
|
|
import argparse
|
|
|
-#import textwrap
|
|
|
import os
|
|
|
import subprocess, sys
|
|
|
from threading import Thread
|
|
|
-#from getpass import getpass
|
|
|
|
|
|
choices = ('status','start','stop')
|
|
|
-parser = argparse.ArgumentParser(description='Simple tool to handle xfreerdp on LCM nodes.', usage='xfreerdpctl {'+','.join(choices)+'} [options]')
|
|
|
+parser = argparse.ArgumentParser(description='Simple tool to handle xfreerdp on LCM nodes.', usage=sys.argv[0]+' {'+','.join(choices)+'} [--options]')
|
|
|
|
|
|
## positional arguments
|
|
|
parser.add_argument( 'cmd', nargs="?", choices=choices, default='status', help='Specify command to execute, default is \'status\'' )
|
|
@@ -24,7 +22,7 @@ parser.add_argument( '-a', '--all', action='store_true', dest='lcm', help='All L
|
|
|
parser.add_argument( '-n', nargs='+', dest='node', help='Select one or more nodes (at least one)' )
|
|
|
parser.add_argument( '-1', '--lcm1', action='store_true', dest='lcm1', help='LCM1 nodes are considered' )
|
|
|
parser.add_argument( '-2', '--lcm2', action='store_true', dest='lcm2', help='LCM2 nodes are considered' )
|
|
|
-parser.add_argument( '-v', '--version', action='version', version='%(prog)s 1.0', help='Print program version' )
|
|
|
+parser.add_argument( '-v', '--version', action='version', version='%(prog)s 1.1', help='Print program version' )
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
@@ -141,6 +139,13 @@ Hosts = [
|
|
|
|
|
|
nodes = []
|
|
|
|
|
|
+# Show usage if no arguments
|
|
|
+if len(sys.argv) < 2:
|
|
|
+ parser.print_usage()
|
|
|
+ print "\nSimple tool to handle xfreerdp on LCM nodes."
|
|
|
+ print '\nTry: "'+sys.argv[0]+' --help" to display help message.'
|
|
|
+ sys.exit(1)
|
|
|
+
|
|
|
# Filter hostlist according to arguments
|
|
|
if args.lcm:
|
|
|
nodes = Hosts
|