~townsend/autopilot/fix-gcalctool-desktop-file

« back to all changes in this revision

Viewing changes to autopilot/application/_launcher.py

  • Committer: CI bot
  • Author(s): Thomi Richards, Max Brustkern
  • Date: 2014-04-08 00:29:44 UTC
  • mfrom: (459.6.5 logger-privatization)
  • Revision ID: ps-jenkins@lists.canonical.com-20140408002944-hkq216cwlrrbg3k7
Make logger objects within autopilot private. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    QtApplicationEnvironment,
38
38
)
39
39
 
40
 
 
41
 
logger = logging.getLogger(__name__)
 
40
_logger = logging.getLogger(__name__)
42
41
 
43
42
 
44
43
class ApplicationLauncher(fixtures.Fixture):
229
228
    """Launch an autopilot-enabled process and return the process object."""
230
229
    commandline = [application]
231
230
    commandline.extend(args)
232
 
    logger.info("Launching process: %r", commandline)
 
231
    _logger.info("Launching process: %r", commandline)
233
232
    cap_mode = None
234
233
    if capture_output:
235
234
        cap_mode = subprocess.PIPE
284
283
        else:
285
284
            return get_application_launcher_wrapper(app_path)
286
285
    except (RuntimeError, ValueError) as e:
287
 
        logger.error(str(e))
 
286
        _logger.error(str(e))
288
287
        raise RuntimeError(
289
288
            "Autopilot could not determine the correct introspection type "
290
289
            "to use. You can specify this by providing app_type."
342
341
    """Kill the process, and return the stdout, stderr and return code."""
343
342
    stdout_parts = []
344
343
    stderr_parts = []
345
 
    logger.info("waiting for process to exit.")
 
344
    _logger.info("waiting for process to exit.")
346
345
    _attempt_kill_pid(process.pid)
347
346
    for _ in Timeout.default():
348
347
        tmp_out, tmp_err = process.communicate()
355
354
        if not _is_process_running(process.pid):
356
355
            break
357
356
    else:
358
 
        logger.info(
 
357
        _logger.info(
359
358
            "Killing process group, since it hasn't exited after "
360
359
            "10 seconds."
361
360
        )
365
364
 
366
365
def _attempt_kill_pid(pid, sig=signal.SIGTERM):
367
366
    try:
368
 
        logger.info("Killing process %d", pid)
 
367
        _logger.info("Killing process %d", pid)
369
368
        os.killpg(pid, sig)
370
369
    except OSError:
371
 
        logger.info("Appears process has already exited.")
 
370
        _logger.info("Appears process has already exited.")
372
371
 
373
372
 
374
373
def _is_process_running(pid):