From f80a2d799ec6829c78f6ef69e5ae0d0f63bb0931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Ricart?= Date: Mon, 12 Mar 2018 00:02:05 +0100 Subject: [PATCH] fix parser error --- esp8266/main.py | 23 ++++++++++++++++------- esp8266/uConfigParser.py | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/esp8266/main.py b/esp8266/main.py index e0aa7d6..eeb35a5 100644 --- a/esp8266/main.py +++ b/esp8266/main.py @@ -26,18 +26,27 @@ while True: data = {option:config[section][option] for option in config_obj.options(section)} del data['url'] del data['method'] + print(data) try: if method == "GET": print('GET') - r = requests.get(url, data=data) + if data : + r = requests.get(url, data=data) + else: + r = requests.get(url) elif method == "POST": print('POST') - r = requests.post(url, data=data) + if data: + r = requests.post(url, data=data) + else: + r = requests.post(url) except: - pass - else: - print("close") - r.close() - print("closed") + print(url) + requests.get(url) + print("UNKNOWN ERROR") + continue + print("close") + r.close() + print("closed") pin_value = current_value collect() diff --git a/esp8266/uConfigParser.py b/esp8266/uConfigParser.py index c2cc80a..9f3e889 100644 --- a/esp8266/uConfigParser.py +++ b/esp8266/uConfigParser.py @@ -63,7 +63,7 @@ class ConfigParser: end_index = None else: end_index = block.index(end_flag[0]) - values = [value.split('=')[-1].strip() for value in block[start_index:end_index] if value] + values = [value.split('=',1)[-1].strip() for value in block[start_index:end_index] if value] if not values: values = None elif len(values) == 1: