From: Youness Alaoui Date: Thu, 26 Nov 2015 20:05:14 +0000 (-0500) Subject: Make the power module an optional dependency X-Git-Tag: lulzbot-18.02~1 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=215b9e1eeaa37d52f71d86d8c5b02e2b88d90dc4;p=cura.git 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. --- 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()