]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
htspmon: python3 fixes
authorJaroslav Kysela <perex@perex.cz>
Mon, 1 Oct 2018 15:54:24 +0000 (17:54 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 2 Oct 2018 14:09:20 +0000 (16:09 +0200)
lib/py/tvh/htsmsg.py
lib/py/tvh/htsp.py
support/htspmon

index 8fe85d6504f0f9c68ddeefa7db84a2d880a07c2c..f74e6ef00bd3039be44912fa7965be9338564f96 100644 (file)
@@ -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))
index d1898d4d61292ac0fc4c0c0d3e336dda7dc108b0..bab234beafc924a608e830d32cc4596152df0863 100644 (file)
@@ -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
index 430827e1ffd8d54ed2103fd5cc52a632f159b173..9ce6048c613e21a5635e24329718e1e16d5c36ee 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 #
 # Copyright (C) 2012 Adam Sutton <dev@adamsutton.me.uk>
 #
@@ -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) 
 
 # ############################################################################