Changeset 30437 in vbox for trunk/src/VBox
- Timestamp:
- Jun 24, 2010 1:47:46 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 63079
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r30389 r30437 30 30 import re 31 31 import platform 32 from optparse import OptionParser 32 33 33 34 # Simple implementation of IConsoleCallback, one can use it as skeleton … … 134 135 print "onGuestPropertyChange: %s: %s=%s" %(id, name, newValue) 135 136 137 g_batchmode = False 138 g_scripfile = None 139 g_cmd = None 136 140 g_hasreadline = True 137 141 try: … … 2592 2596 nat.network = args[1] 2593 2597 return (0, None) 2598 2594 2599 def natCmd(ctx, args): 2595 2600 """This command is entry point to NAT settins management … … 3050 3055 except: 3051 3056 pass 3057 cmds = [] 3058 3059 if g_cmd is not None: 3060 cmds = g_cmd.split(';') 3061 it = cmds.__iter__() 3052 3062 3053 3063 while True: 3054 3064 try: 3055 cmd = raw_input(ctx['prompt']) 3065 if g_batchmode: 3066 cmd = 'runScript %s'%(g_scripfile) 3067 elif g_cmd is not None: 3068 cmd = it.next() 3069 else: 3070 cmd = raw_input(ctx['prompt']) 3056 3071 done = runCommand(ctx, cmd) 3057 3072 if done != 0: break 3073 if g_batchmode: 3074 break 3058 3075 except KeyboardInterrupt: 3059 3076 print '====== You can type quit or q to leave' 3077 except StopIteration: 3078 break 3060 3079 except EOFError: 3061 3080 break … … 3088 3107 def main(argv): 3089 3108 style = None 3109 params = None 3090 3110 autopath = False 3091 argv.pop(0) 3092 while len(argv) > 0: 3093 if argv[0] == "-w": 3094 style = "WEBSERVICE" 3095 if argv[0] == "-a": 3096 autopath = True 3097 argv.pop(0) 3098 3099 if autopath: 3111 script_file = None 3112 parse = OptionParser() 3113 parse.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False, help = "switch on verbose") 3114 parse.add_option("-a", "--autopath", dest="autopath", action="store_true", default=False, help = "switch on autopath") 3115 parse.add_option("-w", "--webservice", dest="style", action="store_const", const="WEBSERVICE", help = "connect to webservice") 3116 parse.add_option("-b", "--batch", dest="batch_file", help = "script file to execute") 3117 parse.add_option("-c", dest="command_line", help = "command sequence to execute") 3118 parse.add_option("-o", dest="opt_line", help = "option line") 3119 global g_verbose, g_scripfile, g_batchmode, g_hascolors, g_hasreadline, g_cmd 3120 (options, args) = parse.parse_args() 3121 g_verbose = options.verbose 3122 style = options.style 3123 if options.batch_file is not None: 3124 g_batchmode = True 3125 g_hascolors = False 3126 g_hasreadline = False 3127 g_scripfile = options.batch_file 3128 if options.command_line is not None: 3129 g_hascolors = False 3130 g_hasreadline = False 3131 g_cmd = options.command_line 3132 if options.opt_line is not None: 3133 params = {} 3134 strparams = options.opt_line 3135 l = strparams.split(',') 3136 for e in l: 3137 (k,v) = e.split('=') 3138 params[k] = v 3139 else: 3140 params = None 3141 3142 if options.autopath: 3100 3143 cwd = os.getcwd() 3101 3144 vpp = os.environ.get("VBOX_PROGRAM_PATH") … … 3107 3150 3108 3151 from vboxapi import VirtualBoxManager 3109 g_virtualBoxManager = VirtualBoxManager(style, None)3152 g_virtualBoxManager = VirtualBoxManager(style, params) 3110 3153 ctx = {'global':g_virtualBoxManager, 3111 3154 'mgr':g_virtualBoxManager.mgr,
Note:
See TracChangeset
for help on using the changeset viewer.