X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=tests%2Fdata%2Fplugins%2Fsrc.ctf.lttng-live%2Flttng_live_server.py;h=77b005ca3083cb264352a02aeab32a0e47748cb4;hp=4c3c9ff45c0088d23f67e197fbcc6b6a4e925764;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=584af91edcbb694c054835c69ff960c5350d0c0e diff --git a/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py b/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py index 4c3c9ff4..77b005ca 100644 --- a/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py +++ b/tests/data/plugins/src.ctf.lttng-live/lttng_live_server.py @@ -1,24 +1,7 @@ -# The MIT License (MIT) +# SPDX-License-Identifier: MIT # -# Copyright (c) 2019 Philippe Proulx +# Copyright (C) 2019 Philippe Proulx # -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. import argparse import collections.abc @@ -457,7 +440,7 @@ class _LttngLiveViewerProtocolCodec: version, tracing_session_id, offset, seek_type ) elif cmd_type == 4: - stream_id, = self._unpack_payload('Q', data) + (stream_id,) = self._unpack_payload('Q', data) return _LttngLiveViewerGetNextDataStreamIndexEntryCommand( version, stream_id ) @@ -467,15 +450,15 @@ class _LttngLiveViewerProtocolCodec: version, stream_id, offset, req_length ) elif cmd_type == 6: - stream_id, = self._unpack_payload('Q', data) + (stream_id,) = self._unpack_payload('Q', data) return _LttngLiveViewerGetMetadataStreamDataCommand(version, stream_id) elif cmd_type == 7: - tracing_session_id, = self._unpack_payload('Q', data) + (tracing_session_id,) = self._unpack_payload('Q', data) return _LttngLiveViewerGetNewStreamInfosCommand(version, tracing_session_id) elif cmd_type == 8: return _LttngLiveViewerCreateViewerSessionCommand(version) elif cmd_type == 9: - tracing_session_id, = self._unpack_payload('Q', data) + (tracing_session_id,) = self._unpack_payload('Q', data) return _LttngLiveViewerDetachFromTracingSessionCommand( version, tracing_session_id ) @@ -674,9 +657,15 @@ class _LttngDataStreamIndex(collections.abc.Sequence): break assert len(data) == size - offset_bytes, total_size_bits, content_size_bits, timestamp_begin, timestamp_end, events_discarded, stream_class_id = struct.unpack( - fmt, data - ) + ( + offset_bytes, + total_size_bits, + content_size_bits, + timestamp_begin, + timestamp_end, + events_discarded, + stream_class_id, + ) = struct.unpack(fmt, data) self._entries.append( _LttngDataStreamIndexEntry( @@ -1320,7 +1309,9 @@ class LttngLiveServer: def _listen(self): logging.info('Listening: port={}'.format(self._server_port)) - self._sock.listen() + # Backlog must be present for Python version < 3.5. + # 128 is an arbitrary number since we expect only 1 connection anyway. + self._sock.listen(128) self._conn, viewer_addr = self._sock.accept() logging.info( 'Accepted viewer: addr={}:{}'.format(viewer_addr[0], viewer_addr[1]) @@ -1337,7 +1328,7 @@ class LttngLiveServer: print(self._server_port, end='', file=tmp_port_file) # Rename temporary file to real file - os.rename(tmp_port_file.name, port_filename) + os.replace(tmp_port_file.name, port_filename) logging.info( 'Renamed port file: src-path="{}", dst-path="{}"'.format( tmp_port_file.name, port_filename