shellcommon.py revision 293679af9d28ad029ab0735343ecfa734919b9dd
import traceback
import sys
import pdb
g_hasreadline = 1
try:
import readline
import rlcompleter
except:
g_hasreadline = 0
if g_hasreadline:
"""
taken from:
"""
if text == "":
return ['\t',None][state]
else:
"""
Compute matches when text is a simple name.
Return a list of all names currently defined
in self.namespace that match.
"""
matches = []
try:
# although it has autoconversion, we need to cast
# explicitly for subscripts to work
except Exception,e:
print e
return matches
if not g_hasreadline:
return
comps = {}
comps[k] = None
def split_no_quotes(s):
return s.split()
if rc == 0:
try:
except:
pass
def getMachines(ctx):
if var:
return 'on'
else:
return 'off'
valsStr = '[ '
valsStr += ']'
try:
except Exception,e:
if g_verbose:
return
return
# unfortunately IGuest is suppressed, thus WebServices knows not about it
# this is an example how to handle local only functionality
print 'Trying to use local only functionality, ignored'
return
}
# can cache known machines, if needed
mach = None
for m in getMachines(ctx):
mach = m
break
mach = m
break
return mach
return None
if m == None:
print "Machine '%s' is unknown, use list command to find available machines" %(id)
return m
print "Help page:"
for i in commands:
else:
if c == None:
else:
return 0
for m in getMachines(ctx):
return 0
print "usage: info [vmname|uuid]"
return 0
if mach == None:
return 0
return 0
if mach == None:
return 0
else:
type = "gui"
return 0
if mach == None:
return 0
return 0
if mach == None:
return 0
return 0
if mach == None:
return 0
return 0
if mach == None:
return 0
return 0
print "usage: setvar [vmname|uuid] expr value"
return 0
if mach == None:
return 0
print "Executing",expr
try:
exec expr
except Exception, e:
print 'failed: ',e
if g_verbose:
return 0
return 1
print "'%s' is an alias for '%s'" %(k,v)
return 0
global g_verbose
return 0
print "Processor count:",cnt
valsStr = '[ '
valsStr += ']'
return 0
try:
exec expr
except Exception, e:
print 'failed: ',e
if g_verbose:
return 0
'i':'info',
'l':'list',
'h':'help',
'a':'aliases',
'q':'quit', 'exit':'quit',
'v':'verbose'}
'eval':['Evaluate arbitrary Python construction: eval for m in getMachines(ctx): print m.name,"has",m.memorySize,"M"', evalCmd],
c = args[0]
c = aliases[c]
if ci == None:
print "Unknown command: '%s', type 'help' for list of known commands" %(c)
return 0
# to allow to print actual host information, we collect info for
# last 150 secs maximum, (sample every 10 secs and keep up to 15 samples)
try:
except:
pass
while True:
try:
if done != 0: break
except KeyboardInterrupt:
print '====== You can type quit or q to leave'
break
except EOFError:
break;
except Exception,e:
print e
if g_verbose:
try:
except:
pass