/[gli]/trunk/src/GLIUtility.py
Gentoo

Diff of /trunk/src/GLIUtility.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 981 Revision 982
318 # open a read only pipe 318 # open a read only pipe
319 ro_pipe = os.popen(cmd, 'r') 319 ro_pipe = os.popen(cmd, 'r')
320 320
321 # read a line from the pipe and loop until 321 # read a line from the pipe and loop until
322 # pipe is empty 322 # pipe is empty
323 data = ro_pipe.readline() 323# data = ro_pipe.readline()
324 seenlines = 0 324 seenlines = 0
325 last_percent = 0
325 326
326 while data: 327 while 1:
328 data = ro_pipe.read(2048)
329 if not data: break
330
327 if logfile: 331 if logfile:
328 fd_logfile.write(data) 332 fd_logfile.write(data)
329# fd_logfile.flush() 333# fd_logfile.flush()
330 334
331 if display_on_tty8: 335 if display_on_tty8:
332 fd_tty.write(data) 336 fd_tty.write(data)
333# fd_tty.flush() 337 fd_tty.flush()
334 338
335 if return_output: 339 if return_output:
336 output = output + data 340 output += data
337 341
338 if linecount and cc: 342 if linecount and cc:
343 lastpos = -1
344 while 1:
345 lastpos = data.find("\n", lastpos + 1)
346 if lastpos == -1: break
339 seenlines += 1 347 seenlines += 1
340 if not seenlines % 20: 348 percent = float(seenlines) / linecount
349 if int(percent * 100) > last_percent:
350 last_percent = int(percent * 100)
341 cc.addNotification("progress", (float(seenlines) / linecount, status_message)) 351 cc.addNotification("progress", (percent, status_message))
342 352
343 data = ro_pipe.readline() 353# data = ro_pipe.readline()
344 354
345 # close the file descriptors 355 # close the file descriptors
346 if logfile: fd_logfile.close() 356 if logfile: fd_logfile.close()
347 if display_on_tty8: fd_tty.close() 357 if display_on_tty8: fd_tty.close()
348 358

Legend:
Removed from v.981  
changed lines
  Added in v.982

  ViewVC Help
Powered by ViewVC 1.1.20