Update code style

This commit is contained in:
Jordan
2021-09-11 17:25:38 -04:00
parent 98cb3ef743
commit 70d8315539
35 changed files with 735 additions and 736 deletions

View File

@@ -62,10 +62,10 @@ class KlippyGtk:
return (self.width - self.get_action_bar_width()) * self.keyboard_ratio
def Label(self, label, style=None):
l = Gtk.Label(label)
if style != None and style != False:
l.get_style_context().add_class(style)
return l
la = Gtk.Label(label)
if style is not None and style is not False:
la.get_style_context().add_class(style)
return la
def ImageLabel(self, image_name, text, size=20, style=False, width_scale=.32, height_scale=.32):
box1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=15)
@@ -80,7 +80,7 @@ class KlippyGtk:
box1.add(image)
box1.add(label)
if style != False:
if style is not False:
ctx = box1.get_style_context()
ctx.add_class(style)
@@ -94,31 +94,31 @@ class KlippyGtk:
return Gtk.Image.new_from_pixbuf(pixbuf)
def ImageFromFile(self, filename, style=False, width_scale=1, height_scale=1):
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename,
int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
filename, int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
return Gtk.Image.new_from_pixbuf(pixbuf)
def PixbufFromFile(self, filename, style=False, width_scale=1, height_scale=1):
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filename, int(round(self.img_width * width_scale)),
int(round(self.img_height * height_scale)), True)
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
filename, int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
return pixbuf
def PixbufFromHttp(self, resource, style=False, width_scale=1, height_scale=1):
response = self.screen.apiclient.get_thumbnail_stream(resource)
if response == False:
if response is False:
return None
stream = Gio.MemoryInputStream.new_from_data(response, None)
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(stream, int(round(self.img_width * width_scale)),
int(round(self.img_height * height_scale)), True)
pixbuf = GdkPixbuf.Pixbuf.new_from_stream_at_scale(
stream, int(round(self.img_width * width_scale)), int(round(self.img_height * height_scale)), True)
return pixbuf
def ProgressBar(self, style=False):
bar = Gtk.ProgressBar()
if style != False:
if style is not False:
ctx = bar.get_style_context()
ctx.add_class(style)
@@ -131,7 +131,7 @@ class KlippyGtk:
b.set_can_focus(False)
b.props.relief = Gtk.ReliefStyle.NONE
if style != None:
if style is not None:
b.get_style_context().add_class(style)
return b
@@ -168,10 +168,10 @@ class KlippyGtk:
child = b.get_children()[0].get_children()[0].get_children()[1]
child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
child.set_line_wrap(True)
except:
except Exception:
pass
if style != None:
if style is not None:
b.get_style_context().add_class(style)
return b
@@ -222,7 +222,6 @@ class KlippyGtk:
img = Gtk.Image.new_from_pixbuf(pixbuf)
b = Gtk.ToggleButton(label=label)
#b.props.relief = Gtk.RELIEF_NONE
b.set_image(img)
b.set_hexpand(True)
b.set_vexpand(True)
@@ -231,7 +230,7 @@ class KlippyGtk:
b.set_always_show_image(True)
b.props.relief = Gtk.ReliefStyle.NONE
if style != False:
if style is not False:
ctx = b.get_style_context()
ctx.add_class(style)
@@ -241,7 +240,7 @@ class KlippyGtk:
g = Gtk.Grid()
g.set_row_homogeneous(True)
g.set_column_homogeneous(True)
if width != None and height != None:
if width is not None and height is not None:
g.set_size_request(width, height)
return g

View File

@@ -13,7 +13,7 @@ class KlippyRest:
def get_oneshot_token(self):
r = self.send_request("access/oneshot_token")
if r == False:
if r is False:
return False
return r['result']
@@ -31,10 +31,10 @@ class KlippyRest:
def send_request(self, method):
url = "http://%s:%s/%s" % (self.ip, self.port, method)
logging.debug("Sending request to %s" % url)
headers = {} if self.api_key == False else {"x-api-key":self.api_key}
headers = {} if self.api_key is False else {"x-api-key": self.api_key}
try:
r = requests.get(url, headers=headers)
except:
except Exception:
return False
if r.status_code != 200:
return False
@@ -42,7 +42,7 @@ class KlippyRest:
# TODO: Try/except
try:
data = json.loads(r.content)
except:
except Exception:
logging.exception("Unable to parse response from moonraker:\n %s" % r.content)
return False

View File

@@ -14,9 +14,7 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib
from ks_includes.KlippyGcodes import KlippyGcodes
#f = open("/home/pi/.moonraker_api_key", "r")
api_key = "" #f.readline()
#f.close()
api_key = ""
api = {
"printer_info": {
@@ -48,33 +46,32 @@ class KlippyWebsocket(threading.Thread):
def initial_connect(self):
# Enable a timeout so that way if moonraker is not running, it will attempt to reconnect
if self.timeout == None:
if self.timeout is None:
self.timeout = GLib.timeout_add(500, self.reconnect)
self.connect()
def connect(self):
def ws_on_close(ws, a=None, b=None):
self.on_close(ws)
def ws_on_error(ws, msg):
self.on_error(ws, msg)
def ws_on_message(ws, msg):
self.on_message(ws, msg)
def ws_on_open(ws):
self.on_open(ws)
try:
token = self._screen.apiclient.get_oneshot_token()
except:
except Exception:
logging.debug("Unable to get oneshot token")
return False
self.ws_url = "ws://%s/websocket?token=%s" % (self._url, token)
self.ws = websocket.WebSocketApp(self.ws_url,
on_close = ws_on_close,
on_error = ws_on_error,
on_message = ws_on_message,
on_open = ws_on_open
)
self.ws = websocket.WebSocketApp(
self.ws_url, on_close=ws_on_close, on_error=ws_on_error, on_message=ws_on_message, on_open=ws_on_open)
self._wst = threading.Thread(target=self.ws.run_forever)
self._wst.daemon = True
@@ -115,11 +112,11 @@ class KlippyWebsocket(threading.Thread):
return
def send_method(self, method, params={}, callback=None, *args):
if self.is_connected() == False:
if self.is_connected() is False:
return False
self._req_id += 1
if callback != None:
if callback is not None:
self.callback_table[self._req_id] = [callback, method, params, [*args]]
data = {
@@ -135,7 +132,7 @@ class KlippyWebsocket(threading.Thread):
logging.info("Moonraker Websocket Open")
logging.info("Self.connected = %s" % self.is_connected())
self.connected = True
if self.timeout != None:
if self.timeout is not None:
GLib.source_remove(self.timeout)
self.timeout = None
if "on_connect" in self._callback:
@@ -145,18 +142,18 @@ class KlippyWebsocket(threading.Thread):
)
def on_close(self, ws):
if self.is_connected() == False:
if self.is_connected() is False:
logging.debug("Connection already closed")
return
if self.closing == True:
if self.closing is True:
logging.debug("Closing websocket")
self.ws.stop()
return
logging.info("Moonraker Websocket Closed")
self.connected = False
if self.timeout == None:
if self.timeout is None:
self.timeout = GLib.timeout_add(500, self.reconnect)
if "on_close" in self._callback:
@@ -207,7 +204,6 @@ class MoonrakerApi:
)
def get_file_list(self, callback=None, *args):
#Commenting this log for being too noisy
logging.debug("Sending server.files.list")
return self._ws.send_method(
"server.files.list",
@@ -217,7 +213,6 @@ class MoonrakerApi:
)
def get_file_metadata(self, filename, callback=None, *args):
#logging.debug("Sending server.files.metadata: %s", filename)
return self._ws.send_method(
"server.files.metadata",
{"filename": filename},
@@ -300,7 +295,8 @@ class MoonrakerApi:
*args
)
else:
logging.debug("Sending printer.gcode.script: %s",
logging.debug(
"Sending printer.gcode.script: %s",
KlippyGcodes.set_ext_temp(target, heater.replace("tool", "")))
# TODO: Add max/min limits
return self._ws.send_method(

View File

@@ -56,12 +56,12 @@ class KlipperScreenConfig:
self.log_config(self.defined_config)
self.config.read_string(user_def)
if saved_def != None:
if saved_def is not None:
self.config.read_string(saved_def)
logging.info("====== Saved Def ======\n%s\n=======================" % saved_def)
except KeyError:
raise ConfigError(f"Error reading config: {self.config_path}")
except:
except Exception:
logging.exception("Unknown error with config")
printers = sorted([i for i in self.config.sections() if i.startswith("printer ")])
@@ -92,7 +92,7 @@ class KlipperScreenConfig:
logging.debug("Configured printers: %s" % json.dumps(conf_printers_debug, indent=2))
lang = self.get_main_config_option("language", None)
lang = [lang] if lang != None and lang != "default" else None
lang = [lang] if lang is not None and lang != "default" else None
logging.info("Detected language: %s" % lang)
self.lang = gettext.translation('KlipperScreen', localedir='ks_includes/locales', languages=lang,
fallback=True)
@@ -111,35 +111,37 @@ class KlipperScreenConfig:
"callback": screen.restart_warning, "options": [
{"name": "System Default", "value": "system_lang"}
]}},
{"move_speed": {"section": "main", "name": _("Move Speed (mm/s)"), "type": "scale", "value": "20",
"range": [5,100], "step": 1
}},
{"move_speed": {
"section": "main", "name": _("Move Speed (mm/s)"), "type": "scale", "value": "20",
"range": [5, 100], "step": 1}},
{"print_sort_dir": {"section": "main", "type": None, "value": "name_asc"}},
{"print_estimate_method": {"section": "main", "name": _("Estimated Time Method"), "type": "dropdown",
{"print_estimate_method": {
"section": "main", "name": _("Estimated Time Method"), "type": "dropdown",
"value": "file", "options": [
{"name": _("File Estimation (default)"), "value": "file"},
{"name": _("Duration Only"), "value": "duration"},
{"name": _("Filament Used"), "value": "filament"},
{"name": _("Slicer"), "value": "slicer"}
]}},
{"screen_blanking": {"section": "main", "name": _("Screen Power Off Time"), "type": "dropdown",
{"name": _("Slicer"), "value": "slicer"}]}},
{"screen_blanking": {
"section": "main", "name": _("Screen Power Off Time"), "type": "dropdown",
"value": "3600", "callback": screen.set_screenblanking_timeout, "options": [
{"name": _("Off"), "value": "off"}
]}},
{"theme": {"section": "main", "name": _("Icon Theme"), "type": "dropdown",
{"name": _("Off"), "value": "off"}]
}},
{"theme": {
"section": "main", "name": _("Icon Theme"), "type": "dropdown",
"value": "z-bolt", "callback": screen.restart_warning, "options": [
{"name": _("Z-bolt (default)"), "value": "z-bolt"},
{"name": _("Colorized"), "value": "colorized"}
]}},
{"name": _("Colorized"), "value": "colorized"}]}},
{"24htime": {"section": "main", "name": _("24 Hour Time"), "type": "binary", "value": "True"}},
{"side_macro_shortcut": {"section": "main", "name": _("Macro shortcut on sidebar"), "type": "binary",
{"side_macro_shortcut": {
"section": "main", "name": _("Macro shortcut on sidebar"), "type": "binary",
"value": "True", "callback": screen.toggle_macro_shortcut}},
{"font_size": {"section": "main", "name": _("Font Size"), "type": "dropdown",
{"font_size": {
"section": "main", "name": _("Font Size"), "type": "dropdown",
"value": "medium", "callback": screen.restart_warning, "options": [
{"name": _("Small"), "value": "small"},
{"name": _("Medium (default)"), "value": "medium"},
{"name": _("Large"), "value": "large"},
]}},
{"name": _("Large"), "value": "large"}]}},
# {"": {"section": "main", "name": _(""), "type": ""}}
]
@@ -148,8 +150,8 @@ class KlipperScreenConfig:
langs.sort()
lang_opt = self.configurable_options[3]['language']['options']
for l in langs:
lang_opt.append({"name": l, "value": l})
for lang in langs:
lang_opt.append({"name": lang, "value": lang})
index = self.configurable_options.index(
[i for i in self.configurable_options if list(i)[0] == "screen_blanking"][0])
@@ -216,12 +218,12 @@ class KlipperScreenConfig:
found_saved = True
saved_def = []
continue
if found_saved == False:
if found_saved is False:
user_def.append(line.replace('\n', ''))
else:
if line.startswith(self.do_not_edit_prefix):
saved_def.append(line[(len(self.do_not_edit_prefix)+1):])
return ["\n".join(user_def), None if saved_def == None else "\n".join(saved_def)]
return ["\n".join(user_def), None if saved_def is None else "\n".join(saved_def)]
def get_config_file_location(self, file):
logging.info("Passed config file: %s" % file)
@@ -305,7 +307,7 @@ class KlipperScreenConfig:
opt = item[name]
curval = self.config[opt['section']].get(name)
if curval != opt["value"] or (
self.defined_config != None and opt['section'] in self.defined_config.sections() and
self.defined_config is not None and opt['section'] in self.defined_config.sections() and
self.defined_config[opt['section']].get(name, None) not in (None, curval)):
if opt['section'] not in save_config.sections():
save_config.add_section(opt['section'])
@@ -315,9 +317,9 @@ class KlipperScreenConfig:
for macro_sec in macro_sections:
for item in self.config.options(macro_sec):
value = self.config[macro_sec].getboolean(item, fallback=True)
if value == False or (self.defined_config != None and
if value is False or (self.defined_config is not None and
macro_sec in self.defined_config.sections() and
self.defined_config[macro_sec].getboolean(item, fallback=True) == False and
self.defined_config[macro_sec].getboolean(item, fallback=True) is False and
self.defined_config[macro_sec].getboolean(item, fallback=True) != value):
if macro_sec not in save_config.sections():
save_config.add_section(macro_sec)
@@ -333,9 +335,10 @@ class KlipperScreenConfig:
else:
user_def, saved_def = self.separate_saved_config(self.config_path)
extra_lb = "\n" if saved_def != None else ""
contents = "%s\n%s%s\n%s\n%s\n%s\n" % (user_def, self.do_not_edit_line, extra_lb,
self.do_not_edit_prefix, "\n".join(save_output), self.do_not_edit_prefix)
extra_lb = "\n" if saved_def is not None else ""
contents = "%s\n%s%s\n%s\n%s\n%s\n" % (
user_def, self.do_not_edit_line, extra_lb, self.do_not_edit_prefix, "\n".join(save_output),
self.do_not_edit_prefix)
if self.config_path != self.default_config_path:
path = self.config_path
@@ -350,7 +353,7 @@ class KlipperScreenConfig:
file = open(path, 'w')
file.write(contents)
file.close()
except:
except Exception:
logging.error("Error writing configuration file in %s" % path)
def set(self, section, name, value):
@@ -390,7 +393,7 @@ class KlipperScreenConfig:
try:
item["params"] = json.loads(cfg.get("params", "{}"))
except:
except Exception:
logging.debug("Unable to parse parameters for [%s]" % name)
item["params"] = {}

View File

@@ -77,14 +77,14 @@ class KlippyFiles():
for thumbnail in self.files[params['filename']]['thumbnails']:
thumbnail['local'] = False
if self.gcodes_path != None:
if self.gcodes_path is not None:
fpath = os.path.join(self.gcodes_path, params['filename'])
fdir = os.path.dirname(fpath)
path = os.path.join(fdir, thumbnail['relative_path'])
if os.access(path, os.R_OK):
thumbnail['local'] = True
thumbnail['path'] = path
if thumbnail['local'] == False:
if thumbnail['local'] is False:
fdir = os.path.dirname(params['filename'])
thumbnail['path'] = os.path.join(fdir, thumbnail['relative_path'])
self.run_callbacks(mods=[params['filename']])
@@ -107,13 +107,13 @@ class KlippyFiles():
"modified": item['modified']
}
self.request_metadata(filename)
if notify == True:
if notify is True:
self.run_callbacks(newfiles=[filename])
def add_file_callback(self, callback):
try:
self.callbacks.append(callback)
except:
except Exception:
logging.debug("Callback not found: %s" % callback)
def process_update(self, data):
@@ -150,7 +150,7 @@ class KlippyFiles():
return None
thumb = self.files[filename]['thumbnails'][0]
if thumb['local'] == False:
if thumb['local'] is False:
return ['http', thumb['path']]
return ['file', thumb['path']]
@@ -174,7 +174,7 @@ class KlippyFiles():
self.filelist.remove(filename)
self.files.pop(filename, None)
if notify == True:
if notify is True:
self.run_callbacks(deletedfiles=[filename])
def ret_file_data(self, filename):

View File

