Translations and more minor cleanups

This commit is contained in:
Ken Roberts 2017-06-01 15:35:57 -07:00
parent 80369c8b0b
commit 0fc49e3df1
5 changed files with 94 additions and 39 deletions

View File

@ -57,61 +57,113 @@ LF = chr(0x0A) # \n
PJLINK_PORT = 4352
TIMEOUT = 30.0
PJLINK_MAX_PACKET = 136
# NOTE: Change format to account for some commands are both class 1 and 2
# NOTE: Changed format to account for some commands are both class 1 and 2
PJLINK_VALID_CMD = {
'ACKN': {'version': ['2', ], # UDP Reply to 'SRCH'
'description': 'Acknowledge a PJLink SRCH command - returns MAC address.'},
'ACKN': {'version': ['2', ],
'description': translate('OpenLP.PJLinkConstants',
'Acknowledge a PJLink SRCH command - returns MAC address.')
},
'AVMT': {'version': ['1', ],
'description': 'Blank/unblank video and/or mute audio.'},
'description': translate('OpenLP.PJLinkConstants',
'Blank/unblank video and/or mute audio.')
},
'CLSS': {'version': ['1', ],
'description': 'Query projector PJLink class support.'},
'description': translate('OpenLP.PJLinkConstants',
'Query projector PJLink class support.')
},
'ERST': {'version': ['1', '2'],
'description': 'Query error status from projector. '
'Returns fan/lamp/temp/cover/filter/other error status.'},
'FILT': {'version': ['2', ], # Assume (!) time in hours
'description': 'Query number of hours on filter.'},
'description': translate('OpenLP.PJLinkConstants',
'Query error status from projector. '
'Returns fan/lamp/temp/cover/filter/other error status.')
},
'FILT': {'version': ['2', ],
'description': translate('OpenLP.PJLinkConstants',
'Query number of hours on filter.')
},
'FREZ': {'version': ['2', ],
'description': 'Freeze or unfreeze current image being projected.'},
'description': translate('OpenLP.PJLinkConstants',
'Freeze or unfreeze current image being projected.')
},
'INF1': {'version': ['1', ],
'description': 'Query projector manufacturer name.'},
'description': translate('OpenLP.PJLinkConstants',
'Query projector manufacturer name.')
},
'INF2': {'version': ['1', ],
'description': 'Query projector product name.'},
'description': translate('OpenLP.PJLinkConstants',
'Query projector product name.')
},
'INFO': {'version': ['1', ],
'description': 'Query projector for other information set by manufacturer.'},
'description': translate('OpenLP.PJLinkConstants',
'Query projector for other information set by manufacturer.')
},
'INNM': {'version': ['2', ],
'description': 'Query specified input source name'},
'description': translate('OpenLP.PJLinkConstants',
'Query specified input source name')
},
'INPT': {'version': ['1', ],
'description': 'Switch to specified video source.'},
'description': translate('OpenLP.PJLinkConstants',
'Switch to specified video source.')
},
'INST': {'version': ['1', ],
'description': 'Query available input sources.'},
'description': translate('OpenLP.PJLinkConstants',
'Query available input sources.')
},
'IRES': {'version:': ['2', ],
'description': 'Query current input resolution.'},
'description': translate('OpenLP.PJLinkConstants',
'Query current input resolution.')
},
'LAMP': {'version': ['1', ],
'description': 'Query lamp time and on/off status. Multiple lamps supported.'},
'description': translate('OpenLP.PJLinkConstants',
'Query lamp time and on/off status. Multiple lamps supported.')
},
'LKUP': {'version': ['2', ],
'description': 'UDP Status notify. Returns MAC address.'},
'description': translate('OpenLP.PJLinkConstants',
'UDP Status notify. Includes MAC address.')
},
'MVOL': {'version': ['2', ],
'description': 'Adjust microphone volume by 1 step.'},
'description': translate('OpenLP.PJLinkConstants',
'Adjust microphone volume by 1 step.')
},
'NAME': {'version': ['1', ],
'description': 'Query customer-set projector name.'},
'description': translate('OpenLP.PJLinkConstants',
'Query customer-set projector name.')
},
'PJLINK': {'version': ['1', ],
'description': 'Initial connection with authentication/no authentication request.'},
'description': translate('OpenLP.PJLinkConstants',
'Initial connection with authentication/no authentication request.')
},
'POWR': {'version': ['1', ],
'description': 'Turn lamp on or off/standby.'},
'description': translate('OpenLP.PJLinkConstants',
'Turn lamp on or off/standby.')
},
'RFIL': {'version': ['2', ],
'description': 'Query replacement air filter model number.'},
'description': translate('OpenLP.PJLinkConstants',
'Query replacement air filter model number.')
},
'RLMP': {'version': ['2', ],
'description': 'Query replacement lamp model number.'},
'description': translate('OpenLP.PJLinkConstants',
'Query replacement lamp model number.')
},
'RRES': {'version': ['2', ],
'description': 'Query recommended resolution.'},
'description': translate('OpenLP.PJLinkConstants',
'Query recommended resolution.')
},
'SNUM': {'version': ['2', ],
'description': 'Query projector serial number.'},
'description': translate('OpenLP.PJLinkConstants',
'Query projector serial number.')
},
'SRCH': {'version': ['2', ],
'description': 'UDP broadcast search request for available projectors.'},
'description': translate('OpenLP.PJLinkConstants',
'UDP broadcast search request for available projectors.')
},
'SVER': {'version': ['2', ],
'description': 'Query projector software version number.'},
'description': translate('OpenLP.PJLinkConstants',
'Query projector software version number.')
},
'SVOL': {'version': ['2', ],
'description': 'Adjust speaker volume by 1 step.'}
'description': translate('OpenLP.PJLinkConstants',
'Adjust speaker volume by 1 step.')
}
}
# Error and status codes

