kliment / Printrun

Pronterface, Pronsole, and Printcore - Pure Python 3d printing host software
GNU General Public License v3.0
2.37k stars 998 forks source link

Failed to inhibit sleep and DBusException for pronsole #522

Closed lordofhyphens closed 9 years ago

lordofhyphens commented 10 years ago

running pronsole on a headless RasPi board, running Raspberrian

T:22 0%> Print started at: 20:53:11 [ERROR] Failed to inhibit sleep: Traceback (most recent call last): File "/home/builder/Printrun/printrun/pronsole.py", line 1426, in startcb powerset_print_start(reason = "Preventing sleep during print") File "/home/builder/Printrun/printrun/power/init.py", line 79, in powerset_print_start inhibit_sleep(reason) File "/home/builder/Printrun/printrun/power/init.py", line 40, in inhibit_sleep bus = dbus.SessionBus() File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 211, in new mainloop=mainloop) File "/usr/lib/python2.7/dist-packages/dbus/_dbus.py", line 100, in new bus = BusConnection.new(subclass, bus_type, mainloop=mainloop) File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 122, in new bus = cls._new_for_bus(address_or_type, mainloop=mainloop) DBusException: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

iXce commented 10 years ago

Okai, not a problem (the exception is just the explanation of the [ERROR] Failed to inhibit sleep:), but we need to silence this.

iXce commented 10 years ago

Can you try with the above fix ?

darrenfreeman commented 10 years ago

I just updated to the latest commit (f972ebeef9cc37898ae9f57e09d8b2093b89bb20) from a much older one (54cf403daffb3031b7d96b5b0a59d4de955ed880).

I now get the following error message whenever I hit print:

-------8<--------8<--------8<--------8<-------- [ERROR] Failed to inhibit sleep: Traceback (most recent call last): File "/home/opt/Printrun/printrun/pronsole.py", line 1431, in startcb powerset_print_start(reason = "Preventing sleep during print") TypeError: powerset_print_start() takes no arguments (1 given) -------8<--------8<--------8<--------8<--------

I would love to see this feature succeed, as I've lost a long print due to stupidly closing my laptop lid while the charger was not plugged in properly. I don't know what is supposed to happen with this new feature, but I'd like it if it pretty much couldn't go to sleep unless the battery is on maybe 1%. I've also absent-mindedly hit "sleep" instead of "lock screen" under KDE. Same result. I don't expect you to fix that :) But if my desktop environment happens to ask me if I'm really sure as a result of being told by Pronterface not to sleep, then that would be great :D

darrenfreeman commented 10 years ago

Using latest commit 3a82c2bdfafa572d3644c2b6fac4cda5edb35d0e.

I now get no error messages on the console within the application window, but I do get these to stdout/stderr. Probably not all related to this issue, but here is where I'm pasting them :)

--------8<--------8<--------8<--------8<-------- psutil unavailable, could not import power utils: Traceback (most recent call last): File "/home/opt/Printrun/printrun/power/init.py", line 73, in import psutil ImportError: No module named psutil 3D view mode requested, but we failed to initialize it. Falling back to 2D view, and here is the backtrace: Traceback (most recent call last): File "/home/opt/Printrun/printrun/gui/viz.py", line 51, in init import printrun.gcview File "/home/opt/Printrun/printrun/gcview.py", line 21, in from .gl.panel import wxGLPanel File "/home/opt/Printrun/printrun/gl/panel.py", line 23, in import pyglet ImportError: No module named pyglet

iXce commented 10 years ago

Well, it seems you need to install psutil and pyglet :) psutil is used to set process priority, while pyglet is used for the 3D viewer (which is the new default now)

darrenfreeman commented 10 years ago

Under openSUSE 12.2, there is a package "python-psutil", not to be confused with "psutils". But there is no pyglet, so having to install the source package. This is worth documenting, since it's a new dependency and I gather it's not widely available in package form.

Okay, now I have no warnings at all. I can load a simple g-code and view it. And I'm uber impressed by 3D view! I'll have to share this with outers, I don't believe this is a well known change. I've literally never seen it before, and I know many people who use Pronterface.

kliment commented 10 years ago