@@ -46,11 +46,11 @@ try:
libXext.XCloseDisplay(display)
return state
dpms_loaded = True
except:
except Exception:
pass
def get_network_interfaces():
stream = os.popen("ip addr | grep ^'[0-9]' | cut -d ' ' -f 2 | grep -o '[a-zA-Z0-9\.]*'")
stream = os.popen("ip addr | grep ^'[0-9]' | cut -d ' ' -f 2 | grep -o '[a-zA-Z0-9\\.]*'")
return [i for i in stream.read().strip().split('\n') if not i.startswith('lo')]
def get_wireless_interfaces():
@@ -64,12 +64,12 @@ def get_wireless_interfaces():
try:
p = subprocess.Popen(["iwconfig"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = p.stdout.read().decode('ascii').split('\n')
except:
except Exception:
logging.info("Error with running iwconfig command")
return None
interfaces = []
for line in result:
match = re.search('^(\S+)\s+.*$', line)
match = re.search('^(\\S+)\\s+.*$', line)
if match:
interfaces.append(match.group(1))
@@ -99,15 +99,17 @@ def patch_threading_excepthook():
Inspired by https://bugs.python.org/issue1230540
"""
old_init = threading.Thread.__init__
def new_init(self, *args, **kwargs):
old_init(self, *args, **kwargs)
old_run = self.run
def run_with_excepthook(*args, **kwargs):
try:
old_run(*args, **kwargs)
except (KeyboardInterrupt, SystemExit):
raise
except:
except Exception:
sys.excepthook(*sys.exc_info(), thread_identifier=threading.get_ident())
self.run = run_with_excepthook
threading.Thread.__init__ = new_init
@@ -160,7 +162,8 @@ def setup_logging(log_file, software_version):
listener.start()
def logging_exception_handler(type, value, tb, thread_identifier=None):
logging.exception("Uncaught exception %s: %s\nTraceback: %s" % (type, value, "\n".join(traceback.format_tb(tb))))
logging.exception(
"Uncaught exception %s: %s\nTraceback: %s" % (type, value, "\n".join(traceback.format_tb(tb))))
sys.excepthook = logging_exception_handler
logging.captureWarnings(True)

View File

@@ -141,7 +141,7 @@ class Printer:
logging.debug("Changing state from '%s' to '%s'" % (self.state, state))
prev_state = self.state
self.state = state
if self.state_callbacks[state] != None:
if self.state_callbacks[state] is not None:
logging.debug("Adding callback for state: %s" % state)
Gdk.threads_add_idle(
GLib.PRIORITY_HIGH_IDLE,
@@ -234,7 +234,7 @@ class Printer:
def get_stat(self, stat, substat=None):
if stat not in self.data:
return {}
if substat != None:
if substat is not None:
if substat in self.data[stat]:
return self.data[stat][substat]
return {}
@@ -246,7 +246,7 @@ class Printer:
def set_dev_temps(self, dev, temp, target=None):
if dev in self.devices:
self.devices[dev]['temperature'] = temp
if target != None:
if target is not None:
self.devices[dev]['target'] = target
def get_dev_stats(self, dev):

View File

@@ -24,7 +24,7 @@ class ScreenPanel:
self.layout = Gtk.Layout()
self.layout.set_size(self._screen.width, self._screen.height)
action_bar_width = self._gtk.get_action_bar_width() if action_bar == True else 0
action_bar_width = self._gtk.get_action_bar_width() if action_bar is True else 0
self.content = Gtk.Box(spacing=0)
def initialize(self, panel_name):
@@ -45,7 +45,7 @@ class ScreenPanel:
return None
loc = self._files.get_thumbnail_location(filename)
if loc == None:
if loc is None:
return None
if loc[0] == "file":
return self._gtk.PixbufFromFile(loc[1], None, width, height)
@@ -69,14 +69,13 @@ class ScreenPanel:
1, False)
def menu_return(self, widget, home=False):
if home == False:
if home is False:
self._screen._menu_go_back()
return
self._screen._menu_go_home()
def set_title(self, title):
self.title = title
#self.title.set_label(title)
def show_all(self):
self._screen.show_all()
@@ -87,7 +86,7 @@ class ScreenPanel:
def update_temp(self, dev, temp, target, name=None):
if dev in self.labels:
if name == None:
if name is None:
self.labels[dev].set_label(self._gtk.formatTemperatureString(temp, target))
else:
self.labels[dev].set_label("%s\n%s" % (name, self._gtk.formatTemperatureString(temp, target)))

View File

@@ -1,4 +1,5 @@
import os, signal
import os
import signal
import json
import logging
import re
@@ -57,7 +58,7 @@ class WifiManager():
self.soc = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
self.soc.bind(KS_SOCKET_FILE)
self.soc.connect("/var/run/wpa_supplicant/%s" % interface)
except:
except Exception:
logging.info("Error connecting to wifi socket: %s" % interface)
return
@@ -96,7 +97,7 @@ class WifiManager():
id = i
break
if id == None:
if id is None:
logging.info("Error adding network")
return False
@@ -118,7 +119,7 @@ class WifiManager():
id = netid
break
if id == None:
if id is None:
logging.info("Wifi network is not defined in wpa_supplicant")
return False
@@ -134,7 +135,7 @@ class WifiManager():
id = i
break
if id == None:
if id is None:
logging.debug("Unable to find network in wpa_supplicant")
return
self.wpa_cli("REMOVE_NETWORK %s" % id)
@@ -243,7 +244,7 @@ class WifiManager():
aps = []
for res in results:
match = re.match("^([a-f0-9:]+)\s+([0-9]+)\s+([\-0-9]+)\s+(\S+)\s+(.+)?", res)
match = re.match("^([a-f0-9:]+)\\s+([0-9]+)\\s+([\\-0-9]+)\\s+(\\S+)\\s+(.+)?", res)
if match:
net = {
"mac": match.group(1),
@@ -286,10 +287,10 @@ class WifiManager():
cb, new_networks, deleted_networks)
def wpa_cli(self, command, wait=True):
if wait == False:
if wait is False:
self.wpa_thread.skip_command()
self.soc.send(command.encode())
if wait == True:
if wait is True:
resp = self.queue.get()
return resp
@@ -311,10 +312,10 @@ class WpaSocket(Thread):
def run(self):
event = threading.Event()
logging.debug("Setting up wifi event loop")
while self._stop_loop == False:
while self._stop_loop is False:
try:
msg = self.soc.recv(4096).decode().strip()
except:
except Exception:
# TODO: Socket error
continue
if msg.startswith("<"):
@@ -322,7 +323,7 @@ class WpaSocket(Thread):
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT_IDLE, self.wm.scan_results)
elif "CTRL-EVENT-DISCONNECTED" in msg:
self.callback("connecting_status", msg)
match = re.match('<3>CTRL-EVENT-DISCONNECTED bssid=(\S+) reason=3 locally_generated=1', msg)
match = re.match('<3>CTRL-EVENT-DISCONNECTED bssid=(\\S+) reason=3 locally_generated=1', msg)
if match:
for net in self.wm.networks:
if self.wm.networks[net]['mac'] == match.group(1):
@@ -466,4 +467,4 @@ class WifiChannels:
return ("5", "192")
if freq == "4980":
return ("5", "196")
return None;
return None

View File

@@ -26,7 +26,7 @@ class BasePanel(ScreenPanel):
self.layout = Gtk.Layout()
self.layout.set_size(self._screen.width, self._screen.height)
action_bar_width = self._gtk.get_action_bar_width() if action_bar == True else 0
action_bar_width = self._gtk.get_action_bar_width() if action_bar is True else 0
self.control_grid = self._gtk.HomogeneousGrid()
self.control_grid.set_size_request(action_bar_width - 2, self._screen.height)
@@ -78,7 +78,7 @@ class BasePanel(ScreenPanel):
env.install_gettext_translations(self.lang)
j2_temp = env.from_string(title)
title = j2_temp.render()
except:
except Exception:
logging.debug("Error parsing jinja for title: %s" % title)
self.titlelbl = Gtk.Label()
@@ -91,7 +91,7 @@ class BasePanel(ScreenPanel):
self.content = Gtk.VBox(spacing=0)
self.content.set_size_request(self._screen.width - action_bar_width, self._screen.height - self.title_spacing)
if action_bar == True:
if action_bar is True:
self.layout.put(self.control_grid, 0, 0)
self.control['time_box'] = Gtk.Box()
@@ -158,7 +158,7 @@ class BasePanel(ScreenPanel):
self.content.add(panel.get_content())
def back(self, widget):
if self.current_panel == None:
if self.current_panel is None:
return
if self._screen.is_keyboard_showing():
@@ -174,7 +174,7 @@ class BasePanel(ScreenPanel):
return self.layout
def process_update(self, action, data):
if action != "notify_status_update" or self._printer == None:
if action != "notify_status_update" or self._printer is None:
return
if self._printer.has_heated_bed():
@@ -194,13 +194,13 @@ class BasePanel(ScreenPanel):
self.content.remove(widget)
def show_back(self, show=True):
if show == True and self.buttons_showing['back'] == False:
if show is True and self.buttons_showing['back'] is False:
self.control_grid.remove(self.control_grid.get_child_at(0, 0))
self.control_grid.attach(self.control['back'], 0, 0, 1, 1)
self.control_grid.remove(self.control_grid.get_child_at(0, 1))
self.control_grid.attach(self.control['home'], 0, 1, 1, 1)
self.buttons_showing['back'] = True
elif show == False and self.buttons_showing['back'] == True:
elif show is False and self.buttons_showing['back'] is True:
for i in range(0, 2):
self.control_grid.remove(self.control_grid.get_child_at(0, i))
self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1)
@@ -211,8 +211,8 @@ class BasePanel(ScreenPanel):
if show == "True":
show = True
if show == True and self.buttons_showing['macros_shortcut'] == False:
if len(self._config.get_printers()) > 1 and mod_row == True:
if show is True and self.buttons_showing['macros_shortcut'] is False:
if len(self._config.get_printers()) > 1 and mod_row is True:
self.control_grid.insert_row(self.locations['macro_shortcut'])
else:
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut']))
@@ -220,10 +220,10 @@ class BasePanel(ScreenPanel):
self.control_grid.remove(self.control['space%s' % self.locations['macro_shortcut']])
self.control_grid.attach(self.control['macro_shortcut'], 0, self.locations['macro_shortcut'], 1, 1)
self.buttons_showing['macros_shortcut'] = True
elif show != True and self.buttons_showing['macros_shortcut'] == True:
elif show is not True and self.buttons_showing['macros_shortcut'] is True:
if ('space%s' % self.locations['macro_shortcut']) not in self.control:
self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("")
if len(self._config.get_printers()) > 1 and mod_row == True:
if len(self._config.get_printers()) > 1 and mod_row is True:
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut']))
self.control_grid.remove(self.control['macro_shortcut'])
self.control_grid.remove_row(self.locations['macro_shortcut'])
@@ -242,7 +242,7 @@ class BasePanel(ScreenPanel):
env.install_gettext_translations(self.lang)
j2_temp = env.from_string(title)
title = j2_temp.render()
except:
except Exception:
logging.debug("Error parsing jinja for title: %s" % title)
self.titlelbl.set_label("%s | %s" % (self._screen.connected_printer, title))

View File

@@ -29,7 +29,7 @@ class BedLevelPanel(ScreenPanel):
elif "bed_screws" in self._screen.printer.get_config_section_list():
config_section_name = "bed_screws"
if config_section_name != None:
if config_section_name is not None:
config_section = self._screen.printer.get_config_section(config_section_name)
for item in config_section:
logging.debug("Screws section: %s" % config_section[item])
@@ -146,7 +146,8 @@ class BedLevelPanel(ScreenPanel):
def process_update(self, action, data):
if action == "notify_gcode_response":
result = re.match(
"^// (.*) : [xX= ]+([\-0-9\.]+), [yY= ]+([\-0-9\.]+), [zZ= ]+[\-0-9\.]+ : (Adjust ->|adjust) ([CW]+ [0-9:]+)",
"^// (.*) : [xX= ]+([\\-0-9\\.]+), [yY= ]+([\\-0-9\\.]+), [zZ= ]+[\\-0-9\\.]+ :" +
" (Adjust ->|adjust) ([CW]+ [0-9:]+)",
data
)
if result:

View File

@@ -74,12 +74,12 @@ class BedMeshPanel(ScreenPanel):
if profile != self.active_mesh:
if profile not in self.profiles:
self.add_profile(profile)
if self.active_mesh != None and self.active_mesh in self.profiles:
if self.active_mesh is not None and self.active_mesh in self.profiles:
a = self.profiles[self.active_mesh]
a['buttons'].remove(a['refresh'])
a['buttons'].pack_start(a['load'], False, False, 0)
self.active_mesh = profile
if self.active_mesh != None:
if self.active_mesh is not None:
a = self.profiles[profile]
a['buttons'].remove(a['load'])
a['buttons'].pack_start(a['refresh'], False, False, 0)
@@ -173,10 +173,10 @@ class BedMeshPanel(ScreenPanel):
"view": view,
}
l = list(self.profiles)
if "default" in l:
l.remove('default')
profiles = sorted(l)
pl = list(self.profiles)
if "default" in pl:
pl.remove('default')
profiles = sorted(pl)
pos = profiles.index(profile)+1 if profile != "default" else 0
self.labels['profiles'].insert_row(pos)
@@ -184,7 +184,7 @@ class BedMeshPanel(ScreenPanel):
self.labels['profiles'].show_all()
def back(self):
if self.show_create == True:
if self.show_create is True:
self.remove_create()
return True
return False
@@ -215,7 +215,7 @@ class BedMeshPanel(ScreenPanel):
self.activate_mesh(data['bed_mesh']['profile_name'])
def remove_create(self):
if self.show_create == False:
if self.show_create is False:
return
self._screen.remove_keyboard()
@@ -230,10 +230,10 @@ class BedMeshPanel(ScreenPanel):
if profile not in self.profiles:
return
l = list(self.profiles)
if "default" in l:
l.remove('default')
profiles = sorted(l)
pl = list(self.profiles)
if "default" in pl:
pl.remove('default')
profiles = sorted(pl)
pos = profiles.index(profile)+1 if profile != "default" else 0
self.labels['profiles'].remove_row(pos)
del self.profiles[profile]
@@ -271,8 +271,8 @@ class BedMeshPanel(ScreenPanel):
box.set_vexpand(False)
self.labels['create_profile'].add(box)
l = self._gtk.Label(_("Profile Name:"))
l.set_hexpand(False)
pl = self._gtk.Label(_("Profile Name:"))
pl.set_hexpand(False)
entry = Gtk.Entry()
entry.set_hexpand(True)
@@ -282,7 +282,7 @@ class BedMeshPanel(ScreenPanel):
self.labels['profile_name'] = entry
box.pack_start(l, False, False, 5)
box.pack_start(pl, False, False, 5)
box.pack_start(entry, True, True, 5)
box.pack_start(save, False, False, 5)
@@ -297,13 +297,13 @@ class BedMeshPanel(ScreenPanel):
_ = self.lang.gettext
bm = self._printer.get_config_section("bed_mesh %s" % profile)
if bm == False:
if bm is False:
logging.info("Unable to load profile: %s" % profile)
return
if profile == self.active_mesh:
abm = self._printer.get_stat("bed_mesh")
if abm == None:
if abm is None:
logging.info("Unable to load active mesh: %s" % profile)
return
x_range = [int(abm['mesh_min'][0]), int(abm['mesh_max'][0])]
@@ -319,7 +319,8 @@ class BedMeshPanel(ScreenPanel):
x_range = [int(bm['min_x']), int(bm['max_x'])]
y_range = [int(bm['min_y']), int(bm['max_y'])]
z_range = [min(min(bm['points'])), max(max(bm['points']))]
deltas = [(x_range[1] - x_range[0] )/ (int(bm['x_count'])-1), (y_range[1] - y_range[0]) / (int(bm['y_count'])-1)]
deltas = [(x_range[1] - x_range[0]) / (int(bm['x_count'])-1),
(y_range[1] - y_range[0]) / (int(bm['y_count'])-1)]
x = [(i*deltas[0])+x_range[0] for i in range(bm['x_count'])]
y = [(i*deltas[0])+y_range[0] for i in range(bm['y_count'])]
x, y = np.meshgrid(x, y)

View File

@@ -12,6 +12,7 @@ from ks_includes.screen_panel import ScreenPanel
def create_panel(*args):
return ConsolePanel(*args)
COLORS = {
"command": "#bad8ff",
"error": "#ff6975",
@@ -85,9 +86,11 @@ class ConsolePanel(ScreenPanel):
message = message.replace('\n', '\n ')
self.labels['tb'].insert_markup(self.labels['tb'].get_end_iter(),
self.labels['tb'].insert_markup(
self.labels['tb'].get_end_iter(),
'\n<span color="%s">%s</span> %s' % (COLORS['time'], datetime.fromtimestamp(time).strftime("%H:%M:%S"),
message), -1)
message), -1
)
def gcode_response(self, result, method, params):
if method != "server.gcode_store":

View File

@@ -57,16 +57,16 @@ class ExtrudePanel(ScreenPanel):
distgrid = Gtk.Grid()
j = 0;
j = 0
for i in self.distances:
self.labels["dist"+str(i)] = self._gtk.ToggleButton(i)
self.labels["dist"+str(i)].connect("clicked", self.change_distance, i)
ctx = self.labels["dist"+str(i)].get_style_context()
if ((self._screen.lang_ltr == True and j == 0) or
(self._screen.lang_ltr == False and j == len(self.distances)-1)):
if ((self._screen.lang_ltr is True and j == 0) or
(self._screen.lang_ltr is False and j == len(self.distances)-1)):
ctx.add_class("distbutton_top")
elif ((self._screen.lang_ltr == False and j == 0) or
(self._screen.lang_ltr == True and j == len(self.distances)-1)):
elif ((self._screen.lang_ltr is False and j == 0) or
(self._screen.lang_ltr is True and j == len(self.distances)-1)):
ctx.add_class("distbutton_bottom")
else:
ctx.add_class("distbutton")
@@ -77,16 +77,16 @@ class ExtrudePanel(ScreenPanel):
self.labels["dist1"].set_active(True)
speedgrid = Gtk.Grid()
j = 0;
j = 0
for i in self.speeds:
self.labels["speed"+str(i)] = self._gtk.ToggleButton(_(i))
self.labels["speed"+str(i)].connect("clicked", self.change_speed, i)
ctx = self.labels["speed"+str(i)].get_style_context()
if ((self._screen.lang_ltr == True and j == 0) or
(self._screen.lang_ltr == False and j == len(self.speeds)-1)):
if ((self._screen.lang_ltr is True and j == 0) or
(self._screen.lang_ltr is False and j == len(self.speeds)-1)):
ctx.add_class("distbutton_top")
elif ((self._screen.lang_ltr == False and j == 0) or
(self._screen.lang_ltr == True and j == len(self.speeds)-1)):
elif ((self._screen.lang_ltr is False and j == 0) or
(self._screen.lang_ltr is True and j == len(self.speeds)-1)):
ctx.add_class("distbutton_bottom")
else:
ctx.add_class("distbutton")
@@ -110,7 +110,8 @@ class ExtrudePanel(ScreenPanel):
return
for x in self._printer.get_tools():
self.update_temp(x,
self.update_temp(
x,
self._printer.get_dev_stat(x, "temperature"),
self._printer.get_dev_stat(x, "target")
)

View File

@@ -10,6 +10,7 @@ from ks_includes.screen_panel import ScreenPanel
def create_panel(*args):
return FanPanel(*args)
CHANGEABLE_FANS = ["fan", "fan_generic"]
class FanPanel(ScreenPanel):
@@ -50,7 +51,7 @@ class FanPanel(ScreenPanel):
def update_fan_speed(self, fan, speed):
if fan not in self.devices:
return
if self.devices[fan]['changeable'] == True:
if self.devices[fan]['changeable'] is True:
if self.devices[fan]['scale'].has_grab():
return
self.fan_speed[fan] = round(float(speed) * 100)
@@ -92,7 +93,7 @@ class FanPanel(ScreenPanel):
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
adj = Gtk.Adjustment(0, 0, 100, 1, 5, 0)
if changeable == True:
if changeable is True:
self.fan_speed[fan] = round(self.fan_speed[fan] * 100)
scale = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=adj)
scale.set_value(self.fan_speed[fan])

View File

@@ -77,7 +77,7 @@ class FineTunePanel(ScreenPanel):
# babystepping grid
bsgrid = Gtk.Grid()
j = 0;
j = 0
for i in self.bs_deltas:
self.labels[i] = self._gtk.ToggleButton(i)
self.labels[i].connect("clicked", self.change_bs_delta, i)
@@ -96,7 +96,7 @@ class FineTunePanel(ScreenPanel):
# Grid for percentage
deltgrid = Gtk.Grid()
j = 0;
j = 0
for i in self.percent_deltas:
self.labels[i] = self._gtk.ToggleButton("%s%%" % i)
self.labels[i].connect("clicked", self.change_percent_delta, i)

View File

@@ -60,9 +60,9 @@ class JobStatusPanel(ScreenPanel):
self.labels['lcdmessage'].set_ellipsize(True)
self.labels['lcdmessage'].set_ellipsize(Pango.EllipsizeMode.END)
fi_box.add(self.labels['file']) #, True, True, 0)
fi_box.add(self.labels['status']) #, True, True, 0)
fi_box.add(self.labels['lcdmessage']) #, True, True, 0)
fi_box.add(self.labels['file'])
fi_box.add(self.labels['status'])
fi_box.add(self.labels['lcdmessage'])
fi_box.set_valign(Gtk.Align.CENTER)
info = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
@@ -237,7 +237,7 @@ class JobStatusPanel(ScreenPanel):
self.show_buttons_for_state()
if self.timeout == None:
if self.timeout is None:
GLib.timeout_add(500, self.state_check)
def add_labels(self):
@@ -246,13 +246,6 @@ class JobStatusPanel(ScreenPanel):
for child in self.labels['i2_box'].get_children():
self.labels['i2_box'].remove(child)
#if self.file_metadata == None:
# self.labels['i1_box'].add(self.labels['temp_grid'])
# self.labels['i1_box'].add(self.labels['pos_box'])
# self.labels['i1_box'].add(self.labels['sfe_grid'])
# self.labels['i2_box'].add(self.labels['it_box'])
# self.labels['i2_box'].add(self.labels['itl_box'])
#else:
self.labels['i1_box'].add(self.labels['thumbnail'])
self.labels['i2_box'].add(self.labels['temp_grid'])
self.labels['i2_box'].add(self.labels['pos_box'])
@@ -286,16 +279,14 @@ class JobStatusPanel(ScreenPanel):
for to in self.close_timeouts:
GLib.source_remove(to)
self.close_timeouts.remove(to)
if self.timeout == None:
if self.timeout is None:
self.timeout = GLib.timeout_add(500, self.state_check)
def resume(self, widget):
#self.disable_button("resume","cancel")
self._screen._ws.klippy.print_resume(self._response_callback, "enable_button", "pause", "cancel")
self._screen.show_all()
def pause(self, widget):
#self.disable_button("pause","cancel")
self._screen._ws.klippy.print_pause(self._response_callback, "enable_button", "resume", "cancel")
self._screen.show_all()
@@ -352,7 +343,7 @@ class JobStatusPanel(ScreenPanel):
self.labels[arg].set_sensitive(False)
def _callback_metadata(self, newfiles, deletedfiles, modifiedfiles):
if bool(self.file_metadata) == False and self.filename in modifiedfiles:
if bool(self.file_metadata) is False and self.filename in modifiedfiles:
self.update_file_metadata()
self._files.remove_file_callback(self._callback_metadata)
@@ -361,7 +352,7 @@ class JobStatusPanel(ScreenPanel):
for to in self.close_timeouts:
GLib.source_remove(to)
self.close_timeouts.remove(to)
if self.timeout == None:
if self.timeout is None:
GLib.timeout_add(500, self.state_check)
self._screen.wake_screen()
self.state_check()
@@ -378,12 +369,14 @@ class JobStatusPanel(ScreenPanel):
_ = self.lang.gettext
if self._printer.has_heated_bed():
self.update_temp("heater_bed",
self.update_temp(
"heater_bed",
self._printer.get_dev_stat("heater_bed", "temperature"),
self._printer.get_dev_stat("heater_bed", "target")
)
for x in self._printer.get_tools():
self.update_temp(x,
self.update_temp(
x,
self._printer.get_dev_stat(x, "temperature"),
self._printer.get_dev_stat(x, "target")
)
@@ -394,8 +387,10 @@ class JobStatusPanel(ScreenPanel):
self.update_message()
if "print_stats" in data and "filename" in data['print_stats']:
if data['print_stats']['filename'] != self.filename and self.state not in ["cancelling","cancelled","complete"]:
logging.debug("filename: '%s' '%s' status: %s" % (self.filename, data['print_stats']['filename'], self.state))
if data['print_stats']['filename'] != self.filename and (
self.state not in ["cancelling", "cancelled", "complete"]):
logging.debug("filename: '%s' '%s' status: %s" %
(self.filename, data['print_stats']['filename'], self.state))
self.update_filename()
if "toolhead" in data:
@@ -413,8 +408,6 @@ class JobStatusPanel(ScreenPanel):
self.labels['pos_z'].set_text("Z: %.2f" % (data["gcode_move"]["gcode_position"][2]))
if "gcode_move" in data:
#if "homing_origin" in data["gcode_move"]:
# self.labels['zoffset'].set_text("%.2fmm" % data["gcode_move"]["homing_origin"][2])
if "extrude_factor" in data["gcode_move"]:
self.extrusion = int(data["gcode_move"]["extrude_factor"]*100)
self.labels['extrusion'].set_text("%3d%%" % self.extrusion)
@@ -555,7 +548,7 @@ class JobStatusPanel(ScreenPanel):
def show_file_thumbnail(self):
if self._files.has_thumbnail(self.filename):
pixbuf = self.get_file_image(self.filename, 7, 3.25)
if pixbuf != None:
if pixbuf is not None:
self.labels['thumbnail'].set_from_pixbuf(pixbuf)
def update_filename(self):
@@ -611,11 +604,7 @@ class JobStatusPanel(ScreenPanel):
def update_message(self):
msg = self._printer.get_stat("display_status", "message")
self.labels['lcdmessage'].set_text("" if msg == None else msg)
#def update_temp(self, dev, temp, target):
# if dev in self.labels:
# self.labels[dev].set_label(self._gtk.formatTemperatureString(temp, target))
self.labels['lcdmessage'].set_text("" if msg is None else msg)
def update_temp(self, x, temp, target):
self.labels[x].set_markup(

View File

@@ -78,12 +78,14 @@ class MainPanel(MenuPanel):
return
for x in self._printer.get_tools():
self.update_temp(x,
self.update_temp(
x,
self._printer.get_dev_stat(x, "temperature"),
self._printer.get_dev_stat(x, "target")
)
for h in self._printer.get_heaters():
self.update_temp(h,
self.update_temp(
h,
self._printer.get_dev_stat(h, "temperature"),
self._printer.get_dev_stat(h, "target"),
None if h == "heater_bed" else " ".join(h.split(" ")[1:])

View File

@@ -35,7 +35,7 @@ class MenuPanel(ScreenPanel):
for child in self.grid.get_children():
self.grid.remove(child)
l = len(items)
length = len(items)
i = 0
for item in items:
key = list(item)[0]
@@ -47,7 +47,7 @@ class MenuPanel(ScreenPanel):
row = int(i/columns)
width = 1
if expandLast == True and i+1 == l and l%2 == 1:
if expandLast is True and i+1 == length and length % 2 == 1:
width = 2
self.grid.attach(self.labels[key], col, row, width, 1)
@@ -68,11 +68,11 @@ class MenuPanel(ScreenPanel):
b = self._gtk.ButtonImage(
item['icon'], parsed_name, "color"+str((i % 4)+1)
)
if item['panel'] != False:
if item['panel'] is not False:
b.connect("clicked", self.menu_item_clicked, item['panel'], item)
elif item['method'] != False:
params = item['params'] if item['params'] != False else {}
if item['confirm'] != False:
elif item['method'] is not False:
params = item['params'] if item['params'] is not False else {}
if item['confirm'] is not False:
b.connect("clicked", self._screen._confirm_send_action, item['confirm'], item['method'], params)
else:
b.connect("clicked", self._screen._send_action, item['method'], params)
@@ -81,9 +81,9 @@ class MenuPanel(ScreenPanel):
self.labels[key] = b
def evaluate_enable(self, enable):
if enable == True:
if enable is True:
return True
if enable == False:
if enable is False:
return False
try:
@@ -94,6 +94,6 @@ class MenuPanel(ScreenPanel):
if result == 'True':
return True
return False
except:
except Exception:
logging.debug("Error evaluating enable statement: %s", enable)
return False

View File

@@ -52,7 +52,7 @@ class MovePanel(ScreenPanel):
grid.attach(self.labels['home'], 0, 0, 1, 1)
distgrid = Gtk.Grid()
j = 0;
j = 0
for i in self.distances:
self.labels[i] = self._gtk.ToggleButton(i)
self.labels[i].set_direction(Gtk.TextDirection.LTR)
@@ -71,10 +71,6 @@ class MovePanel(ScreenPanel):
self.labels["1"].set_active(True)
#space_grid = self._gtk.HomogeneousGrid()
#space_grid.attach(Gtk.Label("Distance (mm):"),0,0,1,1)
#space_grid.attach(distgrid,0,1,1,1)
#space_grid.attach(Gtk.Label(" "),0,2,1,1)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
bottomgrid = self._gtk.HomogeneousGrid()
@@ -128,6 +124,8 @@ class MovePanel(ScreenPanel):
speed = self._config.get_config()['main'].getint("move_speed", 20)
speed = min(max(1, speed), 200) # Cap movement speed between 1-200mm/s
self._screen._ws.klippy.gcode_script(
"%s\n%s %s%s F%s%s" % (KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist, speed*60,
"\nG90" if self._printer.get_stat("gcode_move", "absolute_coordinates") == True else "")
"%s\n%s %s%s F%s%s" % (
KlippyGcodes.MOVE_RELATIVE, KlippyGcodes.MOVE, axis, dist, speed*60,
"\nG90" if self._printer.get_stat("gcode_move", "absolute_coordinates") is True else ""
)
)

View File

@@ -7,7 +7,6 @@ import re
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib, Pango
from ks_includes.screen_panel import ScreenPanel
def create_panel(*args):
@@ -67,7 +66,7 @@ class NetworkPanel(ScreenPanel):
self.labels['networklist'] = Gtk.Grid()
self.files = {}
if self._screen.wifi != None and self._screen.wifi.is_initialized():
if self._screen.wifi is not None and self._screen.wifi.is_initialized():
box.pack_start(sbox, False, False, 0)
box.pack_start(scroll, True, True, 0)
@@ -104,7 +103,7 @@ class NetworkPanel(ScreenPanel):
def add_network(self, ssid, show=True):
_ = self.lang.gettext
if ssid == None:
if ssid is None:
return
ssid = ssid.strip()
@@ -113,7 +112,7 @@ class NetworkPanel(ScreenPanel):
return
netinfo = self._screen.wifi.get_network_info(ssid)
if netinfo == None:
if netinfo is None:
logging.debug("Couldn't get netinfo")
return
@@ -165,7 +164,7 @@ class NetworkPanel(ScreenPanel):
buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
if network_id != -1:
buttons.pack_end(delete, False, False, 0)
if netinfo['connected'] == False:
if netinfo['connected'] is False:
buttons.pack_end(connect, False, False, 0)
network.add(buttons)
@@ -176,17 +175,17 @@ class NetworkPanel(ScreenPanel):
reverse = False
pos = 0
if netinfo['connected'] == True:
if netinfo['connected'] is True:
pos = 0
else:
connected_ssid = self._screen.wifi.get_connected_ssid()
nets = list(self.networks)
if connected_ssid != None:
if connected_ssid is not None:
if connected_ssid in nets:
nets.remove(connected_ssid)
nets = sorted(nets, reverse=reverse)
pos = nets.index(ssid)
if connected_ssid != None:
if connected_ssid is not None:
pos += 1
self.labels['networks'][ssid] = {
@@ -199,7 +198,7 @@ class NetworkPanel(ScreenPanel):
self.labels['networklist'].insert_row(pos)
self.labels['networklist'].attach(self.networks[ssid], 0, pos, 1, 1)
if show == True:
if show is True:
self.labels['networklist'].show()
def add_new_network(self, widget, ssid, connect=False):
@@ -209,14 +208,14 @@ class NetworkPanel(ScreenPanel):
self.close_add_network()
if connect == True:
if result == True:
if connect is True:
if result is True:
self.connect_network(widget, ssid, False)
else:
self._screen.show_popup_message("Error adding network %s" % ssid)
def back(self):
if self.show_add == True:
if self.show_add is True:
self.close_add_network()
return True
return False
@@ -232,7 +231,7 @@ class NetworkPanel(ScreenPanel):
self.labels['networklist'].show_all()
def close_add_network(self):
if self.show_add == False:
if self.show_add is False:
return
for child in self.content.get_children():
@@ -249,9 +248,9 @@ class NetworkPanel(ScreenPanel):
def connected_callback(self, ssid, prev_ssid):
logging.info("Now connected to a new network")
if ssid != None:
if ssid is not None:
self.remove_network(ssid)
if prev_ssid != None:
if prev_ssid is not None:
self.remove_network(prev_ssid)
self.check_missing_networks()
@@ -266,8 +265,8 @@ class NetworkPanel(ScreenPanel):
isdef = True
break
if isdef == False:
if showadd == True:
if isdef is False:
if showadd is True:
self.show_add_network(widget, ssid)
return
self.prev_network = self._screen.wifi.get_connected_ssid()
@@ -306,7 +305,7 @@ class NetworkPanel(ScreenPanel):
return
i = 0
while self.labels['networklist'].get_child_at(0, i) != None:
while self.labels['networklist'].get_child_at(0, i) is not None:
if self.networks[ssid] == self.labels['networklist'].get_child_at(0, i):
self.labels['networklist'].remove_row(i)
self.labels['networklist'].show()
@@ -332,7 +331,7 @@ class NetworkPanel(ScreenPanel):
self.content.show_all()
def show_add_network(self, widget, ssid):
if self.show_add == True:
if self.show_add is True:
return
_ = self.lang.gettext
@@ -352,8 +351,8 @@ class NetworkPanel(ScreenPanel):
box.set_vexpand(False)
self.labels['add_network'].add(box)
l = self._gtk.Label("%s %s:" % (_("PSK for"), ssid))
l.set_hexpand(False)
label = self._gtk.Label("%s %s:" % (_("PSK for"), ssid))
label.set_hexpand(False)
entry = Gtk.Entry()
entry.set_hexpand(True)
@@ -363,7 +362,7 @@ class NetworkPanel(ScreenPanel):
self.labels['network_psk'] = entry
box.pack_start(l, False, False, 5)
box.pack_start(label, False, False, 5)
box.pack_start(entry, True, True, 5)
box.pack_start(save, False, False, 5)
@@ -386,12 +385,12 @@ class NetworkPanel(ScreenPanel):
if ssid not in self.networks or ssid not in self.labels['networks']:
return
netinfo = self._screen.wifi.get_network_info(ssid)
if netinfo == None:
if netinfo is None:
logging.debug("Couldn't get netinfo for update")
return
connected = ""
if netinfo['connected'] == True:
if netinfo['connected'] is True:
stream = os.popen('hostname -f')
hostname = stream.read().strip()
ifadd = netifaces.ifaddresses(self.interface)
@@ -406,8 +405,8 @@ class NetworkPanel(ScreenPanel):
connected = "Password saved."
freq = "2.4 GHz" if netinfo['frequency'][0:1] == "2" else "5 Ghz"
self.labels['networks'][ssid]['info'].set_markup("%s%s <small>%s %s %s %s%s</small>" % ( connected,
"" if netinfo['encryption'] == "off" else netinfo['encryption'].upper(),
self.labels['networks'][ssid]['info'].set_markup("%s%s <small>%s %s %s %s%s</small>" % (
connected, "" if netinfo['encryption'] == "off" else netinfo['encryption'].upper(),
freq, _("Channel"), netinfo['channel'], netinfo['signal_level_dBm'], _("dBm")
))
self.labels['networks'][ssid]['info'].show_all()
@@ -424,8 +423,8 @@ class NetworkPanel(ScreenPanel):
ipv4 = "<b>%s:</b> %s " % (_("IPv4"), ifadd[netifaces.AF_INET][0]['addr'])
if netifaces.AF_INET6 in ifadd and len(ifadd[netifaces.AF_INET6]) > 0:
ipv6 = ipv6 = "<b>%s:</b> %s " % (_("IPv6"), ifadd[netifaces.AF_INET6][0]['addr'].split('%')[0])
connected = "<b>%s</b>\n\n<small><b>%s</b></small>\n<b>%s:</b> %s\n%s\n%s\n" % (self.interface, _("Connected"),_("Hostname"),
hostname, ipv4, ipv6)
connected = "<b>%s</b>\n\n<small><b>%s</b></small>\n<b>%s:</b> %s\n%s\n%s\n" % (
self.interface, _("Connected"), _("Hostname"), hostname, ipv4, ipv6)
self.labels['networkinfo'].set_markup(connected)
self.labels['networkinfo'].show_all()

View File

@@ -138,12 +138,14 @@ class PreheatPanel(ScreenPanel):
return
for x in self._printer.get_tools():
self.update_temp(x,
self.update_temp(
x,
self._printer.get_dev_stat(x, "temperature"),
self._printer.get_dev_stat(x, "target")
)
for h in self._printer.get_heaters():
self.update_temp(h,
self.update_temp(
h,
self._printer.get_dev_stat(h, "temperature"),
self._printer.get_dev_stat(h, "target"),
None if h == "heater_bed" else " ".join(h.split(" ")[1:])

View File

@@ -156,14 +156,14 @@ class PrintPanel(ScreenPanel):
self.dir_panels[parent_dir].insert_row(pos)
self.dir_panels[parent_dir].attach(self.directories[directory], 0, pos, 1, 1)
if show == True:
if show is True:
self.dir_panels[parent_dir].show_all()
def add_file(self, filepath, show=True):
_ = self.lang.gettext
fileinfo = self._screen.files.get_file_info(filepath)
if fileinfo == None:
if fileinfo is None:
return
dir = ("gcodes/%s" % filepath).split('/')[:-1]
@@ -180,7 +180,8 @@ class PrintPanel(ScreenPanel):
curdir = "/".join(dir[0:i+1])
if curdir != "gcodes" and fileinfo['modified'] > self.filelist[curdir]['modified']:
self.filelist[curdir]['modified'] = fileinfo['modified']
self.labels['directories'][curdir]['info'].set_markup("<small>%s: <b>%s</b></small>" %
self.labels['directories'][curdir]['info'].set_markup(
"<small>%s: <b>%s</b></small>" %
(_("Modified"), datetime.fromtimestamp(fileinfo['modified']).strftime("%Y-%m-%d %H:%M")))
self.filelist[directory]['files'].append(filename)
@@ -217,7 +218,7 @@ class PrintPanel(ScreenPanel):
icon = self._gtk.Image("file.svg", False, 1.6, 1.6)
pixbuf = self.get_file_image(filepath)
if pixbuf != None:
if pixbuf is not None:
icon.set_from_pixbuf(pixbuf)
file.add(icon)
@@ -234,8 +235,10 @@ class PrintPanel(ScreenPanel):
reverse = False if self.sort_current[1] == 0 else True
if self.sort_current[0] == "date":
files = sorted(self.filelist[directory]['files'], reverse=reverse,
key=lambda item: self._screen.files.get_file_info(("%s/%s" %(directory,item))[7:])['modified'])
files = sorted(
self.filelist[directory]['files'], reverse=reverse,
key=lambda item: self._screen.files.get_file_info(("%s/%s" % (directory, item))[7:])['modified']
)
else:
files = sorted(self.filelist[directory]['files'], reverse=reverse)
pos = files.index(filename)
@@ -243,7 +246,7 @@ class PrintPanel(ScreenPanel):
self.dir_panels[directory].insert_row(pos)
self.dir_panels[directory].attach(self.files[filepath], 0, pos, 1, 1)
if show == True:
if show is True:
self.dir_panels[directory].show_all()
def back(self):
@@ -302,11 +305,10 @@ class PrintPanel(ScreenPanel):
grid.set_size_request(self._screen.width - 60, -1)
pixbuf = self.get_file_image(filename, 8, 3.2)
if pixbuf != None:
if pixbuf is not None:
image = Gtk.Image.new_from_pixbuf(pixbuf)
grid.attach_next_to(image, label, Gtk.PositionType.BOTTOM, 1, 3)
#table.attach(label, 0, 1, 0, 1, Gtk.AttachOptions.SHRINK | Gtk.AttachOptions.FILL)
grid.set_vexpand(True)
grid.set_halign(Gtk.Align.CENTER)
grid.set_valign(Gtk.Align.CENTER)
@@ -352,7 +354,7 @@ class PrintPanel(ScreenPanel):
_ = self.lang.gettext
fileinfo = self._screen.files.get_file_info(filename)
if fileinfo == None:
if fileinfo is None:
return
return "<small>%s: <b>%s</b> - %s: <b>%s</b>\n%s: <b>%s</b></small>" % (
@@ -366,7 +368,7 @@ class PrintPanel(ScreenPanel):
def get_print_time(self, filename):
fileinfo = self._screen.files.get_file_info(filename)
if fileinfo == None:
if fileinfo is None:
return
if "estimated_time" in fileinfo:
@@ -408,7 +410,7 @@ class PrintPanel(ScreenPanel):
# Update icon
pixbuf = self.get_file_image(filename)
if pixbuf != None:
if pixbuf is not None:
self.labels['files'][filename]['icon'].set_from_pixbuf(pixbuf)
def _callback(self, newfiles, deletedfiles, updatedfiles=[]):

View File

@@ -19,8 +19,8 @@ class ScreenSaverPanel(ScreenPanel):
box.set_vexpand(True)
box.set_halign(Gtk.Align.CENTER)
l = Gtk.Label(_("Screen will show in less than one second"))
box.add(l)
label = Gtk.Label(_("Screen will show in less than one second"))
box.add(label)
self.layout = box

View File

@@ -24,7 +24,6 @@ class SettingsPanel(ScreenPanel):
printbox = Gtk.Box(spacing=0)
printbox.set_vexpand(False)
self.labels['add_printer_button'] = self._gtk.Button(_("Add Printer"), "color1")
#printbox.add(self.labels['add_printer_button'])
self.labels['printers_box'] = self.create_box('printers', printbox)
options = self._config.get_configurable_options().copy()
@@ -98,7 +97,7 @@ class SettingsPanel(ScreenPanel):
return box
def add_option(self, boxname, opt_array, opt_name, option):
if option['type'] == None:
if option['type'] is None:
return
frame = Gtk.Frame()
@@ -114,11 +113,6 @@ class SettingsPanel(ScreenPanel):
name.set_line_wrap(True)
name.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR)
#open = self._gtk.ButtonImage("resume",None,"color3")
#open.connect("clicked", self.run_gcode_macro, macro)
#open.set_hexpand(False)
#open.set_halign(Gtk.Align.END)
labels = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
labels.add(name)
@@ -154,7 +148,6 @@ class SettingsPanel(ScreenPanel):
i += 1
dropdown.connect("changed", self.on_dropdown_change, option['section'], opt_name,
option['callback'] if "callback" in option else None)
#dropdown.props.relief = Gtk.ReliefStyle.NONE
dropdown.set_entry_text_column(0)
dev.add(dropdown)
logging.debug("Children: %s" % dropdown.get_children())

View File

@@ -44,7 +44,6 @@ class SplashScreenPanel(ScreenPanel):
main.pack_end(self.labels['text'], True, True, 0)
self.content.add(main)
#self.layout.put(box, 0, 0)
def update_text(self, text):
self.labels['text'].set_text(text)

View File

@@ -12,6 +12,7 @@ from ks_includes.screen_panel import ScreenPanel
def create_panel(*args):
return SystemPanel(*args)
ALLOWED_SERVICES = ["KlipperScreen", "MoonCord", "klipper", "moonraker"]
class SystemPanel(ScreenPanel):
@@ -42,9 +43,9 @@ class SystemPanel(ScreenPanel):
info.set_valign(Gtk.Align.CENTER)
self.labels['loadavg'] = Gtk.Label("temp")
#self.system_timeout = GLib.timeout_add(1000, self.update_system_load)
self.labels['klipper_version'] = Gtk.Label(_("Klipper Version") +
self.labels['klipper_version'] = Gtk.Label(
_("Klipper Version") +
(": %s" % self._screen.printer.get_klipper_version()))
self.labels['klipper_version'].set_margin_top(15)
@@ -64,7 +65,7 @@ class SystemPanel(ScreenPanel):
update_resp = self._screen.apiclient.send_request("machine/update/status")
self.update_status = False
if update_resp == False:
if update_resp is False:
logging.info("No update manager configured")
else:
self.update_status = update_resp['result']
@@ -87,7 +88,6 @@ class SystemPanel(ScreenPanel):
self.labels["%s_restart" % prog].connect("clicked", self.restart, prog)
infogrid.attach(self.labels["%s_restart" % prog], 0, i, 1, 1)
#infogrid.attach(self.labels["%s_info" % prog], 2, i, 1, 1)
infogrid.attach(self.labels["%s_status" % prog], 2, i, 1, 1)
logging.info("Updating program: %s " % prog)
self.update_program_info(prog)
@@ -120,7 +120,7 @@ class SystemPanel(ScreenPanel):
def get_updates(self):
update_resp = self._screen.apiclient.send_request("machine/update/status")
if update_resp == False:
if update_resp is False:
logging.info("No update manager configured")
else:
self.update_status = update_resp['result']
@@ -139,7 +139,7 @@ class SystemPanel(ScreenPanel):
adjustment.set_value(adjustment.get_upper() - adjustment.get_page_size())
adjustment = self.labels['update_scroll'].show_all()
if data['complete'] == True:
if data['complete'] is True:
self.update_dialog.set_response_sensitive(Gtk.ResponseType.CANCEL, True)
def restart(self, widget, program):
@@ -152,7 +152,7 @@ class SystemPanel(ScreenPanel):
def show_commit_history(self, widget, program):
_ = self.lang.gettext
if self.update_status == False or program not in self.update_status['version_info']:
if self.update_status is False or program not in self.update_status['version_info']:
return
info = self.update_status['version_info'][program]
@@ -205,7 +205,7 @@ class SystemPanel(ScreenPanel):
_ = self.lang.gettext
if self.update_status == False or program not in self.update_status['version_info']:
if self.update_status is False or program not in self.update_status['version_info']:
return
info = self.update_status['version_info'][program]

View File

@@ -65,7 +65,7 @@ class TemperaturePanel(ScreenPanel):
self.labels["npad"].connect("clicked", self.show_numpad)
tempgrid = Gtk.Grid()
j = 0;
j = 0
for i in self.tempdeltas:
self.labels['deg' + i] = self._gtk.ToggleButton(i)
self.labels['deg' + i].connect("clicked", self.change_temp_delta, i)
@@ -194,12 +194,14 @@ class TemperaturePanel(ScreenPanel):
return
for x in self._printer.get_tools():
self.update_temp(x,
self.update_temp(
x,
self._printer.get_dev_stat(x, "temperature"),
self._printer.get_dev_stat(x, "target")
)
for h in self._printer.get_heaters():
self.update_temp(h,
self.update_temp(
h,
self._printer.get_dev_stat(h, "temperature"),
self._printer.get_dev_stat(h, "target"),
None if h == "heater_bed" else " ".join(h.split(" ")[1:])

View File

@@ -39,7 +39,7 @@ class ZCalibratePanel(ScreenPanel):
zneg.connect("clicked", self.move, "-")
distgrid = Gtk.Grid()
j = 0;
j = 0
for i in self.distances:
self.labels[i] = self._gtk.ToggleButton(i)
self.labels[i].set_direction(Gtk.TextDirection.LTR)

View File

@@ -119,7 +119,8 @@ class KlipperScreen(Gtk.Window):
logging.info("Screen resolution: %sx%s" % (self.width, self.height))
self.theme = self._config.get_main_config_option('theme')
self.gtk = KlippyGtk(self, self.width, self.height, self.theme, self._config.get_main_config().getboolean("show_cursor", fallback=False))
self.gtk = KlippyGtk(self, self.width, self.height, self.theme,
self._config.get_main_config().getboolean("show_cursor", fallback=False))
self.keyboard_height = self.gtk.get_keyboard_height()
self.init_style()
@@ -155,7 +156,7 @@ class KlipperScreen(Gtk.Window):
_ = self.lang.gettext
if self.connected_printer == name:
if self.printer_select_prepanel != None:
if self.printer_select_prepanel is not None:
self.show_panel(self.printer_select_prepanel, "", "", 2)
self.printer_select_prepanel = None
while len(self.printer_select_callbacks) > 0:
@@ -219,7 +220,7 @@ class KlipperScreen(Gtk.Window):
powerdevs = self.apiclient.send_request("machine/device_power/devices")
logging.debug("Found power devices: %s" % powerdevs)
if powerdevs != False:
if powerdevs is not False:
self.printer.configure_power_devices(powerdevs['result'])
self.panels['splash_screen'].show_restart_buttons()
@@ -265,7 +266,7 @@ class KlipperScreen(Gtk.Window):
self._ws.klippy.object_subscription(requested_updates)
def _load_panel(self, panel, *args):
if not panel in self.load_panel:
if panel not in self.load_panel:
logging.debug("Loading panel: %s" % panel)
panel_path = os.path.join(os.path.dirname(__file__), 'panels', "%s.py" % panel)
logging.info("Panel path: %s" % panel_path)
@@ -297,7 +298,7 @@ class KlipperScreen(Gtk.Window):
self.panels[panel_name].initialize(panel_name, **kwargs)
else:
self.panels[panel_name].initialize(panel_name)
except:
except Exception:
if panel_name in self.panels:
del self.panels[panel_name]
logging.exception("Unable to load panel %s" % type)
@@ -328,14 +329,14 @@ class KlipperScreen(Gtk.Window):
if hasattr(self.panels[panel_name], "activate"):
self.panels[panel_name].activate()
self.show_all()
except:
except Exception:
logging.exception("Error attaching panel")
self._cur_panels.append(panel_name)
logging.debug("Current panel hierarchy: %s", str(self._cur_panels))
def show_popup_message(self, message):
if self.popup_message != None:
if self.popup_message is not None:
self.close_popup_message()
box = Gtk.Box()
@@ -367,7 +368,7 @@ class KlipperScreen(Gtk.Window):
return False
def close_popup_message(self, widget=None):
if self.popup_message == None:
if self.popup_message is None:
return
self.base_panel.get().remove(self.popup_message)
@@ -383,7 +384,8 @@ class KlipperScreen(Gtk.Window):
]
label = Gtk.Label()
label.set_markup(("%s \n\n" % err) +
label.set_markup(
("%s \n\n" % err) +
_("Check /tmp/KlipperScreen.log for more information.\nPlease submit an issue on GitHub for help."))
label.set_hexpand(True)
label.set_halign(Gtk.Align.CENTER)
@@ -450,7 +452,7 @@ class KlipperScreen(Gtk.Window):
)
def is_keyboard_showing(self):
if self.keyboard == None:
if self.keyboard is None:
return False
return True
@@ -491,7 +493,7 @@ class KlipperScreen(Gtk.Window):
def _remove_current_panel(self, pop=True, show=True):
if len(self._cur_panels) > 0:
self.base_panel.remove(self.panels[self._cur_panels[-1]].get_content())
if pop ==True:
if pop is True:
self._cur_panels.pop()
if len(self._cur_panels) > 0:
self.base_panel.add_content(self.panels[self._cur_panels[-1]])
@@ -499,7 +501,7 @@ class KlipperScreen(Gtk.Window):
if hasattr(self.panels[self._cur_panels[-1]], "process_update"):
self.panels[self._cur_panels[-1]].process_update("notify_status_update",
self.printer.get_updates())
if show == True:
if show is True:
self.show_all()
def _menu_go_back(self, widget=None):
@@ -551,13 +553,13 @@ class KlipperScreen(Gtk.Window):
os.system("xset -display :0 s off")
os.system("xset -display :0 s noblank")
if functions.dpms_loaded == False:
if functions.dpms_loaded is False:
logging.info("DPMS functions not loaded. Unable to protect on button click when DPMS is enabled.")
logging.debug("Changing power save to: %s" % time)
if time == "off":
if self.dpms_timeout != None:
if self.dpms_timeout is not None:
GLib.source_remove(self.dpms_timeout)
self.dpms_timeout = None
os.system("xset -display :0 -dpms")
@@ -567,11 +569,11 @@ class KlipperScreen(Gtk.Window):
if time < 0:
return
os.system("xset -display :0 dpms 0 %s 0" % time)
if self.dpms_timeout == None and functions.dpms_loaded == True:
if self.dpms_timeout is None and functions.dpms_loaded is True:
self.dpms_timeout = GLib.timeout_add(1000, self.check_dpms_state)
def set_updating(self, updating=False):
if self.updating == True and updating == False:
if self.updating is True and updating is False:
if len(self.update_queue) > 0:
i = self.update_queue.pop()
self.update_queue = []
@@ -681,7 +683,7 @@ class KlipperScreen(Gtk.Window):
self.printer_initializing(_("Klipper has shutdown"))
def toggle_macro_shortcut(self, value):
if value == True:
if value is True:
self.base_panel.show_macro_shortcut(True, True)
else:
self.base_panel.show_macro_shortcut(False, True)
@@ -689,7 +691,7 @@ class KlipperScreen(Gtk.Window):
def _websocket_callback(self, action, data):
_ = self.lang.gettext
if self.connecting == True:
if self.connecting is True:
return
if action == "notify_klippy_disconnected":
@@ -702,7 +704,7 @@ class KlipperScreen(Gtk.Window):
self.printer.process_update(data)
elif action == "notify_filelist_changed":
logging.debug("Filelist changed: %s", json.dumps(data, indent=2))
if self.files != None:
if self.files is not None:
self.files.process_update(data)
elif action == "notify_metadata_update":
self.files.request_metadata(data['filename'])
@@ -739,7 +741,7 @@ class KlipperScreen(Gtk.Window):
env.install_gettext_translations(self.lang)
j2_temp = env.from_string(text)
text = j2_temp.render()
except:
except Exception:
logging.debug("Error parsing jinja for confirm_send_action")
label = Gtk.Label()
@@ -766,7 +768,7 @@ class KlipperScreen(Gtk.Window):
self.shutdown = True
self.close_popup_message()
self.show_panel('splash_screen', "splash_screen", "Splash Screen", 2)
if text != None:
if text is not None:
self.panels['splash_screen'].update_text(text)
self.panels['splash_screen'].show_restart_buttons()
@@ -774,18 +776,18 @@ class KlipperScreen(Gtk.Window):
_ = self.lang.gettext
printer_info = self.apiclient.get_printer_info()
if printer_info == False:
if printer_info is False:
logging.info("Unable to get printer info from moonraker")
return False
data = self.apiclient.send_request("printer/objects/query?" + "&".join(PRINTER_BASE_STATUS_OBJECTS))
if data == False:
if data is False:
logging.info("Error getting printer object data")
return False
powerdevs = self.apiclient.send_request("machine/device_power/devices")
data = data['result']['status']
config = self.apiclient.send_request("printer/objects/query?configfile")
if config == False:
if config is False:
logging.info("Error getting printer config data")
return False
@@ -803,7 +805,7 @@ class KlipperScreen(Gtk.Window):
data = self.apiclient.send_request("printer/objects/query?" + "&".join(PRINTER_BASE_STATUS_OBJECTS +
extra_items))
if data == False:
if data is False:
logging.info("Error getting printer object data")
return False
logging.info("Startup data: %s" % data['result']['status'])
@@ -812,7 +814,7 @@ class KlipperScreen(Gtk.Window):
self.files.initialize()
self.files.refresh_files()
if powerdevs != False:
if powerdevs is not False:
self.printer.configure_power_devices(powerdevs['result'])
def printer_ready(self):
@@ -910,5 +912,5 @@ def main():
if __name__ == "__main__":
try:
main()
except:
except Exception:
logging.exception("Fatal error in main loop")

3
scripts/check_code.sh Normal file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
pycodestyle --ignore=E226,E301,E302,E303,E402,W503,W504 --max-line-length=120 --max-doc-length=120 screen.py ks_includes panels