Skip to content
This repository was archived by the owner on Dec 13, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
language: python
python:
- "2.7"
- "3.3"
- "3.4"
install:
- "pip install -q -e ."
- "pip install coverage"
Expand Down
4 changes: 2 additions & 2 deletions pygazebo/pygazebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ def _handle_server_data(self, future, connection):
self._read_server_data(connection)

def _handle_server_sub(self, this_connection, msg):
if not msg.topic in self._publishers:
if msg.topic not in self._publishers:
logger.warn('Manager.handle_server_sub unknown topic:' + msg.topic)
return

Expand Down Expand Up @@ -734,7 +734,7 @@ def _handle_publisher_subscribe(self, msg):
logger.debug('Manager.handle_publisher_subscribe:' + msg.topic)
logger.debug(' our info: %s, %d',
self._server.local_host, self._server.local_port)
if not msg.topic in self._subscribers:
if msg.topic not in self._subscribers:
logger.debug('no subscribers!')
return

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
protobuf>=2.6
protobuf==3.0.0-alpha-1
trollius
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def run_tests(self):
errcode = pytest.main(self.test_args)
sys.exit(errcode)

install_requires = ['protobuf>=2.6']
# Specify explicit protobuf dependency for python 3 support
# -> Once 3.0 is released, this should be set to >= 3.0
install_requires = ['protobuf==3.0.0-alpha-1']

if sys.hexversion < 0x03040000:
install_requires.append('trollius')
Expand Down
22 changes: 14 additions & 8 deletions tests/test_pygazebo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function

"""
test_pygazebo
----------------------------------
Expand All @@ -19,6 +21,10 @@
except ImportError:
import trollius as asyncio

import sys
_b = sys.version_info[0] < 3 and (lambda x: x) or \
(lambda x: x.encode('latin1'))

import mock
import pytest
import socket
Expand Down Expand Up @@ -57,7 +63,7 @@ def write(self, data, callback):
future.add_done_callback(lambda future: self.write(data[1:], callback))

def write_frame(self, payload, callback):
header = '%08X' % len(payload)
header = _b('%08X' % len(payload))

data = header + payload

Expand All @@ -81,7 +87,7 @@ def write_packet(self, name, message, callback):

def recv(self, length, callback):
assert length <= 16384
self.recv_handler('', '', length, callback)
self.recv_handler(_b(''), _b(''), length, callback)

def recv_handler(self, new_data, old_data, total_size, callback):
data = old_data + new_data
Expand All @@ -108,8 +114,8 @@ def _read_frame_header(self, header, callback):
except ValueError:
return None

data = ''
self._read_frame_data('', data, size, callback)
data = _b('')
self._read_frame_data(_b(''), data, size, callback)

def _read_frame_data(self, new_data, old_data, total_size, callback):
data = old_data + new_data
Expand Down Expand Up @@ -203,7 +209,7 @@ def recv(self, size, callback):

class ManagerFixture(object):
def __init__(self):
print "ManagerFixture.__init__"
print("ManagerFixture.__init__")
self.manager = None

self.server = MockServer()
Expand Down Expand Up @@ -236,7 +242,7 @@ def __init__(self):
self.manager = manager_future.result()

def connect(self, socket, addr):
print "connect, returning:", self.next_connect_socket
print("connect, returning:", self.next_connect_socket)
socket.pipe = self.next_connect_socket
self.next_connect_socket = None

Expand Down Expand Up @@ -368,10 +374,10 @@ def callback(data):

# Write a frame to the pipe and see that it shows up in
# received data.
other_pipe.endpointa.write_frame('testdata', lambda: None)
other_pipe.endpointa.write_frame(_b('testdata'), lambda: None)
loop.run_until_complete(first_data_future)
assert len(received_data) == 1
assert received_data[0] == 'testdata'
assert received_data[0] == _b('testdata')

def test_send(self, manager):
loop = asyncio.get_event_loop()
Expand Down