Commit 79979ef5 authored by Guillaume Seguin's avatar Guillaume Seguin

Merge branch 'master' of github.com:kliment/Printrun

parents 49099158 4b25bb34
...@@ -77,6 +77,20 @@ else: ...@@ -77,6 +77,20 @@ else:
try: try:
import psutil import psutil
def get_nice(nice, p = None):
if not p: p = psutil.Process(os.getpid())
if callable(p.nice):
return p.nice()
else:
return p.nice
def set_nice(nice, p = None):
if not p: p = psutil.Process(os.getpid())
if callable(p.nice):
p.nice(nice)
else:
p.nice = nice
if platform.system() != "Windows": if platform.system() != "Windows":
import resource import resource
if hasattr(psutil, "RLIMIT_NICE"): if hasattr(psutil, "RLIMIT_NICE"):
...@@ -87,22 +101,15 @@ try: ...@@ -87,22 +101,15 @@ try:
# RLIMIT_NICE is not available (probably OSX), let's probe # RLIMIT_NICE is not available (probably OSX), let's probe
# Try setting niceness to -20 .. -1 # Try setting niceness to -20 .. -1
p = psutil.Process(os.getpid()) p = psutil.Process(os.getpid())
orig_nice = p.get_nice() orig_nice = get_nice(p)
for i in range(-20, 0): for i in range(-20, 0):
try: try:
p.set_nice(i) set_nice(i, p)
high_priority_nice = i high_priority_nice = i
break break
except psutil.AccessDenied, e: except psutil.AccessDenied, e:
pass pass
p.set_nice(orig_nice) set_nice(orig_nice, p)
def set_nice(nice):
p = psutil.Process(os.getpid())
if callable(p.nice):
p.nice(nice)
else:
p.nice = nice
def set_priority(): def set_priority():
if platform.system() == "Windows": if platform.system() == "Windows":
...@@ -126,7 +133,7 @@ try: ...@@ -126,7 +133,7 @@ try:
reset_priority() reset_priority()
deinhibit_sleep() deinhibit_sleep()
except ImportError, e: except ImportError, e:
logging.warning("psutil unavailable, could not import power utils:" + e) logging.warning("psutil unavailable, could not import power utils:" + str(e))
def powerset_print_start(reason): def powerset_print_start(reason):
pass pass
......
...@@ -266,7 +266,7 @@ class StlPlaterPanel(PlaterPanel): ...@@ -266,7 +266,7 @@ class StlPlaterPanel(PlaterPanel):
self.menusizer.Add(cutpanel, pos = (nrows + 1, 0), span = (1, 2), flag = wx.EXPAND) self.menusizer.Add(cutpanel, pos = (nrows + 1, 0), span = (1, 2), flag = wx.EXPAND)
else: else:
viewer = showstl(self, (580, 580), (0, 0)) viewer = showstl(self, (580, 580), (0, 0))
self.simarrange_path = simarrange_path if simarrange_path else "./simarrange/sa" self.simarrange_path = simarrange_path
self.set_viewer(viewer) self.set_viewer(viewer)
def start_cutting_tool(self, event, axis, direction): def start_cutting_tool(self, event, axis, direction):
...@@ -475,12 +475,15 @@ class StlPlaterPanel(PlaterPanel): ...@@ -475,12 +475,15 @@ class StlPlaterPanel(PlaterPanel):
logging.info(_("Wrote plate to %s") % name) logging.info(_("Wrote plate to %s") % name)
def autoplate(self, event = None): def autoplate(self, event = None):
try: if self.simarrange_path:
self.autoplate_simarrange() try:
except Exception, e: self.autoplate_simarrange()
logging.warning(_("Failed to use simarrange for plating, " except Exception, e:
"falling back to the standard method. " logging.warning(_("Failed to use simarrange for plating, "
"The error was: ") + e) "falling back to the standard method. "
"The error was: ") + e)
super(StlPlater, self).autoplate()
else:
super(StlPlater, self).autoplate() super(StlPlater, self).autoplate()
def autoplate_simarrange(self): def autoplate_simarrange(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment