示例#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
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