diff --git a/.gitignore b/.gitignore index 9d8443d..00daf42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -build +./build dist tmp *.pyc diff --git a/README.md b/README.md index 06066dc..bdb1196 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Requirements Documentation ------------- -API documentation can be found [here](http://github.com/nutechsoftware/alarmdecoder/tree/master/docs/_build/html). +API documentation can be found [here](http://github.com/nutechsoftware/alarmdecoder/tree/master/docs/build/html). Examples -------- diff --git a/docs/Makefile b/docs/Makefile index 2283e13..3ed8e91 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -5,7 +5,7 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = _build +BUILDDIR = build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) diff --git a/docs/_build/doctrees/alarmdecoder.doctree b/docs/_build/doctrees/alarmdecoder.doctree deleted file mode 100644 index ee19f08..0000000 Binary files a/docs/_build/doctrees/alarmdecoder.doctree and /dev/null differ diff --git a/docs/_build/html/objects.inv b/docs/_build/html/objects.inv deleted file mode 100644 index 1293b30..0000000 Binary files a/docs/_build/html/objects.inv and /dev/null differ diff --git a/docs/_build/html/searchindex.js b/docs/_build/html/searchindex.js deleted file mode 100644 index 93bf40b..0000000 --- a/docs/_build/html/searchindex.js +++ /dev/null @@ -1 +0,0 @@ -Search.setIndex({envversion:42,terms:{represent:1,all:[1,0],code:1,entri:1,zone_bypass:1,text:1,sent:1,recogn:1,arm:1,ssl_kei:1,socketdevic:1,through:1,human:1,stage_don:1,data:1,find:1,backlight:1,paramet:1,raw:1,current:1,baudrat:1,locat:1,expos:1,also:0,readabl:1,except:1,identif:1,whether:1,add:0,program:1,serialdevic:1,bypass:1,on_read:1,match:1,sourc:[1,0],"return":1,string:1,serial_numb:1,format:1,read:1,numeric_cod:1,stop:1,ssl:1,lcd:1,lrr:1,progress:1,report:1,detach:1,requir:1,enabl:1,ad2:1,name:1,earg:0,list:1,upload:1,authent:1,factori:1,"try":1,provid:1,expand:1,stage_wait:1,mode:1,timeout:1,contain:1,found:1,alarm_event_occur:1,expandermessag:1,page:3,certif:1,nodeviceerror:1,on_open:1,request:1,"static":1,connect:1,usbdevic:1,on_writ:1,our:1,charact:1,read_lin:1,event:1,stop_read:1,pyseri:1,index:3,statu:1,detect:1,parent:1,purge_buff:1,pattern:1,ad2seri:1,callback:1,content:3,pyftdi:1,written:1,reader:1,"new":0,awai:1,method:1,localhost:1,ser2sock:1,process:1,perimet:1,run:1,timeouterror:1,kei:1,state:1,numer:1,gener:1,stage_load:1,cursor_loc:1,entry_delay_off:1,like:0,on_clos:1,base:[1,0],ssl_certif:1,address:1,path:1,"byte":1,armed_hom:1,valu:1,describ:1,fire_alarm:1,search:[1,3],actual:1,zone:1,thread:1,fault:1,readthread:1,stage_start:1,prior:1,rais:1,loop:1,fals:1,find_al:1,ad2usb:1,first:1,oper:0,rang:1,via:1,vid:1,appli:1,keypad:1,"float":1,number:1,automat:1,filenam:1,read_timeout:1,"long":1,famili:1,batteri:1,chime:1,open:1,on_attach:1,differ:1,from:1,usb:1,commun:1,detectthread:1,support:1,system:1,been:1,beep:1,attach:1,singl:1,handler:0,call:[1,0],on_detach:1,start_detect:1,ac_pow:1,interfac:1,stage_upload:1,type:1,start:1,low:1,"function":[1,0],no_reader_thread:1,fire:[1,0],tupl:1,commerror:1,chime_on:1,specifi:1,stage_boot:1,rfmessag:1,flag:1,indic:1,relai:1,obj:0,line:1,repres:1,cach:1,present:1,must:0,sound:1,none:[1,0],sender:0,retriev:1,on_restor:1,restor:1,"default":1,remov:[1,0],purg:1,displai:1,dev:1,stop_detect:1,cursor:1,defin:0,"while":1,kwarg:0,can:0,str:1,error:1,battery_low:1,alarm:1,radio:1,expir:1,backlight_on:1,"int":1,descript:1,arg:0,pid:1,templat:1,bitfield:1,check_zon:1,on_fault:1,itself:0,exist:0,aliv:1,ftdi_vendor_id:1,home:1,close:1,vendor:1,ftdi_product_id:1,alarm_sound:1,serial:1,delai:1,readi:1,panel_data:1,progress_callback:1,author:1,receiv:1,anoth:1,belong:1,when:1,invalid:1,port:1,write:1,field:1,client:1,bool:1,which:1,occur:1,instead:0,you:0,event_data:1,channel:1,updat:1,status:1,product:1,relat:1,intend:1,firmwar:1,supervis:1,buffer:1,expans:1,decod:1,event_typ:1,ftdi:1,partit:1,perimeter_onli:1,wire:1,power:1,user:1,attent:1,basemessag:1,eventhandl:0,associ:1,"class":[1,0],check:1,armed_awai:1,handl:1,classmethod:1,doc:0,clear:1,mask:1,object:[1,0],ssl_ca:1,issu:1,lrrmessag:1,is_reader_al:1,thi:1,programming_mod:1,track:1,func:0,invalidmessageerror:1,usual:1},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:attribute","4":"py:classmethod","5":"py:exception","6":"py:staticmethod"},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","attribute","Python attribute"],"4":["py","classmethod","Python class method"],"5":["py","exception","Python exception"],"6":["py","staticmethod","Python static method"]},filenames:["alarmdecoder.event","alarmdecoder","modules","index"],titles:["event Package","alarmdecoder Package","alarmdecoder","Welcome to alarmdecoder’s documentation!"],objects:{"alarmdecoder.messages.LRRMessage":{partition:[1,3,1,""],event_data:[1,3,1,""],event_type:[1,3,1,""]},"alarmdecoder.messages.BaseMessage":{raw:[1,3,1,""]},"alarmdecoder.messages.ExpanderMessage":{RELAY:[1,3,1,""],ZONE:[1,3,1,""],value:[1,3,1,""],address:[1,3,1,""],type:[1,3,1,""],channel:[1,3,1,""]},"alarmdecoder.event.event":{EventHandler:[0,1,1,""],Event:[0,1,1,""]},"alarmdecoder.zonetracking.Zone":{STATUS:[1,3,1,""],FAULT:[1,3,1,""],CLEAR:[1,3,1,""],CHECK:[1,3,1,""]},"alarmdecoder.devices.SerialDevice":{write:[1,2,1,""],BAUDRATE:[1,3,1,""],read:[1,2,1,""],read_line:[1,2,1,""],find_all:[1,6,1,""],"interface":[1,3,1,""],close:[1,2,1,""],open:[1,2,1,""]},"alarmdecoder.zonetracking":{Zonetracker:[1,1,1,""],Zone:[1,1,1,""]},"alarmdecoder.zonetracking.Zonetracker":{on_restore:[1,3,1,""],EXPIRE:[1,3,1,""],update:[1,2,1,""],on_fault:[1,3,1,""]},"alarmdecoder.devices.Device.ReadThread":{READ_TIMEOUT:[1,3,1,""],stop:[1,2,1,""],run:[1,2,1,""]},"alarmdecoder.event":{event:[0,0,1,""]},"alarmdecoder.messages":{Message:[1,1,1,""],LRRMessage:[1,1,1,""],RFMessage:[1,1,1,""],ExpanderMessage:[1,1,1,""],BaseMessage:[1,1,1,""]},"alarmdecoder.devices":{Device:[1,1,1,""],SocketDevice:[1,1,1,""],USBDevice:[1,1,1,""],SerialDevice:[1,1,1,""]},"alarmdecoder.devices.USBDevice.DetectThread":{run:[1,2,1,""],stop:[1,2,1,""],on_attached:[1,3,1,""],on_detached:[1,3,1,""]},alarmdecoder:{zonetracking:[1,0,1,""],messages:[1,0,1,""],devices:[1,0,1,""],util:[1,0,1,""],panels:[1,0,1,""],event:[0,0,1,""]},"alarmdecoder.devices.SocketDevice":{ssl_certificate:[1,3,1,""],ssl_key:[1,3,1,""],read:[1,2,1,""],ssl_ca:[1,3,1,""],read_line:[1,2,1,""],ssl:[1,3,1,""],write:[1,2,1,""],"interface":[1,3,1,""],close:[1,2,1,""],open:[1,2,1,""]},"alarmdecoder.devices.USBDevice":{write:[1,2,1,""],BAUDRATE:[1,3,1,""],description:[1,3,1,""],read:[1,2,1,""],DetectThread:[1,1,1,""],stop_detection:[1,4,1,""],devices:[1,4,1,""],start_detection:[1,4,1,""],read_line:[1,2,1,""],find_all:[1,4,1,""],FTDI_VENDOR_ID:[1,3,1,""],serial_number:[1,3,1,""],"interface":[1,3,1,""],close:[1,2,1,""],FTDI_PRODUCT_ID:[1,3,1,""],open:[1,2,1,""],find:[1,4,1,""]},"alarmdecoder.messages.Message":{backlight_on:[1,3,1,""],alarm_event_occurred:[1,3,1,""],programming_mode:[1,3,1,""],text:[1,3,1,""],bitfield:[1,3,1,""],armed_home:[1,3,1,""],alarm_sounding:[1,3,1,""],ready:[1,3,1,""],zone_bypassed:[1,3,1,""],panel_data:[1,3,1,""],check_zone:[1,3,1,""],numeric_code:[1,3,1,""],battery_low:[1,3,1,""],chime_on:[1,3,1,""],entry_delay_off:[1,3,1,""],perimeter_only:[1,3,1,""],fire_alarm:[1,3,1,""],ac_power:[1,3,1,""],beeps:[1,3,1,""],mask:[1,3,1,""],armed_away:[1,3,1,""],cursor_location:[1,3,1,""]},"alarmdecoder.devices.Device":{stop_reader:[1,2,1,""],on_open:[1,3,1,""],on_write:[1,3,1,""],ReadThread:[1,1,1,""],on_close:[1,3,1,""],on_read:[1,3,1,""],close:[1,2,1,""],is_reader_alive:[1,2,1,""],id:[1,3,1,""]},"alarmdecoder.messages.RFMessage":{battery:[1,3,1,""],value:[1,3,1,""],supervision:[1,3,1,""],serial_number:[1,3,1,""],x:[1,3,1,""],loop:[1,3,1,""]},"alarmdecoder.event.event.EventHandler":{fire:[0,2,1,""],add:[0,2,1,""],remove:[0,2,1,""]},"alarmdecoder.util.Firmware":{STAGE_LOAD:[1,3,1,""],upload:[1,6,1,""],STAGE_BOOT:[1,3,1,""],STAGE_START:[1,3,1,""],STAGE_UPLOADING:[1,3,1,""],STAGE_WAITING:[1,3,1,""],STAGE_DONE:[1,3,1,""]},"alarmdecoder.util":{CommError:[1,5,1,""],Firmware:[1,1,1,""],TimeoutError:[1,5,1,""],NoDeviceError:[1,5,1,""],InvalidMessageError:[1,5,1,""]}},titleterms:{subpackag:1,alarmdecod:[1,2,3],welcom:3,modul:[1,0],devic:1,zonetrack:1,util:1,packag:[1,0],messag:1,indic:3,tabl:3,document:3,event:0,panel:1}}) \ No newline at end of file diff --git a/docs/build/doctrees/alarmdecoder.doctree b/docs/build/doctrees/alarmdecoder.doctree new file mode 100644 index 0000000..74acdcf Binary files /dev/null and b/docs/build/doctrees/alarmdecoder.doctree differ diff --git a/docs/_build/doctrees/alarmdecoder.event.doctree b/docs/build/doctrees/alarmdecoder.event.doctree similarity index 79% rename from docs/_build/doctrees/alarmdecoder.event.doctree rename to docs/build/doctrees/alarmdecoder.event.doctree index 20bb85f..efd7056 100644 Binary files a/docs/_build/doctrees/alarmdecoder.event.doctree and b/docs/build/doctrees/alarmdecoder.event.doctree differ diff --git a/docs/_build/doctrees/environment.pickle b/docs/build/doctrees/environment.pickle similarity index 57% rename from docs/_build/doctrees/environment.pickle rename to docs/build/doctrees/environment.pickle index 2b5e17a..3a0b59a 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/index.doctree b/docs/build/doctrees/index.doctree similarity index 87% rename from docs/_build/doctrees/index.doctree rename to docs/build/doctrees/index.doctree index 639d50c..5009232 100644 Binary files a/docs/_build/doctrees/index.doctree and b/docs/build/doctrees/index.doctree differ diff --git a/docs/_build/doctrees/modules.doctree b/docs/build/doctrees/modules.doctree similarity index 78% rename from docs/_build/doctrees/modules.doctree rename to docs/build/doctrees/modules.doctree index 9f3af33..98c33aa 100644 Binary files a/docs/_build/doctrees/modules.doctree and b/docs/build/doctrees/modules.doctree differ diff --git a/docs/_build/html/.buildinfo b/docs/build/html/.buildinfo similarity index 100% rename from docs/_build/html/.buildinfo rename to docs/build/html/.buildinfo diff --git a/docs/_build/html/_modules/alarmdecoder/devices.html b/docs/build/html/_modules/alarmdecoder/devices.html similarity index 87% rename from docs/_build/html/_modules/alarmdecoder/devices.html rename to docs/build/html/_modules/alarmdecoder/devices.html index 36eccc1..b77c905 100644 --- a/docs/_build/html/_modules/alarmdecoder/devices.html +++ b/docs/build/html/_modules/alarmdecoder/devices.html @@ -53,18 +53,20 @@ .. moduleauthor:: Scott Petersen <scott@nutech.com> """ -import usb.core, usb.util +import usb.core +import usb.util import time import threading -import serial, serial.tools.list_ports +import serial +import serial.tools.list_ports import socket from OpenSSL import SSL, crypto -from pyftdi.pyftdi.ftdi import * -from pyftdi.pyftdi.usbtools import * +from pyftdi.pyftdi.ftdi import Ftdi, FtdiError from .util import CommError, TimeoutError, NoDeviceError from .event import event +
[docs]class Device(object): """ Generic parent device to all Alarm Decoder (AD2) products. @@ -92,7 +94,7 @@ """ return self - def __exit__(self, type, value, traceback): + def __exit__(self, exc_type, exc_value, traceback): """ Support for context manager __exit__. """ @@ -142,7 +144,7 @@ self._read_thread.stop() self._device.close() - except: + except Exception: pass self.on_close() @@ -182,15 +184,14 @@ try: self._device.read_line(timeout=self.READ_TIMEOUT) - except TimeoutError, err: + except TimeoutError: pass - except Exception, err: + except Exception: self._running = False - #raise err - time.sleep(0.01) +
[docs]class USBDevice(Device): """ @@ -206,6 +207,7 @@ """Default baudrate for AD2USB devices.""" __devices = [] + __detect_thread = None @classmethod
[docs] def find_all(cls, vid=FTDI_VENDOR_ID, pid=FTDI_PRODUCT_ID): @@ -237,9 +239,11 @@ @classmethod
[docs] def find(cls, device=None): """ - Factory method that returns the requested USBDevice device, or the first device. + Factory method that returns the requested USBDevice device, or the + first device. - :param device: Tuple describing the USB device to open, as returned by find_all(). + :param device: Tuple describing the USB device to open, as returned + by find_all(). :type device: tuple :returns: USBDevice object utilizing the specified device. @@ -281,7 +285,7 @@ try: cls.__detect_thread.stop() - except: + except Exception: pass
@property @@ -350,28 +354,32 @@ """ Constructor - :param interface: May specify either the serial number or the device index. + :param interface: May specify either the serial number or the device + index. :type interface: str or int """ Device.__init__(self) self._device = Ftdi() + self._interface = 0 self._device_number = 0 self._serial_number = None - self.interface = interface self._vendor_id = USBDevice.FTDI_VENDOR_ID self._product_id = USBDevice.FTDI_PRODUCT_ID self._endpoint = 0 self._description = None + self.interface = interface +
[docs] def open(self, baudrate=BAUDRATE, no_reader_thread=False): """ Opens the device. :param baudrate: The baudrate to use. :type baudrate: int - :param no_reader_thread: Whether or not to automatically start the reader thread. + :param no_reader_thread: Whether or not to automatically start the + reader thread. :type no_reader_thread: bool :raises: NoDeviceError @@ -383,11 +391,11 @@ # Open the device and start up the thread. try: self._device.open(self._vendor_id, - self._product_id, - self._endpoint, - self._device_number, - self._serial_number, - self._description) + self._product_id, + self._endpoint, + self._device_number, + self._serial_number, + self._description) self._device.set_baudrate(baudrate) @@ -415,10 +423,10 @@ try: Device.close(self) - # HACK: Probably should fork pyftdi and make this call in .close(). + # HACK: Probably should fork pyftdi and make this call in .close() self._device.usb_dev.attach_kernel_driver(self._device_number) - except: + except Exception: pass
[docs] def write(self, data): @@ -459,29 +467,28 @@ """ Reads a line from the device. - :param timeout: Read timeout + :param timeout: The read timeout. :type timeout: float - :param purge_buffer: Indicates whether to purge the buffer prior to reading. + :param purge_buffer: Indicates whether to purge the buffer prior to + reading. :type purge_buffer: bool :returns: The line that was read. :raises: CommError, TimeoutError """ - if purge_buffer: - self._buffer = '' - def timeout_event(): + """Handles read timeout event""" timeout_event.reading = False - timeout_event.reading = True - got_line = False - ret = None + if purge_buffer: + self._buffer = '' + + got_line, ret = False, None - timer = None + timer = threading.Timer(timeout, timeout_event) if timeout > 0: - timer = threading.Timer(timeout, timeout_event) timer.start() try: @@ -492,36 +499,27 @@ self._buffer += buf if buf == "\n": - if len(self._buffer) > 1: - if self._buffer[-2] == "\r": - self._buffer = self._buffer[:-2] + self._buffer = self._buffer.rstrip("\r\n") - # ignore if we just got \r\n with nothing else in the buffer. - if len(self._buffer) != 0: - got_line = True - break - else: - self._buffer = self._buffer[:-1] + if len(self._buffer) > 0: + got_line = True + break except (usb.core.USBError, FtdiError), err: - if timer: - timer.cancel() - raise CommError('Error reading from device: {0}'.format(str(err)), err) else: if got_line: - ret = self._buffer - self._buffer = '' + ret, self._buffer = self._buffer, '' self.on_read(data=ret) - if timer: - if timer.is_alive(): - timer.cancel() else: raise TimeoutError('Timeout while waiting for line terminator.') + finally: + timer.cancel() + return ret
def _get_serial_number(self): @@ -576,17 +574,15 @@ try: current_devices = set(USBDevice.find_all()) - new_devices = [d for d in current_devices if d not in last_devices] - removed_devices = [d for d in last_devices if d not in current_devices] - last_devices = current_devices + for dev in current_devices.difference(last_devices): + self.on_attached(device=dev) - for d in new_devices: - self.on_attached(device=d) + for dev in last_devices.difference(current_devices): + self.on_detached(device=dev) - for d in removed_devices: - self.on_detached(device=d) + last_devices = current_devices - except CommError, err: + except CommError: pass time.sleep(0.25) @@ -620,7 +616,7 @@ else: devices = serial.tools.list_ports.comports() - except SerialException, err: + except serial.SerialException, err: raise CommError('Error enumerating serial devices: {0}'.format(str(err)), err) return devices @@ -655,7 +651,8 @@ self._port = interface self._id = interface - self._device = serial.Serial(timeout=0, writeTimeout=0) # Timeout = non-blocking to match pyftdi. + # Timeout = non-blocking to match pyftdi. + self._device = serial.Serial(timeout=0, writeTimeout=0)
[docs] def open(self, baudrate=BAUDRATE, no_reader_thread=False): """ @@ -663,7 +660,8 @@ :param baudrate: The baudrate to use with the device. :type baudrate: int - :param no_reader_thread: Whether or not to automatically start the reader thread. + :param no_reader_thread: Whether or not to automatically start the + reader thread. :type no_reader_thread: bool :raises: NoDeviceError @@ -675,17 +673,17 @@ if self._port is None: raise NoDeviceError('No device interface specified.') - self._device.port = self._port - # Open the device and start up the reader thread. try: + self._device.port = self._port self._device.open() - self._device.baudrate = baudrate # NOTE: Setting the baudrate before opening the - # port caused issues with Moschip 7840/7820 - # USB Serial Driver converter. (mos7840) - # - # Moving it to this point seems to resolve - # all issues with it. + # NOTE: Setting the baudrate before opening the + # port caused issues with Moschip 7840/7820 + # USB Serial Driver converter. (mos7840) + # + # Moving it to this point seems to resolve + # all issues with it. + self._device.baudrate = baudrate except (serial.SerialException, ValueError), err: raise NoDeviceError('Error opening device on port {0}.'.format(self._port), err) @@ -706,7 +704,7 @@ try: Device.close(self) - except: + except Exception: pass
[docs] def write(self, data): @@ -721,7 +719,7 @@ try: self._device.write(data) - except serial.SerialTimeoutException, err: + except serial.SerialTimeoutException: pass except serial.SerialException, err: @@ -753,64 +751,60 @@ :param timeout: The read timeout. :type timeout: float - :param purge_buffer: Indicates whether to purge the buffer prior to reading. + :param purge_buffer: Indicates whether to purge the buffer prior to + reading. :type purge_buffer: bool - :returns: The line read. + :returns: The line that was read. :raises: CommError, TimeoutError """ + def timeout_event(): + """Handles read timeout event""" timeout_event.reading = False - timeout_event.reading = True - got_line = False - ret = None + if purge_buffer: + self._buffer = '' + + got_line, ret = False, None - timer = None + timer = threading.Timer(timeout, timeout_event) if timeout > 0: - timer = threading.Timer(timeout, timeout_event) timer.start() try: while timeout_event.reading: buf = self._device.read(1) - if buf != '' and buf != "\xff": # AD2SERIAL specifically apparently sends down \xFF on boot. + # NOTE: AD2SERIAL apparently sends down \xFF on boot. + if buf != '' and buf != "\xff": self._buffer += buf if buf == "\n": - if len(self._buffer) > 1: - if self._buffer[-2] == "\r": - self._buffer = self._buffer[:-2] + self._buffer = self._buffer.rstrip("\r\n") - # ignore if we just got \r\n with nothing else in the buffer. - if len(self._buffer) != 0: - got_line = True - break - else: - self._buffer = self._buffer[:-1] + if len(self._buffer) > 0: + got_line = True + break except (OSError, serial.SerialException), err: - if timer: - timer.cancel() - raise CommError('Error reading from device: {0}'.format(str(err)), err) else: if got_line: - ret = self._buffer - self._buffer = '' + ret, self._buffer = self._buffer, '' self.on_read(data=ret) - if timer: - if timer.is_alive(): - timer.cancel() else: raise TimeoutError('Timeout while waiting for line terminator.') + finally: + timer.cancel() + return ret +
[docs]class SocketDevice(Device): """ @@ -835,8 +829,7 @@ :param value: Tuple containing the host and port to use. :type value: tuple """ - self._host = value[0] - self._port = value[1] + self._host, self._port = value
@property def ssl(self): @@ -898,7 +891,8 @@ @property def ssl_ca(self): """ - Retrieves the SSL Certificate Authority certificate used for authentication. + Retrieves the SSL Certificate Authority certificate used for + authentication. :returns: The CA path """ @@ -935,7 +929,8 @@ :param baudrate: The baudrate to use :type baudrate: int - :param no_reader_thread: Whether or not to automatically open the reader thread. + :param no_reader_thread: Whether or not to automatically open the reader + thread. :type no_reader_thread: bool :raises: NoDeviceError, CommError @@ -976,11 +971,12 @@ self._device.shutdown() else: - self._device.shutdown(socket.SHUT_RDWR) # Make sure that it closes immediately. + # Make sure that it closes immediately. + self._device.shutdown(socket.SHUT_RDWR) Device.close(self) - except Exception, ex: + except Exception: pass
[docs] def write(self, data): @@ -1031,27 +1027,26 @@ :param timeout: The read timeout. :type timeout: float - :param purge_buffer: Indicates whether to purge the buffer prior to reading. + :param purge_buffer: Indicates whether to purge the buffer prior to + reading. :type purge_buffer: bool - :returns: The line read from the device. + :returns: The line that was read.: :raises: CommError, TimeoutError """ - if purge_buffer: - self._buffer = '' - def timeout_event(): + """Handles read timeout event""" timeout_event.reading = False - timeout_event.reading = True - got_line = False - ret = None + if purge_buffer: + self._buffer = '' - timer = None + got_line, ret = False, None + + timer = threading.Timer(timeout, timeout_event) if timeout > 0: - timer = threading.Timer(timeout, timeout_event) timer.start() try: @@ -1062,39 +1057,34 @@ self._buffer += buf if buf == "\n": - if len(self._buffer) > 1: - if self._buffer[-2] == "\r": - self._buffer = self._buffer[:-2] + self._buffer = self._buffer.rstrip("\r\n") - # ignore if we just got \r\n with nothing else in the buffer. - if len(self._buffer) != 0: - got_line = True - break - else: - self._buffer = self._buffer[:-1] + if len(self._buffer) > 0: + got_line = True + break except socket.error, err: - if timer: - timer.cancel() - raise CommError('Error reading from device: {0}'.format(str(err)), err) else: if got_line: - ret = self._buffer - self._buffer = '' + ret, self._buffer = self._buffer, '' self.on_read(data=ret) - if timer: - if timer.is_alive(): - timer.cancel() else: raise TimeoutError('Timeout while waiting for line terminator.') + finally: + timer.cancel() + return ret
def _init_ssl(self): + """ + Initializes our device as an SSL connection. + """ + try: ctx = SSL.Context(SSL.TLSv1_METHOD) @@ -1122,6 +1112,9 @@ raise CommError('Error setting up SSL connection.', err) def _verify_ssl_callback(self, connection, x509, errnum, errdepth, ok): + """ + SSL verification callback. + """ return ok diff --git a/docs/_build/html/_modules/alarmdecoder/event/event.html b/docs/build/html/_modules/alarmdecoder/event/event.html similarity index 99% rename from docs/_build/html/_modules/alarmdecoder/event/event.html rename to docs/build/html/_modules/alarmdecoder/event/event.html index 4cb5a8b..e62ec66 100644 --- a/docs/_build/html/_modules/alarmdecoder/event/event.html +++ b/docs/build/html/_modules/alarmdecoder/event/event.html @@ -58,6 +58,7 @@ # * Added type check in fire() # * Removed earg from fire() and added support for args/kwargs. +
[docs]class Event(object): def __init__(self, doc=None): diff --git a/docs/_build/html/_modules/alarmdecoder/messages.html b/docs/build/html/_modules/alarmdecoder/messages.html similarity index 96% rename from docs/_build/html/_modules/alarmdecoder/messages.html rename to docs/build/html/_modules/alarmdecoder/messages.html index 6d2d509..2645690 100644 --- a/docs/_build/html/_modules/alarmdecoder/messages.html +++ b/docs/build/html/_modules/alarmdecoder/messages.html @@ -58,6 +58,7 @@ from .util import InvalidMessageError +
[docs]class BaseMessage(object): """ Base class for messages. @@ -77,6 +78,7 @@ String conversion operator. """ return self.raw +
[docs]class Message(BaseMessage): """ @@ -137,7 +139,7 @@ """ BaseMessage.__init__(self) - self._regex = re.compile('("(?:[^"]|"")*"|[^,]*),("(?:[^"]|"")*"|[^,]*),("(?:[^"]|"")*"|[^,]*),("(?:[^"]|"")*"|[^,]*)') + self._regex = re.compile('^(!KPE:){0,1}(\[[a-fA-F0-9\-]+\]),([a-fA-F0-9]+),(\[[a-fA-F0-9]+\]),(".+")$') if data is not None: self._parse_message(data) @@ -157,12 +159,12 @@ :raises: InvalidMessageError """ - m = self._regex.match(data) + match = self._regex.match(data) - if m is None: + if match is None: raise InvalidMessageError('Received invalid message: {0}'.format(data)) - self.bitfield, self.numeric_code, self.panel_data, alpha = m.group(1, 2, 3, 4) + header, self.bitfield, self.numeric_code, self.panel_data, alpha = match.group(1, 2, 3, 4, 5) self.mask = int(self.panel_data[3:3+8], 16) is_bit_set = lambda bit: not self.bitfield[bit] == "0" @@ -188,7 +190,9 @@ self.text = alpha.strip('"') if int(self.panel_data[19:21], 16) & 0x01 > 0: - self.cursor_location = int(self.bitfield[21:23], 16) # Alpha character index that the cursor is on. + # Current cursor location on the alpha display. + self.cursor_location = int(self.bitfield[21:23], 16) +
[docs]class ExpanderMessage(BaseMessage): """ @@ -200,7 +204,6 @@ RELAY = 1 """Flag indicating that the expander message relates to a Relay Expander.""" - type = None """Expander message type: ExpanderMessage.ZONE or ExpanderMessage.RELAY""" address = -1 @@ -253,6 +256,7 @@ self.type = ExpanderMessage.RELAY else: raise InvalidMessageError('Unknown expander message header: {0}'.format(data)) +
[docs]class RFMessage(BaseMessage): """ @@ -315,6 +319,7 @@ except ValueError: raise InvalidMessageError('Received invalid message: {0}'.format(data)) +
[docs]class LRRMessage(BaseMessage): """ diff --git a/docs/_build/html/_modules/alarmdecoder/util.html b/docs/build/html/_modules/alarmdecoder/util.html similarity index 95% rename from docs/_build/html/_modules/alarmdecoder/util.html rename to docs/build/html/_modules/alarmdecoder/util.html index 57eabec..3540201 100644 --- a/docs/_build/html/_modules/alarmdecoder/util.html +++ b/docs/build/html/_modules/alarmdecoder/util.html @@ -56,29 +56,34 @@ import time import threading +
[docs]class NoDeviceError(Exception): """ No devices found. """ pass +
[docs]class CommError(Exception): """ There was an error communicating with the device. """ pass +
[docs]class TimeoutError(Exception): """ There was a timeout while trying to communicate with the device. """ pass +
[docs]class InvalidMessageError(Exception): """ The format of the panel message was invalid. """ pass +
[docs]class Firmware(object): """ @@ -93,6 +98,7 @@ STAGE_UPLOADING = 4 STAGE_DONE = 5 + # FIXME: Rewrite this monstrosity. @staticmethod
[docs] def upload(dev, filename, progress_callback=None): """ @@ -110,13 +116,13 @@ """ Perform the actual firmware upload to the device. """ - with open(filename) as f: - for line in f: + with open(filename) as upload_file: + for line in upload_file: line = line.rstrip() if line[0] == ':': dev.write(line + "\r") - res = dev.read_line(timeout=10.0) + dev.read_line(timeout=10.0) if progress_callback is not None: progress_callback(Firmware.STAGE_UPLOADING) @@ -125,9 +131,11 @@ def read_until(pattern, timeout=0.0): """ - Read characters until a specific pattern is found or the timeout is hit. + Read characters until a specific pattern is found or the timeout is + hit. """ def timeout_event(): + """Handles the read timeout event.""" timeout_event.reading = False timeout_event.reading = True @@ -137,7 +145,6 @@ timer = threading.Timer(timeout, timeout_event) timer.start() - buf = '' position = 0 while timeout_event.reading: @@ -152,7 +159,7 @@ else: position = 0 - except Exception, err: + except Exception: pass if timer: @@ -162,6 +169,7 @@ raise TimeoutError('Timeout while waiting for line terminator.') def stage_callback(stage): + """Callback to update progress for the specified stage.""" if progress_callback is not None: progress_callback(stage) diff --git a/docs/_build/html/_modules/alarmdecoder/zonetracking.html b/docs/build/html/_modules/alarmdecoder/zonetracking.html similarity index 91% rename from docs/_build/html/_modules/alarmdecoder/zonetracking.html rename to docs/build/html/_modules/alarmdecoder/zonetracking.html index 3cd34b7..b0ed0c1 100644 --- a/docs/_build/html/_modules/alarmdecoder/zonetracking.html +++ b/docs/build/html/_modules/alarmdecoder/zonetracking.html @@ -59,6 +59,7 @@ from .event import event from .messages import ExpanderMessage +
[docs]class Zone(object): """ Representation of a panel zone. @@ -71,7 +72,7 @@ CHECK = 2 # Wire fault """Status indicating that there is a wiring issue with the zone.""" - STATUS = { CLEAR: 'CLEAR', FAULT: 'FAULT', CHECK: 'CHECK' } + STATUS = {CLEAR: 'CLEAR', FAULT: 'FAULT', CHECK: 'CHECK'} def __init__(self, zone=0, name='', status=CLEAR): """ @@ -100,6 +101,7 @@ Human readable representation operator. """ return 'Zone({0}, {1}, ts {2})'.format(self.zone, Zone.STATUS[self.status], self.timestamp) +
[docs]class Zonetracker(object): """ @@ -129,7 +131,7 @@ """ if isinstance(message, ExpanderMessage): if message.type == ExpanderMessage.ZONE: - zone = self._expander_to_zone(message.address, message.channel) + zone = self.expander_to_zone(message.address, message.channel) status = Zone.CLEAR if message.value == 1: @@ -137,9 +139,10 @@ elif message.value == 2: status = Zone.CHECK - # NOTE: Expander zone faults are handled differently than regular messages. - # We don't include them in self._zones_faulted because they are not reported - # by the panel in it's rolling list of faults. + # NOTE: Expander zone faults are handled differently than + # regular messages. We don't include them in + # self._zones_faulted because they are not reported + # by the panel in it's rolling list of faults. try: self._update_zone(zone, status=status) @@ -149,12 +152,13 @@ else: # Panel is ready, restore all zones. # - # NOTE: This will need to be updated to support panels with multiple partitions. - # In it's current state a ready on partition #1 will end up clearing all zones, even - # if they exist elsewhere and it shouldn't. + # NOTE: This will need to be updated to support panels with + # multiple partitions. In it's current state a ready on + # partition #1 will end up clearing all zones, even if they + # exist elsewhere and it shouldn't. if message.ready: - for z in self._zones_faulted: - self._update_zone(z, Zone.CLEAR) + for zone in self._zones_faulted: + self._update_zone(zone, Zone.CLEAR) self._last_zone_fault = 0 @@ -168,17 +172,18 @@ except ValueError: zone = int(message.numeric_code, 16) - # NOTE: Odd case for ECP failures. Apparently they report as zone 191 (0xBF) regardless - # of whether or not the 3-digit mode is enabled... so we have to pull it out of the - # alpha message. + # NOTE: Odd case for ECP failures. Apparently they report as + # zone 191 (0xBF) regardless of whether or not the + # 3-digit mode is enabled... so we have to pull it out + # of the alpha message. if zone == 191: zone_regex = re.compile('^CHECK (\d+).*$') - m = zone_regex.match(message.text) - if m is None: + match = zone_regex.match(message.text) + if match is None: return - zone = m.group(1) + zone = match.group(1) # Add new zones and clear expired ones. if zone in self._zones_faulted: @@ -198,6 +203,25 @@ self._last_zone_fault = zone self._clear_expired_zones() +
+
[docs] def expander_to_zone(self, address, channel): + """ + Convert an address and channel into a zone number. + + :param address: The expander address + :type address: int + :param channel: The channel + :type channel: int + + :returns: The zone number associated with an address and channel. + """ + + # TODO: This is going to need to be reworked to support the larger + # panels without fixed addressing on the expanders. + + idx = address - 7 # Expanders start at address 7. + + return address + channel + (idx * 7) + 1
def _clear_zones(self, zone): """ @@ -323,26 +347,7 @@ :returns: Whether or not the zone is expired. """ - return time.time() > self._zones[zone].timestamp + Zonetracker.EXPIRE - - def _expander_to_zone(self, address, channel): - """ - Convert an address and channel into a zone number. - - :param address: The expander address - :type address: int - :param channel: The channel - :type channel: int - - :returns: The zone number associated with an address and channel. - """ - - # TODO: This is going to need to be reworked to support the larger - # panels without fixed addressing on the expanders. - - idx = address - 7 # Expanders start at address 7. - - return address + channel + (idx * 7) + 1
+ return time.time() > self._zones[zone].timestamp + Zonetracker.EXPIRE
diff --git a/docs/_build/html/_modules/index.html b/docs/build/html/_modules/index.html similarity index 100% rename from docs/_build/html/_modules/index.html rename to docs/build/html/_modules/index.html diff --git a/docs/_build/html/_sources/alarmdecoder.event.txt b/docs/build/html/_sources/alarmdecoder.event.txt similarity index 100% rename from docs/_build/html/_sources/alarmdecoder.event.txt rename to docs/build/html/_sources/alarmdecoder.event.txt diff --git a/docs/_build/html/_sources/alarmdecoder.txt b/docs/build/html/_sources/alarmdecoder.txt similarity index 100% rename from docs/_build/html/_sources/alarmdecoder.txt rename to docs/build/html/_sources/alarmdecoder.txt diff --git a/docs/_build/html/_sources/index.txt b/docs/build/html/_sources/index.txt similarity index 100% rename from docs/_build/html/_sources/index.txt rename to docs/build/html/_sources/index.txt diff --git a/docs/_build/html/_sources/modules.txt b/docs/build/html/_sources/modules.txt similarity index 100% rename from docs/_build/html/_sources/modules.txt rename to docs/build/html/_sources/modules.txt diff --git a/docs/_build/html/_static/ajax-loader.gif b/docs/build/html/_static/ajax-loader.gif similarity index 100% rename from docs/_build/html/_static/ajax-loader.gif rename to docs/build/html/_static/ajax-loader.gif diff --git a/docs/_build/html/_static/basic.css b/docs/build/html/_static/basic.css similarity index 100% rename from docs/_build/html/_static/basic.css rename to docs/build/html/_static/basic.css diff --git a/docs/_build/html/_static/comment-bright.png b/docs/build/html/_static/comment-bright.png similarity index 100% rename from docs/_build/html/_static/comment-bright.png rename to docs/build/html/_static/comment-bright.png diff --git a/docs/_build/html/_static/comment-close.png b/docs/build/html/_static/comment-close.png similarity index 100% rename from docs/_build/html/_static/comment-close.png rename to docs/build/html/_static/comment-close.png diff --git a/docs/_build/html/_static/comment.png b/docs/build/html/_static/comment.png similarity index 100% rename from docs/_build/html/_static/comment.png rename to docs/build/html/_static/comment.png diff --git a/docs/_build/html/_static/default.css b/docs/build/html/_static/default.css similarity index 100% rename from docs/_build/html/_static/default.css rename to docs/build/html/_static/default.css diff --git a/docs/_build/html/_static/doctools.js b/docs/build/html/_static/doctools.js similarity index 100% rename from docs/_build/html/_static/doctools.js rename to docs/build/html/_static/doctools.js diff --git a/docs/_build/html/_static/down-pressed.png b/docs/build/html/_static/down-pressed.png similarity index 100% rename from docs/_build/html/_static/down-pressed.png rename to docs/build/html/_static/down-pressed.png diff --git a/docs/_build/html/_static/down.png b/docs/build/html/_static/down.png similarity index 100% rename from docs/_build/html/_static/down.png rename to docs/build/html/_static/down.png diff --git a/docs/_build/html/_static/file.png b/docs/build/html/_static/file.png similarity index 100% rename from docs/_build/html/_static/file.png rename to docs/build/html/_static/file.png diff --git a/docs/_build/html/_static/jquery.js b/docs/build/html/_static/jquery.js similarity index 100% rename from docs/_build/html/_static/jquery.js rename to docs/build/html/_static/jquery.js diff --git a/docs/_build/html/_static/minus.png b/docs/build/html/_static/minus.png similarity index 100% rename from docs/_build/html/_static/minus.png rename to docs/build/html/_static/minus.png diff --git a/docs/_build/html/_static/plus.png b/docs/build/html/_static/plus.png similarity index 100% rename from docs/_build/html/_static/plus.png rename to docs/build/html/_static/plus.png diff --git a/docs/_build/html/_static/pygments.css b/docs/build/html/_static/pygments.css similarity index 100% rename from docs/_build/html/_static/pygments.css rename to docs/build/html/_static/pygments.css diff --git a/docs/_build/html/_static/searchtools.js b/docs/build/html/_static/searchtools.js similarity index 100% rename from docs/_build/html/_static/searchtools.js rename to docs/build/html/_static/searchtools.js diff --git a/docs/_build/html/_static/sidebar.js b/docs/build/html/_static/sidebar.js similarity index 100% rename from docs/_build/html/_static/sidebar.js rename to docs/build/html/_static/sidebar.js diff --git a/docs/_build/html/_static/underscore.js b/docs/build/html/_static/underscore.js similarity index 100% rename from docs/_build/html/_static/underscore.js rename to docs/build/html/_static/underscore.js diff --git a/docs/_build/html/_static/up-pressed.png b/docs/build/html/_static/up-pressed.png similarity index 100% rename from docs/_build/html/_static/up-pressed.png rename to docs/build/html/_static/up-pressed.png diff --git a/docs/_build/html/_static/up.png b/docs/build/html/_static/up.png similarity index 100% rename from docs/_build/html/_static/up.png rename to docs/build/html/_static/up.png diff --git a/docs/_build/html/_static/websupport.js b/docs/build/html/_static/websupport.js similarity index 100% rename from docs/_build/html/_static/websupport.js rename to docs/build/html/_static/websupport.js diff --git a/docs/_build/html/alarmdecoder.event.html b/docs/build/html/alarmdecoder.event.html similarity index 100% rename from docs/_build/html/alarmdecoder.event.html rename to docs/build/html/alarmdecoder.event.html diff --git a/docs/_build/html/alarmdecoder.html b/docs/build/html/alarmdecoder.html similarity index 97% rename from docs/_build/html/alarmdecoder.html rename to docs/build/html/alarmdecoder.html index 6b8a672..2ac6071 100644 --- a/docs/_build/html/alarmdecoder.html +++ b/docs/build/html/alarmdecoder.html @@ -212,12 +212,14 @@
classmethod find(device=None)[source]
-

Factory method that returns the requested USBDevice device, or the first device.

+

Factory method that returns the requested USBDevice device, or the +first device.

- + @@ -303,7 +305,8 @@ @@ -361,8 +364,9 @@ @@ -462,7 +466,8 @@ @@ -521,11 +526,12 @@ -
Parameters:device (tuple) – Tuple describing the USB device to open, as returned by find_all().
Parameters:device (tuple) – Tuple describing the USB device to open, as returned +by find_all().
Returns:USBDevice object utilizing the specified device.
Parameters:
  • baudrate (int) – The baudrate to use.
  • -
  • no_reader_thread (bool) – Whether or not to automatically start the reader thread.
  • +
  • no_reader_thread (bool) – Whether or not to automatically start the +reader thread.
Parameters:
    -
  • timeout (float) – Read timeout
  • -
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to reading.
  • +
  • timeout (float) – The read timeout.
  • +
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to +reading.
Parameters:
  • baudrate (int) – The baudrate to use with the device.
  • -
  • no_reader_thread (bool) – Whether or not to automatically start the reader thread.
  • +
  • no_reader_thread (bool) – Whether or not to automatically start the +reader thread.
Parameters:
  • timeout (float) – The read timeout.
  • -
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to reading.
  • +
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to +reading.
Returns:

The line read.

+
Returns:

The line that was read.

Raises :

CommError, TimeoutError

@@ -602,7 +608,8 @@ exposed via ser2sock or another Serial to IP interface.

ssl_ca[source]
-

Retrieves the SSL Certificate Authority certificate used for authentication.

+

Retrieves the SSL Certificate Authority certificate used for +authentication.

@@ -623,7 +630,8 @@ exposed via ser2sock or another Serial to IP interface.

@@ -684,11 +692,12 @@ exposed via ser2sock or another Serial to IP interface.

-
Parameters:
  • baudrate (int) – The baudrate to use
  • -
  • no_reader_thread (bool) – Whether or not to automatically open the reader thread.
  • +
  • no_reader_thread (bool) – Whether or not to automatically open the reader +thread.
Parameters:
  • timeout (float) – The read timeout.
  • -
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to reading.
  • +
  • purge_buffer (bool) – Indicates whether to purge the buffer prior to +reading.
Returns:

The line read from the device.

+
Returns:

The line that was read.:

Raises :

CommError, TimeoutError

@@ -861,6 +870,27 @@ exposed via ser2sock or another Serial to IP interface.

+
+
+expander_to_zone(address, channel)[source]
+

Convert an address and channel into a zone number.

+ +++ + + + + + +
Parameters:
    +
  • address (int) – The expander address
  • +
  • channel (int) – The channel
  • +
+
Returns:

The zone number associated with an address and channel.

+
+
+ diff --git a/docs/_build/html/genindex.html b/docs/build/html/genindex.html similarity index 99% rename from docs/_build/html/genindex.html rename to docs/build/html/genindex.html index 111128e..e92fc80 100644 --- a/docs/_build/html/genindex.html +++ b/docs/build/html/genindex.html @@ -281,6 +281,10 @@ +
expander_to_zone() (alarmdecoder.zonetracking.Zonetracker method) +
+ +
ExpanderMessage (class in alarmdecoder.messages)
diff --git a/docs/_build/html/index.html b/docs/build/html/index.html similarity index 100% rename from docs/_build/html/index.html rename to docs/build/html/index.html diff --git a/docs/_build/html/modules.html b/docs/build/html/modules.html similarity index 100% rename from docs/_build/html/modules.html rename to docs/build/html/modules.html diff --git a/docs/build/html/objects.inv b/docs/build/html/objects.inv new file mode 100644 index 0000000..7e14e50 Binary files /dev/null and b/docs/build/html/objects.inv differ diff --git a/docs/_build/html/py-modindex.html b/docs/build/html/py-modindex.html similarity index 100% rename from docs/_build/html/py-modindex.html rename to docs/build/html/py-modindex.html diff --git a/docs/_build/html/search.html b/docs/build/html/search.html similarity index 100% rename from docs/_build/html/search.html rename to docs/build/html/search.html diff --git a/docs/build/html/searchindex.js b/docs/build/html/searchindex.js new file mode 100644 index 0000000..ae78dc9 --- /dev/null +++ b/docs/build/html/searchindex.js @@ -0,0 +1 @@ +Search.setIndex({envversion:42,terms:{represent:1,all:[1,0],code:1,entri:1,zone_bypass:1,text:1,sent:1,recogn:1,arm:1,ssl_kei:1,socketdevic:1,through:1,human:1,stage_don:1,data:1,find:1,backlight:1,paramet:1,raw:1,current:1,baudrat:1,locat:1,expos:1,also:0,readabl:1,except:1,identif:1,whether:1,add:0,program:1,serialdevic:1,bypass:1,on_read:1,match:1,sourc:[1,0],"return":1,string:1,serial_numb:1,format:1,read:1,numeric_cod:1,stop:1,ssl:1,lcd:1,lrr:1,progress:1,report:1,detach:1,requir:1,enabl:1,ad2:1,name:1,earg:0,list:1,upload:1,authent:1,factori:1,"try":1,provid:1,expand:1,stage_wait:1,mode:1,timeout:1,contain:1,found:1,alarm_event_occur:1,expandermessag:1,page:3,certif:1,nodeviceerror:1,on_open:1,request:1,"static":1,connect:1,usbdevic:1,on_writ:1,our:1,charact:1,read_lin:1,event:1,stop_read:1,pyseri:1,index:3,statu:1,detect:1,parent:1,purge_buff:1,pattern:1,ad2seri:1,callback:1,content:3,pyftdi:1,written:1,reader:1,"new":0,awai:1,method:1,localhost:1,ser2sock:1,process:1,perimet:1,run:1,timeouterror:1,kei:1,state:1,numer:1,gener:1,stage_load:1,cursor_loc:1,entry_delay_off:1,like:0,on_clos:1,base:[1,0],ssl_certif:1,address:1,path:1,"byte":1,armed_hom:1,valu:1,describ:1,fire_alarm:1,search:[1,3],actual:1,zone:1,thread:1,fault:1,readthread:1,stage_start:1,prior:1,rais:1,loop:1,fals:1,find_al:1,ad2usb:1,first:1,oper:0,rang:1,via:1,vid:1,appli:1,keypad:1,"float":1,number:1,automat:1,filenam:1,read_timeout:1,"long":1,famili:1,batteri:1,chime:1,open:1,on_attach:1,differ:1,from:1,usb:1,commun:1,detectthread:1,support:1,system:1,been:1,beep:1,attach:1,singl:1,handler:0,call:[1,0],on_detach:1,start_detect:1,ac_pow:1,interfac:1,stage_upload:1,type:1,start:1,low:1,"function":[1,0],no_reader_thread:1,fire:[1,0],tupl:1,commerror:1,chime_on:1,convert:1,specifi:1,stage_boot:1,rfmessag:1,flag:1,indic:1,relai:1,expander_to_zon:1,line:1,repres:1,cach:1,present:1,must:0,sound:1,none:[1,0],sender:0,retriev:1,on_restor:1,restor:1,"default":1,remov:[1,0],purg:1,displai:1,dev:1,stop_detect:1,cursor:1,defin:0,"while":1,kwarg:0,can:0,str:1,error:1,battery_low:1,alarm:1,radio:1,expir:1,backlight_on:1,"int":1,descript:1,arg:0,pid:1,templat:1,bitfield:1,check_zon:1,on_fault:1,itself:0,exist:0,aliv:1,ftdi_vendor_id:1,home:1,close:1,vendor:1,ftdi_product_id:1,alarm_sound:1,serial:1,delai:1,readi:1,panel_data:1,progress_callback:1,author:1,receiv:1,anoth:1,belong:1,when:1,invalid:1,port:1,write:1,field:1,client:1,bool:1,which:1,occur:1,instead:0,you:0,event_data:1,channel:1,updat:1,status:1,product:1,relat:1,intend:1,firmwar:1,supervis:1,buffer:1,expans:1,decod:1,event_typ:1,ftdi:1,partit:1,perimeter_onli:1,wire:1,power:1,user:1,attent:1,basemessag:1,eventhandl:0,associ:1,"class":[1,0],check:1,armed_awai:1,handl:1,classmethod:1,doc:0,clear:1,mask:1,object:[1,0],ssl_ca:1,issu:1,lrrmessag:1,is_reader_al:1,obj:0,thi:1,programming_mod:1,track:1,func:0,invalidmessageerror:1,usual:1},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:attribute","4":"py:classmethod","5":"py:exception","6":"py:staticmethod"},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","attribute","Python attribute"],"4":["py","classmethod","Python class method"],"5":["py","exception","Python exception"],"6":["py","staticmethod","Python static method"]},filenames:["alarmdecoder.event","alarmdecoder","modules","index"],titles:["event Package","alarmdecoder Package","alarmdecoder","Welcome to alarmdecoder’s documentation!"],objects:{"alarmdecoder.messages.LRRMessage":{partition:[1,3,1,""],event_data:[1,3,1,""],event_type:[1,3,1,""]},"alarmdecoder.messages.BaseMessage":{raw:[1,3,1,""]},"alarmdecoder.messages.ExpanderMessage":{RELAY:[1,3,1,""],ZONE:[1,3,1,""],value:[1,3,1,""],address:[1,3,1,""],type:[1,3,1,""],channel:[1,3,1,""]},"alarmdecoder.event.event":{EventHandler:[0,1,1,""],Event:[0,1,1,""]},"alarmdecoder.zonetracking.Zone":{STATUS:[1,3,1,""],FAULT:[1,3,1,""],CLEAR:[1,3,1,""],CHECK:[1,3,1,""]},"alarmdecoder.devices.SerialDevice":{write:[1,2,1,""],BAUDRATE:[1,3,1,""],read:[1,2,1,""],read_line:[1,2,1,""],find_all:[1,6,1,""],"interface":[1,3,1,""],close:[1,2,1,""],open:[1,2,1,""]},"alarmdecoder.zonetracking":{Zonetracker:[1,1,1,""],Zone:[1,1,1,""]},"alarmdecoder.zonetracking.Zonetracker":{on_restore:[1,3,1,""],EXPIRE:[1,3,1,""],expander_to_zone:[1,2,1,""],update:[1,2,1,""],on_fault:[1,3,1,""]},"alarmdecoder.devices.Device.ReadThread":{READ_TIMEOUT:[1,3,1,""],stop:[1,2,1,""],run:[1,2,1,""]},"alarmdecoder.event":{event:[0,0,1,""]},"alarmdecoder.messages":{Message:[1,1,1,""],LRRMessage:[1,1,1,""],RFMessage:[1,1,1,""],ExpanderMessage:[1,1,1,""],BaseMessage:[1,1,1,""]},"alarmdecoder.devices":{Device:[1,1,1,""],SocketDevice:[1,1,1,""],USBDevice:[1,1,1,""],SerialDevice:[1,1,1,""]},"alarmdecoder.devices.USBDevice.DetectThread":{run:[1,2,1,""],stop:[1,2,1,""],on_attached:[1,3,1,""],on_detached:[1,3,1,""]},alarmdecoder:{zonetracking:[1,0,1,""],messages:[1,0,1,""],devices:[1,0,1,""],util:[1,0,1,""],panels:[1,0,1,""],event:[0,0,1,""]},"alarmdecoder.devices.SocketDevice":{ssl_certificate:[1,3,1,""],ssl_key:[1,3,1,""],read:[1,2,1,""],ssl_ca:[1,3,1,""],read_line:[1,2,1,""],ssl:[1,3,1,""],write:[1,2,1,""],"interface":[1,3,1,""],close:[1,2,1,""],open:[1,2,1,""]},"alarmdecoder.devices.USBDevice":{write:[1,2,1,""],BAUDRATE:[1,3,1,""],description:[1,3,1,""],read:[1,2,1,""],DetectThread:[1,1,1,""],stop_detection:[1,4,1,""],devices:[1,4,1,""],start_detection:[1,4,1,""],read_line:[1,2,1,""],find_all:[1,4,1,""],FTDI_VENDOR_ID:[1,3,1,""],serial_number:[1,3,1,""],"interface":[1,3,1,""],close:[1,2,1,""],FTDI_PRODUCT_ID:[1,3,1,""],open:[1,2,1,""],find:[1,4,1,""]},"alarmdecoder.messages.Message":{backlight_on:[1,3,1,""],alarm_event_occurred:[1,3,1,""],programming_mode:[1,3,1,""],text:[1,3,1,""],bitfield:[1,3,1,""],armed_home:[1,3,1,""],alarm_sounding:[1,3,1,""],ready:[1,3,1,""],zone_bypassed:[1,3,1,""],panel_data:[1,3,1,""],check_zone:[1,3,1,""],numeric_code:[1,3,1,""],battery_low:[1,3,1,""],chime_on:[1,3,1,""],entry_delay_off:[1,3,1,""],perimeter_only:[1,3,1,""],fire_alarm:[1,3,1,""],ac_power:[1,3,1,""],beeps:[1,3,1,""],mask:[1,3,1,""],armed_away:[1,3,1,""],cursor_location:[1,3,1,""]},"alarmdecoder.devices.Device":{stop_reader:[1,2,1,""],on_open:[1,3,1,""],on_write:[1,3,1,""],ReadThread:[1,1,1,""],on_close:[1,3,1,""],on_read:[1,3,1,""],close:[1,2,1,""],is_reader_alive:[1,2,1,""],id:[1,3,1,""]},"alarmdecoder.messages.RFMessage":{battery:[1,3,1,""],value:[1,3,1,""],supervision:[1,3,1,""],serial_number:[1,3,1,""],x:[1,3,1,""],loop:[1,3,1,""]},"alarmdecoder.event.event.EventHandler":{fire:[0,2,1,""],add:[0,2,1,""],remove:[0,2,1,""]},"alarmdecoder.util.Firmware":{STAGE_LOAD:[1,3,1,""],upload:[1,6,1,""],STAGE_BOOT:[1,3,1,""],STAGE_START:[1,3,1,""],STAGE_UPLOADING:[1,3,1,""],STAGE_WAITING:[1,3,1,""],STAGE_DONE:[1,3,1,""]},"alarmdecoder.util":{CommError:[1,5,1,""],Firmware:[1,1,1,""],TimeoutError:[1,5,1,""],NoDeviceError:[1,5,1,""],InvalidMessageError:[1,5,1,""]}},titleterms:{subpackag:1,alarmdecod:[1,2,3],welcom:3,modul:[1,0],devic:1,zonetrack:1,util:1,packag:[1,0],messag:1,indic:3,tabl:3,document:3,event:0,panel:1}}) \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 5ad6bb4..e06150d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -64,7 +64,7 @@ release = '' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ['build'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None diff --git a/docs/make.bat b/docs/make.bat index d97cafa..c686d23 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -5,7 +5,7 @@ REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) -set BUILDDIR=_build +set BUILDDIR=build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" (