Controller
Basic Controllers
- controllers.utilities.NS = {'DVB-C': 4294901760, 'DVB-T': 4008574976}
Label:Namespace map
- controllers.utilities.NS_DVB_C = 4294901760
Namespace - DVB-C services
- controllers.utilities.NS_DVB_T = 4008574976
Namespace - DVB-T services
- controllers.utilities.NS_LOOKUP = {4008574976: 'DVB-T', 4294901760: 'DVB-C'}
Namespace:Label lookup map
- controllers.utilities.create_servicereference(*args, **kwargs)[source]
Generate a (Enigma2 style) service reference string representation.
- Parameters:
args[0] (
dict
) – Service Reference Parameter as dictservice_type (int) – Service Type
sid (int) – SID
tsid (int) – TSID
oid (int) – OID
ns (int) – Enigma2 Namespace
- controllers.utilities.get_config_attribute(path, root_obj, head=None)[source]
Determine attribute of root_obj to be accessed by path in a (somewhat) safe manner. This implementation will allow key and index based accessing too (e.g.
config.some_list[0]
orconfig.some_dict['some_key']
) The path value needs to start with head (default=’config’).- Args:
path: character string specifying which attribute is to be accessed root_obj: An object whose attributes are to be accessed. head: Value of the first portion of path
- Returns:
Attribute of root_obj
- Raises:
ValueError: If path is invalid. AttributeError: If attribute cannot be accessed
- controllers.utilities.lenient_decode(value, encoding=None)[source]
Decode an encoded string and convert it to an unicode string.
- Args:
value: input value encoding: string encoding, defaults to utf-8
- Returns:
(unicode) decoded value
>>> lenient_decode("Hallo") u'Hallo' >>> lenient_decode(u"Hallo") u'Hallo' >>> lenient_decode("HällöÜ") u'H\xe4ll\xf6\xdc'
- controllers.utilities.lenient_force_utf_8(value)[source]
- Args:
value: input value
- Returns:
(basestring) utf-8 encoded value
>>> isinstance(lenient_force_utf_8(''), basestring) True >>> lenient_force_utf_8(u"Hallo") 'Hallo' >>> lenient_force_utf_8("HällöÜ") 'H\xc3\xa4ll\xc3\xb6\xc3\x9c'
- controllers.utilities.parse_servicereference(serviceref)[source]
Parse a Enigma2 style service reference string representation.
- Parameters:
serviceref (string) – Enigma2 style service reference
>>> sref = '1:0:1:300:7:85:00c00000:0:0:0:' >>> result = parse_servicereference(sref) >>> result {'service_type': 1, 'oid': 133, 'tsid': 7, 'ns': 12582912, 'sid': 768} >>> sref_g = create_servicereference(**result) >>> sref_g '1:0:1:300:7:85:00c00000:0:0:0:' >>> sref_g2 = create_servicereference(result) >>> sref_g2 '1:0:1:300:7:85:00c00000:0:0:0:' >>> sref == sref_g True >>> sref2 = '1:64:A:0:0:0:0:0:0:0::SKY Sport' >>> result2 = parse_servicereference(sref2) >>> result2 {'service_type': 10, 'oid': 0, 'tsid': 0, 'ns': 0, 'sid': 0} >>> sref3 = '1:0:0:0:0:0:0:0:0:0:/media/hdd/movie/20170921 2055 - DASDING - DASDING Sprechstunde - .ts' >>> result3 = parse_servicereference(sref3) >>> result3 {'service_type': 0, 'oid': 0, 'tsid': 0, 'ns': 0, 'sid': 0}