From 215b9e1eeaa37d52f71d86d8c5b02e2b88d90dc4 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Thu, 26 Nov 2015 15:05:14 -0500 Subject: [PATCH] Make the power module an optional dependency If power module is not loadable, then all it will affect is the warning label about the PC being on battery vs. AC power in the print window. --- Cura/gui/printWindow.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py index b6a7a4c4..70d5fc8d 100644 --- a/Cura/gui/printWindow.py +++ b/Cura/gui/printWindow.py @@ -2,7 +2,10 @@ __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AG import wx from wx.lib.intctrl import IntCtrl -import power +try: + import power +except: + power = None import time import sys import os @@ -447,7 +450,10 @@ class printWindowBasic(wx.Frame): style=wx.ALIGN_CENTER) self.powerWarningText.SetBackgroundColour('red') self.powerWarningText.SetForegroundColour('white') - self.powerManagement = power.PowerManagement() + if power: + self.powerManagement = power.PowerManagement() + else: + self.powerManagement = None self.powerWarningTimer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnPowerWarningChange, self.powerWarningTimer) self.OnPowerWarningChange(None) @@ -498,6 +504,8 @@ class printWindowBasic(wx.Frame): self._printerConnection.openActiveConnection() def OnPowerWarningChange(self, e): + if self.powerManagement is None: + return type = self.powerManagement.get_providing_power_source_type() if type == power.POWER_TYPE_AC and self.powerWarningText.IsShown(): self.powerWarningText.Hide() -- 2.30.2