Codebase list python-procrunner / 1c83a20
Drop Python 2.7 conventions Markus Gerstel 3 years ago
5 changed file(s) with 15 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
00 #!/usr/bin/env python
1 # -*- coding: utf-8 -*-
21 #
32 # procrunner documentation build configuration file, created by
43 # sphinx-quickstart on Fri Jun 9 13:47:02 2017.
4746 master_doc = "index"
4847
4948 # 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"
5352
5453 # The version info for the project you're documenting, acts as replacement
5554 # for |version| and |release|, also used in various other places throughout
128127 (
129128 master_doc,
130129 "procrunner.tex",
131 u"ProcRunner Documentation",
132 u"Markus Gerstel",
130 "ProcRunner Documentation",
131 "Markus Gerstel",
133132 "manual",
134133 )
135134 ]
139138
140139 # One entry per manual page. List of tuples
141140 # (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)]
143142
144143
145144 # -- Options for Texinfo output ----------------------------------------
151150 (
152151 master_doc,
153152 "procrunner",
154 u"ProcRunner Documentation",
153 "ProcRunner Documentation",
155154 author,
156155 "procrunner",
157156 "One line description of project.",
0 # -*- coding: utf-8 -*-
1
2 from __future__ import absolute_import, division, print_function
3
40 import codecs
51 import io
62 import logging
5753 logger.addHandler(logging.NullHandler())
5854
5955
60 class _LineAggregator(object):
56 class _LineAggregator:
6157 """
6258 Buffer that can be filled with stream data and will aggregate complete
6359 lines. Lines can be printed or passed to an arbitrary callback function.
106102 self._buffer = ""
107103
108104
109 class _NonBlockingStreamReader(object):
105 class _NonBlockingStreamReader:
110106 """Reads a stream in a thread to avoid blocking/deadlocks"""
111107
112108 def __init__(self, stream, output=True, debug=False, notify=None, callback=None):
200196 return data
201197
202198
203 class _NonBlockingStreamWriter(object):
199 class _NonBlockingStreamWriter:
204200 """Writes to a stream in a thread to avoid blocking/deadlocks"""
205201
206202 def __init__(self, stream, data, debug=False, notify=None):
223219 block = self._buffer[self._buffer_pos :]
224220 try:
225221 self._stream.write(block)
226 except IOError as e:
222 except OSError as e:
227223 if (
228224 e.errno == 32
229225 ): # broken pipe, ie. process terminated without reading entire stdin
315311 """
316312
317313 def __init__(self, *arg, **kw):
318 super(ReturnObject, self).__init__(*arg, **kw)
314 super().__init__(*arg, **kw)
319315 self.args = self["command"]
320316 self.returncode = self["exitcode"]
321317 self.stdout = self["stdout"]
0 from __future__ import absolute_import, division, print_function
1
20 import copy
31 import mock
42 import os
149147 random_environment_variable = list(os.environ)[0]
150148 if random_environment_variable == list(mock_env2)[0]:
151149 random_environment_variable = list(os.environ)[1]
152 random_environment_value = os.getenv(random_environment_variable)
153150 assert (
154151 random_environment_variable
155152 and random_environment_variable != list(mock_env2)[0]
191188 def test_nonblockingstreamreader_can_read(mock_select):
192189 import time
193190
194 class _stream(object):
191 class _stream:
195192 def __init__(self):
196193 self.data = b""
197194 self.closed = False
0 from __future__ import absolute_import, division, print_function
1
20 import os
31 import sys
42
0 from __future__ import absolute_import, division, print_function
1
20 import os
31 import sys
42
3533 else:
3634 assert result.stdout == test_string
3735 out, err = capsys.readouterr()
38 assert out == u"test\ufffdstring\n"
39 assert err == u""
36 assert out == "test\ufffdstring\n"
37 assert err == ""
4038
4139
4240 def test_running_wget(tmpdir):