~kiril-vladimiroff/cloud-init/cloudsigma-smbios-data-check

« back to all changes in this revision

Viewing changes to cloudinit/cs_utils.py

  • Committer: Kiril Vladimiroff
  • Date: 2014-05-30 11:17:57 UTC
  • Revision ID: kiril.vladimiroff@cloudsigma.com-20140530111757-tco47uv4mk12ogtk
Add timeouts for reading/writing from/to to the serial console

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
import serial
37
37
 
 
38
READ_TIMEOUT = 60
 
39
WRITE_TIMEOUT = 10
38
40
SERIAL_PORT = '/dev/ttyS1'
39
41
if platform.system() == 'Windows':
40
42
    SERIAL_PORT = 'COM2'
76
78
        self.result = self._marshal(self.raw_result)
77
79
 
78
80
    def _execute(self):
79
 
        connection = serial.Serial(SERIAL_PORT)
 
81
        connection = serial.Serial(port=SERIAL_PORT,
 
82
                                   timeout=READ_TIMEOUT,
 
83
                                   writeTimeout=WRITE_TIMEOUT)
80
84
        connection.write(self.request)
81
85
        return connection.readline().strip('\x04\n')
82
86