Drop Python 2.7 conventions
Markus Gerstel
3 years ago
0 | 0 | #!/usr/bin/env python |
1 | # -*- coding: utf-8 -*- | |
2 | 1 | # |
3 | 2 | # procrunner documentation build configuration file, created by |
4 | 3 | # sphinx-quickstart on Fri Jun 9 13:47:02 2017. |
47 | 46 | master_doc = "index" |
48 | 47 | |
49 | 48 | # General information about the project. |
50 | project = u"ProcRunner" | |
51 | copyright = u"2018, Markus Gerstel" | |
52 | author = u"Markus Gerstel" | |
49 | project = "ProcRunner" | |
50 | copyright = "2020, Markus Gerstel" | |
51 | author = "Markus Gerstel" | |
53 | 52 | |
54 | 53 | # The version info for the project you're documenting, acts as replacement |
55 | 54 | # for |version| and |release|, also used in various other places throughout |
128 | 127 | ( |
129 | 128 | master_doc, |
130 | 129 | "procrunner.tex", |
131 | u"ProcRunner Documentation", | |
132 | u"Markus Gerstel", | |
130 | "ProcRunner Documentation", | |
131 | "Markus Gerstel", | |
133 | 132 | "manual", |
134 | 133 | ) |
135 | 134 | ] |
139 | 138 | |
140 | 139 | # One entry per manual page. List of tuples |
141 | 140 | # (source start file, name, description, authors, manual section). |
142 | man_pages = [(master_doc, "procrunner", u"ProcRunner Documentation", [author], 1)] | |
141 | man_pages = [(master_doc, "procrunner", "ProcRunner Documentation", [author], 1)] | |
143 | 142 | |
144 | 143 | |
145 | 144 | # -- Options for Texinfo output ---------------------------------------- |
151 | 150 | ( |
152 | 151 | master_doc, |
153 | 152 | "procrunner", |
154 | u"ProcRunner Documentation", | |
153 | "ProcRunner Documentation", | |
155 | 154 | author, |
156 | 155 | "procrunner", |
157 | 156 | "One line description of project.", |
0 | # -*- coding: utf-8 -*- | |
1 | ||
2 | from __future__ import absolute_import, division, print_function | |
3 | ||
4 | 0 | import codecs |
5 | 1 | import io |
6 | 2 | import logging |
57 | 53 | logger.addHandler(logging.NullHandler()) |
58 | 54 | |
59 | 55 | |
60 | class _LineAggregator(object): | |
56 | class _LineAggregator: | |
61 | 57 | """ |
62 | 58 | Buffer that can be filled with stream data and will aggregate complete |
63 | 59 | lines. Lines can be printed or passed to an arbitrary callback function. |
106 | 102 | self._buffer = "" |
107 | 103 | |
108 | 104 | |
109 | class _NonBlockingStreamReader(object): | |
105 | class _NonBlockingStreamReader: | |
110 | 106 | """Reads a stream in a thread to avoid blocking/deadlocks""" |
111 | 107 | |
112 | 108 | def __init__(self, stream, output=True, debug=False, notify=None, callback=None): |
200 | 196 | return data |
201 | 197 | |
202 | 198 | |
203 | class _NonBlockingStreamWriter(object): | |
199 | class _NonBlockingStreamWriter: | |
204 | 200 | """Writes to a stream in a thread to avoid blocking/deadlocks""" |
205 | 201 | |
206 | 202 | def __init__(self, stream, data, debug=False, notify=None): |
223 | 219 | block = self._buffer[self._buffer_pos :] |
224 | 220 | try: |
225 | 221 | self._stream.write(block) |
226 | except IOError as e: | |
222 | except OSError as e: | |
227 | 223 | if ( |
228 | 224 | e.errno == 32 |
229 | 225 | ): # broken pipe, ie. process terminated without reading entire stdin |
315 | 311 | """ |
316 | 312 | |
317 | 313 | def __init__(self, *arg, **kw): |
318 | super(ReturnObject, self).__init__(*arg, **kw) | |
314 | super().__init__(*arg, **kw) | |
319 | 315 | self.args = self["command"] |
320 | 316 | self.returncode = self["exitcode"] |
321 | 317 | self.stdout = self["stdout"] |
0 | from __future__ import absolute_import, division, print_function | |
1 | ||
2 | 0 | import copy |
3 | 1 | import mock |
4 | 2 | import os |
149 | 147 | random_environment_variable = list(os.environ)[0] |
150 | 148 | if random_environment_variable == list(mock_env2)[0]: |
151 | 149 | random_environment_variable = list(os.environ)[1] |
152 | random_environment_value = os.getenv(random_environment_variable) | |
153 | 150 | assert ( |
154 | 151 | random_environment_variable |
155 | 152 | and random_environment_variable != list(mock_env2)[0] |
191 | 188 | def test_nonblockingstreamreader_can_read(mock_select): |
192 | 189 | import time |
193 | 190 | |
194 | class _stream(object): | |
191 | class _stream: | |
195 | 192 | def __init__(self): |
196 | 193 | self.data = b"" |
197 | 194 | self.closed = False |
0 | from __future__ import absolute_import, division, print_function | |
1 | ||
2 | 0 | import os |
3 | 1 | import sys |
4 | 2 | |
35 | 33 | else: |
36 | 34 | assert result.stdout == test_string |
37 | 35 | out, err = capsys.readouterr() |
38 | assert out == u"test\ufffdstring\n" | |
39 | assert err == u"" | |
36 | assert out == "test\ufffdstring\n" | |
37 | assert err == "" | |
40 | 38 | |
41 | 39 | |
42 | 40 | def test_running_wget(tmpdir): |