Ejemplo n.º 1
0
    def testOrangeDatasets(self):
        events = [EEvent(x) for x in self.raw['orange']]
        self.assertEqual(8, len(events))
        self.assertNotEqual(None, events[4].pseudo_id)

        for item in events:
            psr = parse_servicereference(item.service_reference)
            self.assertFalse((psr['service_type'] == SERVICE_TYPE_RADIO))
Ejemplo n.º 2
0
 def testGOTDatasets(self):
     events = [EEvent(x) for x in self.raw['got']]
     self.assertEqual(4, len(events))
     self.assertNotEqual(None, events[0].pseudo_id)
     for item in events:
         self.assertEqual(pseudo_unique_id(item), item.pseudo_id)
         psr = parse_servicereference(item.service_reference)
         self.assertFalse((psr['service_type'] == SERVICE_TYPE_RADIO))
Ejemplo n.º 3
0
    def _update_lookup_map(self):
        if not self.args.filter_service_type:
            st = (SERVICE_TYPE_TV, SERVICE_TYPE_HDTV)
        else:
            st = self.args.filter_service_type

        if not self.args.filter_namespace:
            namespace = (NS_DVB_C, )
        else:
            namespace = self.args.filter_namespace

        filter_oid = None
        if self.args.filter_oid:
            filter_oid = []
            for item in self.args.filter_oid:
                if item.startswith('0x'):
                    item_i = int(item, 16)
                else:
                    item_i = int(item)
                filter_oid.append(item_i)

        self.log.debug("st={!r} namespace={!r} filter_oid={!r}".format(
            st, namespace, filter_oid))

        for servicename, servicereference in self.get_services():
            self.log.info("Evaluating bouquet {!r}".format(servicename))
            for res in self.get_getservices(servicereference):
                sref = res['servicereference']
                val = res['servicename']
                psref = parse_servicereference(sref)

                if psref.get('service_type') not in st:
                    self.log.debug('ignored(TYPE={!s}): {!r:40} / {!r}'.format(
                        psref.get('service_type'), val, sref))
                    continue

                self.log.debug("{:s}? {!r}".format(
                    normalise_servicereference(sref), val))

                if psref.get('ns') not in namespace:
                    self.log.debug('ignored(NS): {!r:40} / {!r}'.format(
                        val, sref))
                    continue

                if filter_oid:
                    if psref.get('oid') not in filter_oid:
                        self.log.debug('ignored(oid): {!r:40} / {!r}'.format(
                            val, sref))
                        continue

                self.lookup_map[sref] = res

        for key in sorted(self.lookup_map.keys(),
                          key=lambda x: normalise_servicereference(x)):
            self.log.debug("{:s}> {!r}".format(normalise_servicereference(key),
                                               self.lookup_map[key]))
Ejemplo n.º 4
0
    def testMusikstundeDatasets(self):
        events = [EEvent(x) for x in self.raw['musikstunde']]
        self.assertEqual(24, len(events))
        self.assertNotEqual(None, events[0].pseudo_id)

        for item in events:
            psr = parse_servicereference(item.service_reference)
            self.assertTrue((psr['service_type'] == SERVICE_TYPE_RADIO))

        self.assertEqual(pseudo_unique_id_any(events[0]), events[0].pseudo_id)
Ejemplo n.º 5
0
    def zap(self, what):
        zap_to = None

        if not self.lookup_map:
            self._update_lookup_map()

        for sref in self.lookup_map:
            if what == self.lookup_map[sref]:
                zap_to = sref
                break

        if zap_to is None:
            zap_to = what

        self.log.info("Zapping to {!r} ({!r})".format(what, zap_to))

        try:
            parse_servicereference(zap_to)
        except Exception, pexc:
            self.log.error("Invalid service reference! {!r}".format(pexc))
            return False
Ejemplo n.º 6
0
 def list(self):
     for key in self._sorted():
         item = self.lookup_map[key]
         sref = parse_servicereference(item['servicereference'])
         self.log.debug("{:s}> {!r}".format(normalise_servicereference(key),
                                            self.lookup_map[key]))
         print '0x{oid:04X} {service_type:5s} {namespace:5s} {servicename:50s} {sref}'.format(
             oid=sref['oid'],
             service_type=SERVICE_TYPE_LOOKUP[sref['service_type']],
             namespace=NS_LOOKUP[sref['ns']],
             servicename=item['servicename'].encode('utf-8'),
             sref=item['servicereference'])
Ejemplo n.º 7
0
    def dump(self):
        data = {
            "created":
            datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"),
            "services": dict()
        }

        for key in self._sorted():
            item = self.lookup_map[key]
            sref = parse_servicereference(item['servicereference'])
            item_key = create_servicereference(sref)
            data['services'][item_key] = item

        with open(self.args.dump_file, "wb") as tgt:
            json.dump(data, tgt, indent=2)
Ejemplo n.º 8
0
    def testSprechstundeDatasets(self):
        events = [EEvent(x) for x in self.raw['sprechstunde']]
        self.assertEqual(4, len(events))
        self.assertNotEqual(None, events[0].pseudo_id)

        for item in events:
            psr = parse_servicereference(item.service_reference)
            self.assertTrue((psr['service_type'] == SERVICE_TYPE_RADIO))

        self.assertEqual('38d97fdaad3c1d2c495ff0135869eb1aabdab336',
                         events[0].pseudo_id)
        self.assertEqual('dedd36e94f4a8521a810e8438327de2d8357e720',
                         events[1].pseudo_id)
        self.assertEqual('fbc5da506f991ac6c96fea98a8e923dfb10b83d1',
                         events[2].pseudo_id)
        self.assertEqual('47a1be2837d5cce375c544824322f2c07bdd8c2c',
                         events[3].pseudo_id)
Ejemplo n.º 9
0
    def _update_lookup_map(self):
        st = (SERVICE_TYPE_TV, SERVICE_TYPE_HDTV)

        for servicename, servicereference in self.get_services():
            self.log.debug("Evaluating bouquet {!r}".format(servicename))
            for res in self.get_getservices(servicereference):
                sref = res['servicereference']
                val = res['servicename']
                psref = parse_servicereference(sref)

                self.log.debug("{:s}? {!r}".format(
                    normalise_servicereference(sref), val))

                self.lookup_map[sref] = val

        for key in sorted(self.lookup_map.keys(),
                          key=lambda x: normalise_servicereference(x)):
            self.log.debug("{:s}> {!r}".format(normalise_servicereference(key),
                                               self.lookup_map[key]))