View File

@ -167,13 +167,14 @@ class Projector(CommonBase, Base):
"""
Return basic representation of Source table entry.
"""
return '< Projector(id="{data}", ip="{ip}", port="{port}", pin="{pin}", name="{name}", ' \
return '< Projector(id="{data}", ip="{ip}", port="{port}", mac_adx="{mac}", pin="{pin}", name="{name}", ' \
'location="{location}", notes="{notes}", pjlink_name="{pjlink_name}", ' \
'manufacturer="{manufacturer}", model="{model}", serial_no="{serial}", other="{other}", ' \
'sources="{sources}", source_list="{source_list}", model_filter="{mfilter}", ' \
'model_lamp="{mlamp}", sw_version="{sw_ver}") >'.format(data=self.id,
ip=self.ip,
port=self.port,
mac=self.mac_adx,
pin=self.pin,
name=self.name,
location=self.location,
@ -190,6 +191,7 @@ class Projector(CommonBase, Base):
sw_ver=self.sw_version)
ip = Column(String(100))
port = Column(String(8))
mac_adx = Column(String(18))
pin = Column(String(20))
name = Column(String(20))
location = Column(String(30))
@ -244,9 +246,9 @@ class ProjectorDB(Manager):
"""
def __init__(self, *args, **kwargs):
log.debug('ProjectorDB().__init__(args="{arg}", kwargs="{kwarg}")'.format(arg=args, kwarg=kwargs))
super(ProjectorDB, self).__init__(plugin_name='projector',
init_schema=self.init_schema,
upgrade_mod=upgrade)
super().__init__(plugin_name='projector',
init_schema=self.init_schema,
upgrade_mod=upgrade)
log.debug('ProjectorDB() Initialized using db url {db}'.format(db=self.db_url))
log.debug('Session: {session}'.format(session=self.session))

View File

@ -65,6 +65,7 @@ def upgrade_2(session, metadata):
new_op = get_upgrade_op(session)
if 'serial_no' not in [t.name for t in metadata.tables.values()]:
log.debug("Upgrading projector DB to version '2'")
new_op.add_column('projector', Column('mac_adx', types.String(18), server_default=null()))
new_op.add_column('projector', Column('serial_no', types.String(30), server_default=null()))
new_op.add_column('projector', Column('sw_version', types.String(30), server_default=null()))
new_op.add_column('projector', Column('model_filter', types.String(30), server_default=null()))

View File

@ -29,7 +29,7 @@ class TestProjectorConstants(TestCase):
"""
Test specific functions in the projector constants module.
"""
def build_pjlink_video_label_test(self):
def test_build_pjlink_video_label(self):
"""
Test building PJLINK_DEFAULT_CODES dictionary
"""

View File

@ -306,10 +306,10 @@ class TestProjectorDB(TestCase):
# THEN: __repr__ should return a proper string
self.assertEqual(str(projector),
'< Projector(id="0", ip="127.0.0.1", port="4352", pin="None", name="Test One", '
'location="Somewhere over the rainbow", notes="Not again", pjlink_name="TEST", '
'manufacturer="IN YOUR DREAMS", model="OpenLP", serial_no="None", other="None", '
'sources="None", source_list="[]", model_filter="None", model_lamp="None", '
'< Projector(id="0", ip="127.0.0.1", port="4352", mac_adx="None", pin="None", '
'name="Test One", location="Somewhere over the rainbow", notes="Not again", '
'pjlink_name="TEST", manufacturer="IN YOUR DREAMS", model="OpenLP", serial_no="None", '
'other="None", sources="None", source_list="[]", model_filter="None", model_lamp="None", '
'sw_version="None") >',
'Projector.__repr__() should have returned a proper representation string')