It's not a new dependency, it's listed in the documentation and it's been a dependency for at least two years. The 3d view has also been around a long time.

On 04/05/2014 02:17 PM, darrenfreeman wrote:

Under openSUSE 12.2, there is a package "python-psutil", not to be confused with "psutils". But there is no pyglet, so having to install the source package. This is worth documenting, since it's a new dependency and I gather it's not widely available in package form.

Okay, now I have no warnings at all. I can load a simple g-code and view it. And I'm uber impressed by 3D view! I'll have to share this with outers, I don't believe this is a well known change. I've literally never seen it before, and I know many people who use Pronterface.

— Reply to this email directly or view it on GitHub https://github.com/kliment/Printrun/issues/522#issuecomment-39636285.

iXce commented 10 years ago

Yeah, it's definitely not new ^^ pyglet has been used in the STL plater since november 2011 (1e53117b77) and the G-Code 3D viewer has been advertised on planet reprap through http://guillaume.segu.in/blog/code/439/printrun-changes/ Anyway, I'm also planning to make a website for Printrun to advertise all the features (in fact, it's already done, I'm just waiting to finish a few more things in the code to get time to write a decent documentation page explaining all the features and options).

darrenfreeman commented 10 years ago

Well then it's a shame that this information isn't widely known amongst my friends. (Almost all of them have been printing longer than I have.)

Perhaps this deserves a pop-up? If the default view is set to 3D, and it can't be done, then pop-up to let you know why, and offer to change the default to 2D if you really don't want 3D.

darrenfreeman commented 10 years ago

I deeply regret doing a git pull. Nothing ever works after that. Now I can't even connect to my printer. As usual, I can't even go back to an earlier commit, as that is now broken too. I probably have to blow away the repository or reboot. After the errors below, all subsequent sessions freeze when I hit connect, and I have to kill the application.

Latest errors with the latest commit:

--------8<--------8<--------8<--------8<-------- Print started at: 14:51:15 [ERROR] Introspect error on :1.32:/org/freedesktop/ScreenSaver: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownObject: No such object path '/org/freedesktop/ScreenSaver' [ERROR] Failed to inhibit sleep: Traceback (most recent call last): File "/home/opt/Printrun/printrun/pronsole.py", line 1431, in startcb powerset_print_start(reason = "Preventing sleep during print") File "/home/opt/Printrun/printrun/power/init.py", line 90, in powerset_print_start inhibit_sleep(reason) File "/home/opt/Printrun/printrun/power/init.py", line 55, in inhibit_sleep inhibit_sleep.token = inhibit_sleep_handler.Inhibit("printrun", reason) File "/usr/lib/python2.7/site-packages/dbus/proxies.py", line 70, in call return self._proxy_method(_args, _keywords) File "/usr/lib/python2.7/site-packages/dbus/proxies.py", line 145, in call _keywords) File "/usr/lib/python2.7/site-packages/dbus/connection.py", line 651, in call_blocking message, timeout) DBusException: org.freedesktop.DBus.Error.UnknownObject: No such object path '/org/freedesktop/ScreenSaver' Exception in thread Thread-10: Traceback (most recent call last): File "/usr/lib64/python2.7/threading.py", line 551, in bootstrap_inner self.run() File "/usr/lib64/python2.7/threading.py", line 504, in run self.__target(_self.args, **self.__kwargs) File "/home/opt/Printrun/printrun/pronterface.py", line 1478, in loadviz self.gwindow.p.addfile(gcode) File "/home/opt/Printrun/printrun/gviz.py", line 433, in addfile while generator.next() is not None: File "/home/opt/Printrun/printrun/gviz.py", line 424, in addfile_perlayer generator_output = generator.next() File "/home/opt/Printrun/printrun/gviz.py", line 506, in add_parsed_gcodes self.arcs[viz_layer].append(arc) KeyError: 121

