From a0b141adc600db237dc220010e5b062a5ad8294b Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Sat, 15 Sep 2012 11:01:30 +0100 Subject: [PATCH] Updated htspmon debug script to receive EPG info. --- lib/py/tvh/htsp.py | 13 ++++++------- support/htspmon | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/py/tvh/htsp.py b/lib/py/tvh/htsp.py index e023e771..6ef4c83d 100644 --- a/lib/py/tvh/htsp.py +++ b/lib/py/tvh/htsp.py @@ -29,7 +29,7 @@ import log # HTSP Client # ########################################################################### -HTSP_PROTO_VERSION = 5 +HTSP_PROTO_VERSION = 6 # Create passwd digest def htsp_digest ( user, passwd, chal ): @@ -76,10 +76,9 @@ class HTSPClient: self.send('hello', args) resp = self.recv() - # Validate - if resp['htspversion'] != HTSP_PROTO_VERSION: - raise Exception('version mismatch') - self._auth = resp['challenge'] + # Store + self._version = min(HTSP_PROTO_VERSION, resp['htspversion']) + self._auth = resp['challenge'] # Return response return resp @@ -95,8 +94,8 @@ class HTSPClient: raise Exception('Authentication failed') # Enable async receive - def enableAsyncMetadata ( self ): - self.send('enableAsyncMetadata') + def enableAsyncMetadata ( self, args = {} ): + self.send('enableAsyncMetadata', args) # ############################################################################ # Editor Configuration diff --git a/support/htspmon b/support/htspmon index 426a8bc7..dd4380c2 100755 --- a/support/htspmon +++ b/support/htspmon @@ -25,7 +25,6 @@ from optparse import OptionParser # System path sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'lib', 'py')) import tvh -print sys.path # TVH imports from tvh.htsp import HTSPClient @@ -35,7 +34,7 @@ try: # Command line optp = OptionParser() - optp.add_option('-t', '--host', default='localhost', + optp.add_option('-a', '--host', default='localhost', help='Specify HTSP server hostname') optp.add_option('-o', '--port', default=9982, type='int', help='Specify HTSP server port') @@ -43,12 +42,17 @@ try: help='Specify HTSP authentication username') optp.add_option('-p', '--passwd', default=None, help='Specify HTSP authentication password') + optp.add_option('-e', '--epg', default=False, action='store_true', + help='Get async EPG updates') + optp.add_option('-t', '--update', default=None, type='int', + help='Specify when to receive updates from') (opts, args) = optp.parse_args() # Connect htsp = HTSPClient((opts.host, opts.port)) msg = htsp.hello() log.info('connected to %s [%s]' % (msg['servername'], msg['serverversion'])) + log.info('using protocol v%d' % htsp._version) # Authenticate if opts.user: @@ -56,7 +60,12 @@ try: log.info('authenticated as %s' % opts.user) # Enable async - htsp.enableAsyncMetadata() + args = {} + if opts.epg: + args['epg'] = 1 + if opts.update != None: + args['lastUpdate'] = opts.update + htsp.enableAsyncMetadata(args) log.info('enabled async data') # Process messages