Changeset 29809 in vbox for trunk/src/VBox
- Timestamp:
- May 26, 2010 10:41:56 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxShell/vboxshell.py
r29802 r29809 178 178 return rlcompleter.Completer.complete(self,text,state) 179 179 180 def canBePath(self, phrase,word): 181 return word.startswith('/') 182 180 183 def canBeCommand(self, phrase, word): 181 184 spaceIdx = phrase.find(" ") … … 188 191 return False 189 192 190 def canBePath(self,phrase,word):191 return word.startswith('/')192 193 193 def canBeMachine(self,phrase,word): 194 194 return not self.canBePath(phrase,word) and not self.canBeCommand(phrase, word) 195 196 def canBePath(self,phrase,word):197 return word.startswith('/')198 195 199 196 def global_matches(self, text): … … 208 205 209 206 try: 207 if self.canBePath(phrase,text): 208 (dir,rest) = os.path.split(text) 209 n = len(rest) 210 for word in os.listdir(dir): 211 if n == 0 or word[:n] == rest: 212 matches.append(os.path.join(dir,word)) 213 210 214 if self.canBeCommand(phrase,text): 211 215 n = len(text) … … 227 231 matches.append(word) 228 232 229 if self.canBePath(phrase,text):230 (dir,rest) = os.path.split(text)231 n = len(rest)232 for word in os.listdir(dir):233 if n == 0 or word[:n] == rest:234 matches.append(os.path.join(dir,word))235 236 233 except Exception,e: 237 234 printErr(e) … … 251 248 readline.set_completer(completer.complete) 252 249 delims = readline.get_completer_delims() 253 readline.set_completer_delims(re.sub("[\\. ]", "", delims)) # remove some of the delimiters250 readline.set_completer_delims(re.sub("[\\./-]", "", delims)) # remove some of the delimiters 254 251 readline.parse_and_bind("set editing-mode emacs") 255 252 # OSX need it … … 853 850 return 0 854 851 855 def execInGuest(ctx,console,args,env ):852 def execInGuest(ctx,console,args,env,user,passwd,tmo): 856 853 if len(args) < 1: 857 854 print "exec in guest needs at least program name" 858 855 return 859 user = ""860 passwd = ""861 tmo = 0862 856 guest = console.guest 863 857 # shall contain program name as argv[0] 864 858 gargs = args 865 print "executing %s with args %s " %(args[0], gargs)859 print "executing %s with args %s as %s" %(args[0], gargs, user) 866 860 (progress, pid) = guest.executeProcess(args[0], 0, gargs, env, user, passwd, tmo) 867 861 print "executed with pid %d" %(pid) … … 882 876 if progress.cancelable: 883 877 progress.cancel() 878 (reason, code, flags) = guest.getProcessStatus(pid) 879 print "Exit code: %d" %(code) 884 880 return 0 885 881 else: 886 882 reportError(ctx, progress) 883 884 def nh_raw_input(prompt=""): 885 stream = sys.stdout 886 prompt = str(prompt) 887 if prompt: 888 stream.write(prompt) 889 line = sys.stdin.readline() 890 if not line: 891 raise EOFError 892 if line[-1] == '\n': 893 line = line[:-1] 894 return line 895 896 897 def getCred(ctx): 898 import getpass 899 user = getpass.getuser() 900 user_inp = raw_input("User (%s): " %(user)) 901 if len (user_inp) > 0: 902 user = user_inp 903 passwd = getpass.getpass() 904 905 return (user,passwd) 887 906 888 907 def gexecCmd(ctx,args): … … 895 914 gargs = args[2:] 896 915 env = [] # ["DISPLAY=:0"] 897 gargs.insert(0, lambda ctx,mach,console,args: execInGuest(ctx,console,args,env)) 916 (user,passwd) = getCred(ctx) 917 gargs.insert(0, lambda ctx,mach,console,args: execInGuest(ctx,console,args,env,user,passwd,1000)) 898 918 cmdExistingVm(ctx, mach, 'guestlambda', gargs) 899 919 return 0 … … 908 928 gargs = args[2:] 909 929 env = [] 910 gargs.insert(0, lambda ctx,mach,console,args: execInGuest(ctx,console,args,env)) 930 (user,passwd) = getCred(ctx) 931 gargs.insert(0, lambda ctx,mach,console,args: execInGuest(ctx,console,args,env, user, passwd, 0)) 911 932 cmdExistingVm(ctx, mach, 'guestlambda', gargs) 912 933 return 0
Note:
See TracChangeset
for help on using the changeset viewer.