Skip to content

Commit

Permalink
Merge pull request xapi-project#5528 from minglumlu/private/mingl/CA-…
Browse files Browse the repository at this point in the history
…390570

CA-390570: Py3 socket.sendto needs bytes instead of a string
  • Loading branch information
robhoes authored Mar 25, 2024
2 parents 06762b8 + e15763d commit d5d6da8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/plugins/perfmon
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ def send_perfmon_cmd(cmd):
"Return True for success, or ERROR_%d: <msg> otherwise"
if len(cmd) >= cmdmaxlen:
return "ERROR_0: command too long"
cmd_bytes = cmd.encode()
try:
sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
rc = sock.sendto(cmd, cmdsockname)
rc = sock.sendto(cmd_bytes, cmdsockname)
except socket.error as e:
err, msg = e.args
return "ERROR_%d: %s" % (err, msg)
except Exception:
return "ERROR_1: unknown error"

return str(rc == len(cmd))
return str(rc == len(cmd_bytes))


def stop(session, args):
Expand Down

0 comments on commit d5d6da8

Please sign in to comment.