Print paused at: 14:54:01 [ERROR] Failed to uninhibit sleep: Traceback (most recent call last): File "/home/opt/Printrun/printrun/pronsole.py", line 1438, in endcb powerset_print_stop() File "/home/opt/Printrun/printrun/power/init.py", line 93, in powerset_print_stop reset_priority() File "/home/opt/Printrun/printrun/power/init.py", line 86, in reset_priority set_nice(0 if platform.system() != "Windows" else psutil.NORMAL_PRIORITY_CLASS) File "/home/opt/Printrun/printrun/power/init.py", line 80, in set_nice p.nice = nice File "/usr/lib64/python2.7/site-packages/psutil/init.py", line 945, in nice return self.set_nice(value) File "/usr/lib64/python2.7/site-packages/psutil/init.py", line 173, in wrapper return fun(self, _args, *_kwargs) File "/usr/lib64/python2.7/site-packages/psutil/init.py", line 476, in set_nice return self._platform_impl.set_process_nice(value) File "/usr/lib64/python2.7/site-packages/psutil/_pslinux.py", line 471, in wrapper raise AccessDenied(self.pid, self._process_name) AccessDenied: (pid=22738)

darrenfreeman commented 10 years ago

I got it working by unplugging the USB cable. Some parameter must be incorrectly set in the port, and staying that way between instances. I'm guessing it's crappy Linux drivers that can't recover.

iXce commented 10 years ago

That's a bunch of different errors ^^

The first one I don't understand, it shouldn't happen anymore since 02de13cffb, but it's probably not enough. I'll investigate and fix.

The second one is a problem of the 2D viewer which I haven't seen before, but is probably very easy to fix, going to test.

The last one is probably because you were killing the whole app ?

iXce commented 10 years ago

About that second issue, I would probably need the G-Code file to test it as the code clearly seems correct :)

darrenfreeman commented 10 years ago

I'll email you the file. (At least, I think it's the file.)

I should mention that the 2D viewer often renders completely the wrong arcs. Arcs that should be tiny end up spanning the whole screen. I'm guessing it's an absolute/relative issue in specifying the centre of curvature. They come from CamBam and they work fine in Marlin, so whichever format Marlin uses, that's what I'd hope to have Pronterface visualising. (At least, with an option to set it that way.)

I believe the incorrect arc interpretation is also screwing up the time estimate for the file, as some files that really take half a minute are supposed to take several hours, because the arcs are100x too big on the screen.

darrenfreeman commented 10 years ago

Sorry for being cranky earlier. I'm working without the ability to just reset the printer and home all the axes. Every time it dies, I have to accurately find the origin on the object that I'm machining, and it introduces a positioning error. (Something I'm hoping to improve on one day soon.)

And when you're machining metal, it's not just $0.20 worth of plastic if you throw it away. It's more like $20, and I can't get another one because it was an off-cut that happened to be the perfect size.

Reliability is absolutely essential for CNC machining, and I predict that a lot of users are going to try this with Pronterface over the next year.

darrenfreeman commented 10 years ago

Note that the arcs are not always wrong. It may be nondeterministic, so not a format problem. Or it may be something that got fixed in the code over the last 4 months, and I'm just not used to it working yet :)

iXce commented 10 years ago

Ah yeah I know about the arcs, but I always thought it was a problem in the slicers. If you have arcs which are known to be right, I'll be able to investigate. Thanks for the file !

darrenfreeman commented 10 years ago

It's a problem in g-code not being a complete standard :)

You may find this helpful/interesting: http://www.cnccookbook.com/CCCNCGCodeArcsG02G03.htm

iXce commented 10 years ago

Yeah I think I have seen this one in the past. Gotta look at it again ^^

iXce commented 10 years ago

capture d cran de 2014-04-06 14 04 40 Arcs look fine there, no ?

darrenfreeman commented 10 years ago

Yes, I think you may have fixed it.. or there's an intermittent problem. I'll let you know when I come across one that's got issues. I remember it happening a lot with text, so maybe it requires mixing G0/G1 and G2/G3.

iXce commented 10 years ago

Yeah it happens if I modify the gcode using my gcodeplater.

darrenfreeman commented 10 years ago

I'm relieved to hear that. You can't fix what you can't see!

iXce commented 10 years ago

Well it could be that the gcodeplater broke it :P

iXce commented 10 years ago

Was definitely due to gcodeplater not supporting gcode going up and down again and again. So no test case yet :)

iXce commented 9 years ago

Closing as the original issue now seems solved.