Skip to content

Commit

Permalink
Add verbose option, False as default
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelmassot committed Sep 12, 2023
1 parent 821c583 commit 58ef975
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

setup(
name="zeroros",
version="1.0.2",
version="1.0.4",
description="ZeroROS middleware",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
4 changes: 3 additions & 1 deletion src/zeroros/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ def __init__(
message_class: type[Message],
ip: str = "127.0.0.1",
port: int = 5555,
verbose: bool = False,
):
print("Creating publisher for topic: ", topic)
if verbose:
print("Creating publisher for topic: ", topic)
self.topic = validate_topic(topic)
self.message_class = message_class
self.ip = ip
Expand Down
8 changes: 6 additions & 2 deletions src/zeroros/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ def __init__(
callback_handle: callable,
ip: str = "127.0.0.1",
port: int = 5556,
verbose: bool = False,
):
self.ip = ip
self.port = port
print("Subscribing to topic: ", topic)
self.verbose = verbose
if self.verbose:
print("Subscribing to topic: ", topic)
self.topic = validate_topic(topic)
self.message_class = message_class
self.url = "tcp://" + str(self.ip) + ":" + str(self.port)
Expand All @@ -47,7 +50,8 @@ def listen(self, callback_handle: callable):
except Exception as e:
print(f"Error for topic {self.topic} on {self.ip}:{self.port}: {e}")
time.sleep(0.05)
print("Stopping subscriber")
if self.verbose:
print("Stopping subscriber")
# Check if the socket is still open
if self.sock.closed is False:
self.sock.close()
Expand Down

0 comments on commit 58ef975

Please sign in to comment.