예제 #1
0
def convert_command_output(*command):
    """
    Command line interface for ``coloredlogs --to-html``.

    Takes a command (and its arguments) and runs the program under ``script``
    (emulating an interactive terminal), intercepts the output of the command
    and converts ANSI escape sequences in the output to HTML.
    """
    html_output = convert(capture(command))
    if connected_to_terminal():
        fd, temporary_file = tempfile.mkstemp(suffix='.html')
        with open(temporary_file, 'w') as handle:
            handle.write(html_output)
        webbrowser.open(temporary_file)
    else:
        print(html_output)
예제 #2
0
파일: cli.py 프로젝트: NRGI/dcos-bootstrap
def convert_command_output(*command):
    """
    Command line interface for ``coloredlogs --to-html``.

    Takes a command (and its arguments) and runs the program under ``script``
    (emulating an interactive terminal), intercepts the output of the command
    and converts ANSI escape sequences in the output to HTML.
    """
    html_output = convert(capture(command))
    if connected_to_terminal():
        fd, temporary_file = tempfile.mkstemp(suffix='.html')
        with open(temporary_file, 'w') as handle:
            handle.write(html_output)
        webbrowser.open(temporary_file)
    else:
        print(html_output)
예제 #3
0
 def test_output_interception(self):
     """Test capturing of output from external commands."""
     expected_output = 'testing, 1, 2, 3 ..'
     actual_output = capture(['echo', expected_output])
     assert actual_output.strip() == expected_output.strip()
예제 #4
0
 def test_output_interception(self):
     """Test capturing of output from external commands."""
     expected_output = 'testing, 1, 2, 3 ..'
     actual_output = capture(['echo', expected_output])
     assert actual_output.strip() == expected_output.strip()
예제 #5
0
 def test_output_interception(self):
     """Test capturing of output from external commands."""
     expected_output = 'testing, 1, 2, 3 ..'
     assert capture(['sh', '-c', 'echo -n %s' % expected_output]) == expected_output