def updateCmdCompleter(self, struct):
        indexOnlyList = {
            'host': ['get', 'details', 'summary'],
            'save': ['info']
        }
        hostCommand = 'host'
        subCommandList = ['info']
        sendCommand = 'send'

        try:
            structPtr = {}
            topLevelKeys = {}
            for key, val in struct.iteritems():
                structPtr[str(key)] = val
                topLevelKeys[str(key)] = None

            #Update the subCommandList
            for subcmd in subCommandList:
                self.completer.commands[hostCommand][subcmd] = None
                self.completer.commands[hostCommand][subcmd] = structPtr

            #Update the indexOnlyList
            for cmd, data in indexOnlyList.iteritems():
                for subcmd in data:
                    self.completer.commands[cmd][subcmd] = topLevelKeys

            #This is for updating the sendCommand key
            structPtr = {}
            for hostIndex, hostData in struct.iteritems():
                host = str(hostIndex)
                structPtr[host] = {}
                if hostData.has_key('deviceList'):
                    for device, deviceData in hostData['deviceList'].iteritems(
                    ):
                        structPtr[host][device] = {}
                        if deviceData.has_key('services'):
                            for service, serviceData in deviceData[
                                    'services'].iteritems():
                                structPtr[host][device][service] = {}
                                if serviceData.has_key('actions'):
                                    for action, actionData in serviceData[
                                            'actions'].iteritems():
                                        structPtr[host][device][service][
                                            action] = None
            self.completer.commands[hostCommand][sendCommand] = structPtr
        except Exception:
            xbmc.log(
                "Miranda: Error updating command completer structure; some command completion features might not work..."
            )
        return
Example #2
0
    def updateCmdCompleter(self,struct):
        indexOnlyList = {
                'host' : ['get','details','summary'],
                'save' : ['info']
        }
        hostCommand = 'host'
        subCommandList = ['info']
        sendCommand = 'send'

        try:
            structPtr = {}
            topLevelKeys = {}
            for key,val in struct.iteritems():
                structPtr[str(key)] = val
                topLevelKeys[str(key)] = None

            #Update the subCommandList
            for subcmd in subCommandList:
                self.completer.commands[hostCommand][subcmd] = None
                self.completer.commands[hostCommand][subcmd] = structPtr

            #Update the indexOnlyList
            for cmd,data in indexOnlyList.iteritems():
                for subcmd in data:
                    self.completer.commands[cmd][subcmd] = topLevelKeys

            #This is for updating the sendCommand key
            structPtr = {}
            for hostIndex,hostData in struct.iteritems():
                host = str(hostIndex)
                structPtr[host] = {}
                if hostData.has_key('deviceList'):
                    for device,deviceData in hostData['deviceList'].iteritems():
                        structPtr[host][device] = {}
                        if deviceData.has_key('services'):
                            for service,serviceData in deviceData['services'].iteritems():
                                structPtr[host][device][service] = {}
                                if serviceData.has_key('actions'):
                                    for action,actionData in serviceData['actions'].iteritems():
                                        structPtr[host][device][service][action] = None
            self.completer.commands[hostCommand][sendCommand] = structPtr
        except Exception:
            print "Error updating command completer structure; some command completion features might not work..."
        return
Example #3
0
def createIni(section, struct, config):
    config.add_section(section)

    for key, value in struct.iteritems():
        key = key.replace(' ', '_')

        if isinstance(value, (int, long, basestring)):
            config.set(section, key, str(value))
        else:
            try:
                config.set(section, key, ''.join(('0' + hex(val)[2:])[-2:] for val in value))
            except TypeError:
                pass

    return config