Commit bf158927 by Bach Dániel

fix get_serial()

parent 776f392c
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
to the platform specific one. to the platform specific one.
""" """
import platform import platform
from os.path import exists
def _get_virtio_device(): def _get_virtio_device():
...@@ -47,11 +46,13 @@ def get_serial(): ...@@ -47,11 +46,13 @@ def get_serial():
port = r'\\.\COM1' port = r'\\.\COM1'
elif system == "Linux": elif system == "Linux":
port = "/dev/virtio-ports/agent" port = "/dev/virtio-ports/agent"
if exists(port): try:
from linux.posixvirtio import SerialPort open(port, 'rw').close()
else: except (OSError, IOError):
from twisted.internet.serialport import SerialPort from twisted.internet.serialport import SerialPort
port = '/dev/ttyS0' port = '/dev/ttyS0'
else:
from linux.posixvirtio import SerialPort
else: else:
raise NotImplementedError("Platform %s is not supported.", system) raise NotImplementedError("Platform %s is not supported.", system)
return (SerialPort, port) return (SerialPort, port)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment