Changeset 30501
- Timestamp:
- Mar 7, 2008, 3:56:14 PM (16 years ago)
- Location:
- grass/trunk/gui/wxpython/gui_modules
- Files:
-
- 2 edited
-
gcmd.py (modified) (4 diffs)
-
globalvar.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/gui/wxpython/gui_modules/gcmd.py
r30486 r30501 7 7 * GException 8 8 * DigitError 9 * Popen 9 * Popen (from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554) 10 10 * Command 11 11 * CommandThread … … 128 128 def kill(self): 129 129 """Try to kill running process""" 130 try: 130 if subprocess.mswindows: 131 import win32api 132 handle = win32api.OpenProcess(1, 0, self.pid) 133 return (0 != win32api.TerminateProcess(handle, 0)) 134 else: 131 135 os.kill(-self.pid, signal.SIGTERM) # kill whole group 132 except OSError:133 pass134 136 135 137 if subprocess.mswindows: … … 213 215 if not conn.closed: 214 216 fcntl.fcntl(conn, fcntl.F_SETFL, flags) 217 218 message = "Other end disconnected!" 219 220 def recv_some(p, t=.1, e=1, tr=5, stderr=0): 221 if tr < 1: 222 tr = 1 223 x = time.time()+t 224 y = [] 225 r = '' 226 pr = p.recv 227 if stderr: 228 pr = p.recv_err 229 while time.time() < x or r: 230 r = pr() 231 if r is None: 232 if e: 233 raise Exception(message) 234 else: 235 break 236 elif r: 237 y.append(r) 238 else: 239 time.sleep(max((x-time.time())/tr, 0)) 240 return ''.join(y) 241 242 def send_all(p, data): 243 while len(data): 244 sent = p.send(data) 245 if sent is None: 246 raise Exception(message) 247 data = buffer(data, sent) 215 248 216 249 # Define notification event for thread completion … … 529 562 return 530 563 if self.stdout: 531 line = self.__read_all(self.module.stdout) 564 # line = self.__read_all(self.module.stdout) 565 line = recv_some(self.module, e=0, stderr=0) 532 566 self.stdout.write(line) 533 567 if self.stderr: 534 line = self.__read_all(self.module.stderr) 568 # line = self.__read_all(self.module.stderr) 569 line = recv_some(self.module, e=0, stderr=1) 535 570 self.stderr.write(line) 536 571 537 572 # get the last output 538 573 if self.stdout: 539 line = self.__read_all(self.module.stdout) 574 # line = self.__read_all(self.module.stdout) 575 line = recv_some(self.module, e=0, stderr=0) 540 576 self.stdout.write(line) 541 577 if self.stderr: 542 line = self.__read_all(self.module.stderr) 578 # line = self.__read_all(self.module.stderr) 579 line = recv_some(self.module, e=0, stderr=1) 543 580 self.stderr.write(line) 544 581 -
grass/trunk/gui/wxpython/gui_modules/globalvar.py
r30419 r30501 63 63 parsing string from the command line 64 64 """ 65 gcmdlst = []66 65 gisbase = os.environ['GISBASE'] 66 binlst = [] 67 67 if bin is True: 68 gcmdlst = os.listdir(os.path.join(gisbase, 'bin')) 68 binlst = os.listdir(os.path.join(gisbase, 'bin')) 69 if subprocess.mswindows: 70 for idx in range(len(binlst)): 71 binlst[idx] = binlst[idx].replace(EXT_BIN, '') 72 binlst[idx] = binlst[idx].replace(EXT_SCT, '') 73 sctlst = [] 69 74 if scripts is True: 70 gcmdlst = gcmdlst + os.listdir(os.path.join(gisbase, 'scripts')) 75 sctlst = sctlst + os.listdir(os.path.join(gisbase, 'scripts')) 76 if subprocess.mswindows: 77 for idx in range(len(binlst)): 78 binlst[idx] = binlst[idx].replace(EXT_BIN, '') 79 binlst[idx] = binlst[idx].replace(EXT_SCT, '') 80 71 81 # self.gcmdlst = self.gcmdlst + os.listdir(os.path.join(gisbase,'etc','gm','script')) 72 82 73 return gcmdlst83 return binlst + sctlst 74 84 75 85 """@brief Collected GRASS-relared binaries/scripts"""
Note:
See TracChangeset
for help on using the changeset viewer.
