Skip to content

Commit

Permalink
pybridge: Stop hard-coding endian flag in DBusChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
Nykseli committed Feb 29, 2024
1 parent a39755f commit eb1f7e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/cockpit/channels/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import errno
import json
import logging
import sys
import traceback
import xml.etree.ElementTree as ET

Expand All @@ -48,6 +49,8 @@

logger = logging.getLogger(__name__)

IS_LITTLE_ENDIAN_MACHINE = sys.byteorder == 'little'

# The dbusjson3 payload
#
# This channel payload type translates JSON encoded messages on a
Expand Down Expand Up @@ -174,6 +177,7 @@ class DBusChannel(Channel):
name = None
bus = None
owner = None
endianness = "<" if IS_LITTLE_ENDIAN_MACHINE else ">"

async def setup_name_owner_tracking(self):
def send_owner(owner):
Expand Down Expand Up @@ -346,10 +350,9 @@ async def do_call(self, message):
# If the method call has kicked off any signals related to
# watch processing, wait for that to be done.
async with self.watch_processing_lock:
# TODO: stop hard-coding the endian flag here.
self.send_json(
reply=[reply.get_body()], id=cookie,
flags="<" if flags is not None else None,
flags=self.endianness if flags is not None else None,
type=reply.get_signature(True)) # noqa: FBT003
except BusError as error:
# actually, should send the fields from the message body
Expand Down

0 comments on commit eb1f7e6

Please sign in to comment.