Skip to content

Commit

Permalink
cockpit.print: change default channel naming
Browse files Browse the repository at this point in the history
Names like "1" get parsed as integers by default, which is inconvenient.
Call channels like ch1, ch2, etc. so that they're parsed as strings.
  • Loading branch information
allisonkarlitskaya authored and jelly committed Feb 1, 2023
1 parent afe332d commit 1a20c22
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cockpit/print.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def open(self, payload: str, channel: Optional[str] = None, **kwargs: object) ->
"""Opens a channel for the named payload. A channel name is generated if not provided."""
if channel is None:
self.last_channel += 1
channel = str(self.last_channel)
channel = f'ch{self.last_channel}'

self.control('open', channel=channel, payload=payload, **kwargs)

def done(self, channel: Optional[str] = None, **kwargs: object) -> None:
"""Sends a done command on the named channel, or the last opened channel."""
if channel is None:
channel = str(self.last_channel)
channel = f'ch{self.last_channel}'
self.control('done', channel=channel, **kwargs)

def http(self, path: str, method: str = 'GET', done: bool = True, **kwargs: object) -> None:
Expand Down

0 comments on commit 1a20c22

Please sign in to comment.