Skip to content

Commit 6d827d0

Browse files
Jonathas-Conceicaootavio
authored andcommitted
listener: Drop support for try_again and add proceed command
Signed-off-by: Jonathas-Conceicao <[email protected]>
1 parent 24fedc9 commit 6d827d0

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
echo "Unexpected download response"
5959
exit 2
6060
fi
61-
if [[ "$(echo "error foo" | socat - UNIX-CONNECT:updatehub-statechange.sock)" != "try_again 10" ]]; then
61+
if [[ "$(echo "error foo" | socat - UNIX-CONNECT:updatehub-statechange.sock)" != "" ]]; then
6262
echo "Unexpected error response"
6363
exit 3
6464
fi

examples/state_change_listener.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ def error_callback(error_message, command):
3333
Callback to be called after receiving an error state.
3434
"""
3535
print("ERROR: " + error_message)
36-
print("Sending the command \"retry in 10 seconds\"...")
37-
command.try_again(10)
36+
command.proceed()
3837
print("Done!")
3938

4039

updatehub/listener.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ class StateCommand:
4141
The cancel command message to be sent back to the agent to stop whatever it
4242
is doing.
4343
"""
44-
TRY_AGAIN_MESSAGE = "try_again"
45-
"""
46-
The try_again command message to be sent back to the agent to try again
47-
something. This message is also accompanied by a delay integer, expressed
48-
in seconds, which is a parameter for the try_again method (see bellow).
49-
"""
5044

5145
def __init__(self, connection):
5246
"""
@@ -61,19 +55,14 @@ def cancel(self):
6155
"""
6256
Cancels the current action on the agent.
6357
"""
64-
self._send_message(StateCommand.CANCEL_MESSAGE)
58+
self._connection.send(StateCommand.CANCEL_MESSAGE.encode())
6559

66-
def try_again(self, delay):
60+
def proceed(self):
6761
"""
68-
Tell the agent to try the action again after some time.
69-
70-
:seconds: the time delay in seconds to try the action again.
62+
Tell the agent to proceed with the transition.
7163
"""
72-
message = StateCommand.TRY_AGAIN_MESSAGE + " " + str(delay)
73-
self._send_message(message)
74-
75-
def _send_message(self, message):
76-
self._connection.send(message.encode())
64+
# No message need to be sent to the connection in order to the
65+
# agent to proceed handling the current state.
7766

7867

7968
class MalformedState(Exception):

0 commit comments

Comments
 (0)