Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3 fixes next #1

Merged
merged 4 commits into from Jun 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 11 additions & 13 deletions lcd/emonPiLCD.py
Expand Up @@ -47,7 +47,7 @@
# ------------------------------------------------------------------------------------
redis_host = config.get('redis', 'redis_host')
redis_port = config.get('redis', 'redis_port')
r = redis.Redis(host=redis_host, port=redis_port, db=0)
r = redis.Redis(host=redis_host, port=redis_port, db=0, charset="utf-8", decode_responses=True)

# ------------------------------------------------------------------------------------
# General Settings
Expand Down Expand Up @@ -278,7 +278,7 @@ def updateLCD():

elif page == 7:
lcd[0] = "emonPi Build:"
lcd[1] = sd_image_version
lcd[1] = sd_image_version.decode()

elif page == 8:
ret = subprocess.call(ssh_status, shell=True)
Expand Down Expand Up @@ -313,7 +313,7 @@ def get_ip_address(self, ifname):
return socket.inet_ntoa(fcntl.ioctl(
self.sock.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
struct.pack('256s', ifname[:15].encode())
)[20:24])
except Exception:
return ''
Expand Down Expand Up @@ -345,21 +345,19 @@ def __init__(self, logger):
self.logger = logger
for i2c_address in lcd_i2c:
lcd_status = subprocess.check_output([path+"/emonPiLCD_detect.sh", "%s" % i2c_address])
if lcd_status.rstrip() == 'True':
if lcd_status.rstrip().decode() == 'True':
print("I2C LCD DETECTED Ox%s" % i2c_address)
logger.info("I2C LCD DETECTED 0x%s" % i2c_address)
current_lcd_i2c = "0x%s" % i2c_address
# add file to identify device as emonpi
if os.path.isdir('/home/pi/data/'):
open('/home/pi/data/emonpi', 'a').close()
# identify device as emonpi
r.set("describe", "emonpi")
break

if lcd_status.rstrip() == 'False':
if lcd_status.rstrip().decode() == 'False':
print("I2C LCD NOT DETECTED on either 0x" + str(lcd_i2c) + " ...exiting LCD script")
logger.error("I2C LCD NOT DETECTED on either 0x" + str(lcd_i2c) + " ...exiting LCD script")
# add file to identify device as emonbase
if os.path.isdir('/home/pi/data/'):
open('/home/pi/data/emonbase', 'a').close()
# identify device as emonbase
r.set("describe", "emonbase")
sys.exit(0)

# Init LCD using detected I2C address with 16 characters
Expand Down Expand Up @@ -439,8 +437,8 @@ def main():
sd_image_version = sd_image_version.rstrip()

lcd[0] = "emonPi Build:"
lcd[1] = sd_image_version
logger.info("SD card image build version: " + sd_image_version)
lcd[1] = sd_image_version.decode('utf-8')
logger.info("SD card image build version: %s", sd_image_version)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff.


# Set up the buttons and install handlers

Expand Down