~frankban/juju-gui/quickstart-real-bootstrap

« back to all changes in this revision

Viewing changes to quickstart/utils.py

  • Committer: Francesco Banconi
  • Date: 2013-10-16 12:12:31 UTC
  • Revision ID: francesco.banconi@canonical.com-20131016121231-69oao0rv51gjifnn
Logging support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import re
20
20
import os
 
21
import logging
 
22
import pipes
21
23
import subprocess
22
24
 
23
25
import yaml
34
36
    Return a tuple containing the subprocess return code, output and error.
35
37
    """
36
38
    pipe = subprocess.PIPE
 
39
    cmdline = ' '.join(map(pipes.quote, args))
 
40
    logging.debug('running the following: {}'.format(cmdline))
37
41
    try:
38
42
        process = subprocess.Popen(args, stdout=pipe, stderr=pipe)
39
43
    except OSError as err:
41
45
        # found in the PATH.
42
46
        return 127, '', '{}: {}'.format(args[0], err)
43
47
    output, error = process.communicate()
44
 
    return process.poll(), output, error
 
48
    retcode = process.poll()
 
49
    logging.debug('retcode: {} | output: {!r} | error: {!r}'.format(
 
50
        retcode, output, error))
 
51
    return retcode, output, error
45
52
 
46
53
 
47
54
def get_default_env_name():