示例#1
0
 def __init__(self,
              hp=('', 0),
              mac='',
              root=None,
              name='',
              key=PK_KEY,
              password='',
              deviceid='',
              clientsessionid='',
              hp2=('', 0)):
     Device.__init__(self, hp, mac, root, name)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
     self.key = key
     self.fid = 0
     if len(clientsessionid) == 0:
         self.clientSessionId = generatestring(32)
     else:
         self.clientSessionId = clientsessionid
     if root is None:
         self.password = password
         self.deviceId = deviceid
         self.localPort = hp2[1]
         self.localIp = hp2[0]
     else:
         self.password = root.attributes['password'].value
         self.deviceId = root.attributes['deviceId'].value
         self.localPort = root.attributes['localPort'].value
         self.localIp = root.attributes['localIp'].value
示例#2
0
 def __init__(self, hp=('', 0), mac='', root=None, name='', conf=''):
     Device.__init__(self, hp, name, root, name)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
     self.remote = None
     self.last_init = 0
     self.fill_ir_list()
     if root is None:
         self.conffile = conf
     else:
         self.conffile = root.attributes['conffile'].value
     self.config = None
     self.offt = -1
     self.init_device()
示例#3
0
    def loadtables(fn, devn):
        out = dict()
        xmldoc = minidom.parse(fn)
        items = xmldoc.getElementsByTagName('device')
        outitem = None
        for item in items:
            nm = item.attributes['name'].value
            if nm == devn:
                outitem = item
                break
        if outitem is None:
            return out
        out['offafteron'] = None
        sub = outitem.getElementsByTagName('offafteron')
        for s in sub:
            out['offafteron'] = int(s.childNodes[0].nodeValue)
            if out['offafteron'] == DeviceUDP.OFF_AFTER_ON_NONE:
                out['offafteron'] = None
            break

        out['timezone'] = None
        sub = outitem.getElementsByTagName('timezone')
        for s in sub:
            out['timezone'] = int(s.childNodes[0].nodeValue)
            if out['timezone'] == DeviceUDP.TIMEZONE_NONE:
                out['timezone'] = None
            break

        out['timers'] = ManTimerManager.timer_xml_device_node_parse(outitem)

        return out
示例#4
0
 def __init__(self,
              hp=('', 0),
              mac='',
              root=None,
              name='',
              location='',
              deviceobj=None):
     DeviceUpnp.__init__(self, hp, mac, root, name, location, deviceobj)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
     self.a = None
     if root is not None and root.hasAttribute('remote_name'):
         self.remote_name = root.attributes['remote_name'].value
         self.ir_load = True
     else:
         self.ir_load = False
         self.remote_name = self.name
     self.offt = -1
示例#5
0
 def __init__(self,
              hp=('', 0),
              mac='',
              root=None,
              timeout=DEFAULT_RESUBSCRIPTION_TIMEOUT,
              name='',
              sec1900=0,
              lsa_timeout=DEFAULT_RESUBSCRIPTION_STIMEOUT):
     DeviceUDP.__init__(self,
                        hp=hp,
                        mac=mac,
                        root=root,
                        timeout=timeout,
                        name=name,
                        sec1900=sec1900,
                        lsa_timeout=lsa_timeout)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
示例#6
0
    def xml_table_element(self, root, flag=0):
        el = self.xml_element(
            root, flag) if (flag & DEVICE_SAVE_FLAG_TABLE) and (
                flag & DEVICE_SAVE_FLAG_MAIN) else self.__xml_basic(root)
        tables_el = SubElement(el, "tables")
        tv = {} if self.tablever is None else self.tablever
        for tn, tinfo in tv.copy().items():
            table_el = SubElement(tables_el, "table", {"num": tn})
            v = SubElement(table_el, "version")
            v.text = str(tinfo['vern'])
            v = SubElement(table_el, "flag")
            v.text = str(tinfo['flgn'])

        offafteron = SubElement(el, 'offafteron')
        offafteron.text = str(DeviceUDP.OFF_AFTER_ON_NONE
                              ) if self.timer_off_after_on is None else str(
                                  self.timer_off_after_on)
        timezone = SubElement(el, 'timezone')
        timezone.text = str(
            DeviceUDP.TIMEZONE_NONE) if self.timezone is None else str(
                self.timezone)
        ManTimerManager.timer_xml_device_node_write(el, self.timers)
示例#7
0
 def to_json(self):
     rv = DeviceUpnp.to_json(self)
     rv.update(IrManager.to_json(self))
     rv.update(ManTimerManager.to_json(self))
     return rv
示例#8
0
 def on_stop(self):
     IrManager.on_stop(self)
     ManTimerManager.on_stop(self)
示例#9
0
 def xml_element(self, root, flag=0):
     el = IrManager.xml_element(self, root, flag)
     ManTimerManager.xml_element(self, el, flag)
     return el
示例#10
0
 def copy_extra_from(self, already_saved_device):
     DeviceUpnp.copy_extra_from(self, already_saved_device)
     IrManager.copy_extra_from(self, already_saved_device)
     ManTimerManager.copy_extra_from(self, already_saved_device)
     self.remote_name = already_saved_device.remote_name
示例#11
0
 def to_json(self):
     rv = IrManager.to_json(self)
     rv.update(ManTimerManager.to_json(self))
     return rv
示例#12
0
 def copy_extra_from(self, already_saved_device):
     savep = self.port
     IrManager.copy_extra_from(self, already_saved_device)
     ManTimerManager.copy_extra_from(self, already_saved_device)
     self.deviceId = already_saved_device.deviceId
     self.port = savep
示例#13
0
 def copy_extra_from(self, already_saved_device):
     DeviceUDP.copy_extra_from(self, already_saved_device)
     IrManager.copy_extra_from(self, already_saved_device)
     ManTimerManager.copy_extra_from(self, already_saved_device)
示例#14
0
 def do_presend_operations(self, action, actionexec):
     if isinstance(self, ManTimerManager):
         return ManTimerManager.do_presend_operations(
             self, action, actionexec)
     return 1
示例#15
0
 def __init__(self, hp=('', 0), mac='', root=None, name='', inner=None):
     Device.__init__(self, hp, mac, root, name)
     ManTimerManager.__init__(self, root)
     IrManager.__init__(self, hp, mac, root, name)
     self.offt = -1
     self.inner = inner