api: use str(subject) instead of explicit subject.name

This allows better flexibility, when subject is not necessary a VM
object.
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-27 22:15:02 +02:00
parent c17e63588e
commit 0d9574d9fc
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 6 additions and 2 deletions

View File

@ -323,7 +323,7 @@ class QubesDaemonProtocol(asyncio.Protocol):
self.send_header(0x31)
if subject is not self.app:
self.transport.write(subject.name.encode('ascii'))
self.transport.write(str(subject).encode('ascii'))
self.transport.write(b'\0')
self.transport.write(event.encode('ascii') + b'\0')

View File

@ -77,7 +77,11 @@ class TestMgmt(object):
class Subject:
name = 'subject'
self.send_event(Subject, 'event', payload=untrusted_payload.decode())
def __str__(self):
return 'subject'
self.send_event(Subject(), 'event', payload=untrusted_payload.decode())
try:
# give some time to close the other end
yield from asyncio.sleep(0.1)