Moved Docker stuff to "Docker" folder
Created k8s folder for k8s stuff Added early-stage service.yaml for K8s deployment
This commit is contained in:
10
Docker/src/python/tHome/util/hex/__init__.py
Normal file
10
Docker/src/python/tHome/util/hex/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
#=============================================================================
|
||||
#
|
||||
# Hex string/byte utilities
|
||||
#
|
||||
#=============================================================================
|
||||
|
||||
from .dump import dump
|
||||
from .toBytes import toBytes
|
||||
|
||||
#=============================================================================
|
||||
32
Docker/src/python/tHome/util/hex/dump.py
Normal file
32
Docker/src/python/tHome/util/hex/dump.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#===========================================================================
|
||||
#
|
||||
# Dump hex bytes to a table.
|
||||
#
|
||||
#===========================================================================
|
||||
import StringIO
|
||||
|
||||
#===========================================================================
|
||||
def dump( buf ):
|
||||
"""Input is bytes buffer,
|
||||
|
||||
Returns a string w/ the hex values in a table
|
||||
"""
|
||||
# Convert to hex characters
|
||||
h = [ i.encode( "hex" ).upper() for i in buf ]
|
||||
|
||||
f = StringIO.StringIO()
|
||||
f.write( "---: 00 01 02 03 04 05 06 07 08 09\n" )
|
||||
|
||||
for i in range( len( h ) ):
|
||||
if i % 10 == 0:
|
||||
if i > 0:
|
||||
f.write( "\n" )
|
||||
f.write( "%03d: " % i )
|
||||
|
||||
f.write( "%2s " % h[i] )
|
||||
|
||||
f.write( "\n" )
|
||||
|
||||
return f.getvalue()
|
||||
|
||||
#===========================================================================
|
||||
23
Docker/src/python/tHome/util/hex/toBytes.py
Normal file
23
Docker/src/python/tHome/util/hex/toBytes.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#===========================================================================
|
||||
#
|
||||
# Convert a hex string to bytes
|
||||
#
|
||||
#===========================================================================
|
||||
import math
|
||||
|
||||
#===========================================================================
|
||||
def toBytes( hexStr ):
|
||||
"""Input is a string containing hex values (w/ or w/o spaces)
|
||||
|
||||
Return is the same value in a bytes array.
|
||||
"""
|
||||
s = hexStr.strip().replace( "\n", " " )
|
||||
s = ''.join( s.split(" ") )
|
||||
|
||||
bytes = []
|
||||
for i in range( 0, len( s ), 2 ):
|
||||
bytes.append( chr( int( s[i:i+2], 16 ) ) )
|
||||
|
||||
return ''.join( bytes )
|
||||
|
||||
#===========================================================================
|
||||
Reference in New Issue
Block a user