- Timestamp:
- Mar 10, 2012, 9:55:07 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/check-batch-cmd
r10097 r10098 8 8 import argparse 9 9 import gformat 10 import getpass 10 11 import netsnmp 11 12 import os … … 15 16 import time 16 17 17 try: 18 SSHPASS = os.environ['SSHPASS'] 19 except KeyError: 20 SSHPASS = 'SSH_NOT_SET' 21 18 SSHPASS = None 22 19 netsnmp.verbose = 0 23 20 … … 49 46 retval = sess.get(var_list) 50 47 if sess.ErrorInd < 0: 51 raise CmdError(' [%(ErrorInd)s] %(ErrorStr)s (%(DestHost)s)' % vars(sess))48 raise CmdError('SNMP Failed -- [%(ErrorInd)s] %(ErrorStr)s (%(DestHost)s)' % vars(sess)) 52 49 return filter(None, retval)[0] 53 50 … … 125 122 # create the top-level parser 126 123 parser = argparse.ArgumentParser(prog='Various WL management tools') 127 #parser.add_argument('--foo', action='store_true', help='foo help')124 parser.add_argument('--ask-pass', dest="ask_pass", action='store_true', help='Ask password if SSHPASS is not found') 128 125 subparsers = parser.add_subparsers(help='sub-command help') 129 126 … … 142 139 args = parser.parse_args() 143 140 141 try: 142 SSHPASS = os.environ['SSHPASS'] 143 except KeyError: 144 print "#WARN: SSHPASS environ variable not found" 145 if args.ask_pass: 146 SSHPASS = getpass.getpass("WL root password: ") 147 148 144 149 if args.func == 'keys': 145 150 ubnt_keys(args.host)
Note:
See TracChangeset
for help on using the changeset viewer.