From 28067700d05ca1b431a53fc471314b11c7d76f47 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Mon, 1 Oct 2018 17:54:24 +0200 Subject: [PATCH] htspmon: python3 fixes --- lib/py/tvh/htsmsg.py | 6 ++++-- lib/py/tvh/htsp.py | 4 ++-- support/htspmon | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/py/tvh/htsmsg.py b/lib/py/tvh/htsmsg.py index 8fe85d650..f74e6ef00 100644 --- a/lib/py/tvh/htsmsg.py +++ b/lib/py/tvh/htsmsg.py @@ -67,7 +67,7 @@ HMF_BOOL = 7 # Light wrapper for binary type -class HMFBin(str): +class HMFBin(bytes): pass @@ -135,8 +135,10 @@ def binary_write(msg): if type(f) in [list, dict]: ret = ret + binary_write(f) - elif type(f) in [str, HMFBin]: + elif type(f) in [str]: ret = ret + f.encode() + elif type(f) in [HMFBin]: + ret = ret + f elif type(f) == int: while f: ret = ret + struct.pack("B", (f & 0xFF)) diff --git a/lib/py/tvh/htsp.py b/lib/py/tvh/htsp.py index d1898d4d6..bab234bea 100644 --- a/lib/py/tvh/htsp.py +++ b/lib/py/tvh/htsp.py @@ -35,8 +35,8 @@ HTSP_PROTO_VERSION = 33 # Create passwd digest def htsp_digest(user, passwd, chal): import hashlib - ret = hashlib.sha1(passwd + chal).digest() - return ret + salted = passwd.encode('utf-8') + chal + return hashlib.sha1(salted).digest() # Client object diff --git a/support/htspmon b/support/htspmon index 430827e1f..9ce6048c6 100755 --- a/support/htspmon +++ b/support/htspmon @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 # # Copyright (C) 2012 Adam Sutton # @@ -19,7 +19,7 @@ Connect to a HTSP server and monitor the asynchronous traffic """ # System imports -import os, sys, pprint +import os, sys, pprint, traceback from optparse import OptionParser # System path @@ -81,6 +81,7 @@ try: except KeyboardInterrupt: pass except Exception as e: log.error(e) + traceback.print_exc() sys.exit(1) # ############################################################################ -- 2.47.3