Error on Exit

A nice (keyboard based) front end for Arcade / Console game emulators.

Moderator: battlecat

Error on Exit

Postby kanito8a » Sun Dec 14, 2014 3:08 am

Every time I close MahCade (using ESC) I get the following error:

Traceback (most recent call last):
File "/usr/local/share/games/wahcade/win_main.py", line 809, in on_winMain_key_press
self.exit_wahcade()
File "/usr/local/share/games/wahcade/win_main.py", line 472, in exit_wahcade
hal_obj = bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/devices/computer')
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 241, in get_object
follow_name_owner_changes=follow_name_owner_changes)
File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 248, in __init__
self._named_service = conn.activate_name_owner(bus_name)
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 180, in activate_name_owner
self.start_service_by_name(bus_name)
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 278, in start_service_by_name
'su', (bus_name, flags)))
File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Hal was not provided by any .service files


My system config:

    Ubuntu 14.04
    MahCAde: wahcade_20131107mahcade_all
User avatar
kanito8a
 
Posts: 12
Joined: Mon Oct 11, 2010 6:46 pm

Re: Error on Exit

Postby Japi42 » Sat Dec 20, 2014 4:43 pm

Ubuntu 14.04 apparently deprecated HAL, which is causing the exception on close. Easy enough to get rid of the exception, the calls to get the HAL dbus interface just needs to be wrapped in a try/except. I have attached a patch to win_main.py for your version (wahcade_20131107mahcade_all), and also the latest version from the launchpad repository (wahcade_20131107mahcade_all). This fix just gets rid of the exception, but you won't be able to use the "Reboot" "Shutdown" or "Suspend" exit methods. I am very new to python so this patch could be less then ideal, but it seems to work for me.
You do not have the required permissions to view the files attached to this post.
Japi42
 
Posts: 3
Joined: Fri Dec 19, 2014 5:48 pm

Re: Error on Exit

Postby sairuk » Sat Dec 20, 2014 9:06 pm

Thanks for the patch. I prefer (when possible) to stay away from try/except as a final solution but its perfectly good for an immediate workaround. I've obviously implemented in the past as can be seen in the dbus/console kit section.

Good to see someone else playing with python and this project, I first started playing with python to get some stuff done for this project also. After an incident with Mamewah wiping my configurations

Seems the op has python-dbus installed and is importing but not Console Kit/Upower, or HAL.

What is the current system used for initiating a shutdown in 14.04? We need to look into that it seems. HAL depreciation was first reported in NATTY (here on the forum) which was iirc replaced with console kit? So the assumption that CK/UPOWER are current and HAL was a fallback for older systems is proven false as of 14.04.
mameau - My random bits | Wah!Ki - A Wah!Cade wiki | Mah!Cade - Experimental Wah!cade Branch | ListGen | Lazarus
User avatar
sairuk
 
Posts: 432
Joined: Sat May 22, 2010 12:37 am

Re: Error on Exit

Postby Japi42 » Mon Dec 22, 2014 2:34 pm

I've been wanting to learn Python for years now so this is a good project to learn on, plus I have been using wahcade/mahcade for many years and wanted to attempt to make some updates to it (high score display via a python port of HiToText, transition animations, faster list changes). Thanks for all your work on this project, I know it's hard to fit in playing with stuff like this when you have a life too.

I am using xubuntu 14.04.01 LTS, and it doesn't have consolekit, UPower or HAL installed for dbus by default. Looking at a capture from dbus-monitor it looks like the shutdown is done via org.freedesktop.PowerManagement which does implement hibernate/reboot/shutdown/suspend. I should be able to get together a patch that adds proper support for org.freedesktop.PowerManagement in the next couple of days.

Anyone can check if this solution will work for them by checking if PowerManagement is on their dbus by doing this from a terminal:

qdbus org.freedesktop.PowerManagement /org/freedesktop/PowerManagement

If you have qdbus installed it should list out the methods that are available, including Reboot(), Shutdown(), Suspend(), and Hibernate(). If it doesn't then we will need yet another method to support whatever distro is different. Even without that it will fail more gracefully.
Japi42
 
Posts: 3
Joined: Fri Dec 19, 2014 5:48 pm

Re: Error on Exit

Postby Zombie » Mon Dec 22, 2014 2:48 pm

We're happy to have you on the team!
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: Error on Exit

Postby sairuk » Mon Dec 22, 2014 10:13 pm

Nice, this is what this project needs as I really don't have the time to give this project the attention it requires, as is evidenced by the yearly updates ;)

I've just started my annual break so was about to start working on my update .... tragic really but quite frankly I have other priorities.

I've just done a quick commit which should correct the reported failure, I was in the process of reviewing what they had _now_ so I could add it into the code. I was also going to add an os.system or Popen fallback to something, not sure what yet maybe a log report and forced default exit state. I use Mint17 these days which does not have

I was also looking into SessionBus() yesterday which may be be a better way to go??

Code: Select all
qdbus org.gnome.SessionManager /org/gnome/SessionManager
method QString org.freedesktop.DBus.Introspectable.Introspect()
method QDBusVariant org.freedesktop.DBus.Properties.Get(QString interface, QString propname)
method QVariantMap org.freedesktop.DBus.Properties.GetAll(QString interface)
method void org.freedesktop.DBus.Properties.Set(QString interface, QString propname, QDBusVariant value)
property read QString org.gnome.SessionManager.SessionName
method bool org.gnome.SessionManager.CanShutdown()
signal void org.gnome.SessionManager.ClientAdded(QDBusObjectPath)
signal void org.gnome.SessionManager.ClientRemoved(QDBusObjectPath)
method QList<QDBusObjectPath> org.gnome.SessionManager.GetClients()
method QList<QDBusObjectPath> org.gnome.SessionManager.GetInhibitors()
method uint org.gnome.SessionManager.Inhibit(QString app_id, uint toplevel_xid, QString reason, uint flags)
signal void org.gnome.SessionManager.InhibitorAdded(QDBusObjectPath)
signal void org.gnome.SessionManager.InhibitorRemoved(QDBusObjectPath)
method void org.gnome.SessionManager.InitializationError(QString message, bool fatal)
method bool org.gnome.SessionManager.IsAutostartConditionHandled(QString condition)
method bool org.gnome.SessionManager.IsInhibited(uint flags)
method bool org.gnome.SessionManager.IsSessionRunning()
method void org.gnome.SessionManager.Logout(uint mode)
method void org.gnome.SessionManager.Reboot()
method QDBusObjectPath org.gnome.SessionManager.RegisterClient(QString app_id, QString client_startup_id)
method void org.gnome.SessionManager.RequestReboot()
method void org.gnome.SessionManager.RequestShutdown()
signal void org.gnome.SessionManager.SessionOver()
signal void org.gnome.SessionManager.SessionRunning()
method void org.gnome.SessionManager.Setenv(QString variable, QString value)
method void org.gnome.SessionManager.Shutdown()
method void org.gnome.SessionManager.Uninhibit(uint inhibit_cookie)
method void org.gnome.SessionManager.UnregisterClient(QDBusObjectPath client_id)


From Linux Mint 17
Code: Select all
qdbus org.freedesktop.PowerManagement /org/freedesktop/PowerManagement
Service 'org.freedesktop.PowerManagement' does not exist.


Code: Select all
qdbus org.freedesktop.ConsoleKit /org/freedesktop/ConsoleKit
Service 'org.freedesktop.ConsoleKit' does not exist.


To be fair I was looking for something even more generic than org.gnome.SessionManager unless all distro's run a gnome backend (this is not the case) we are still in the same boat.
mameau - My random bits | Wah!Ki - A Wah!Cade wiki | Mah!Cade - Experimental Wah!cade Branch | ListGen | Lazarus
User avatar
sairuk
 
Posts: 432
Joined: Sat May 22, 2010 12:37 am

Re: Error on Exit

Postby Japi42 » Tue Dec 23, 2014 5:48 am

Skipping the whole block when you are doing the default exit is certainly a very simple way for most users to avoid all these problems!

xubuntu uses Xfce4 as the window manager instead of GNOME, and doesn't have org.gnome.sessionmanager available by default. There is a not-at-all surprising amount of variation in something that should be simple, Linux distros can be so much fun to support! Unfortunately I think most command line routines to reboot/suspend/shutdown are going to want root so that closes off the easy option of just running one of those.

Attached is a new patch (against the latest win_main.py from launchpad) that makes a few changes:

org.freedesktop.PowerManagement is on the SessionBus, not the SystemBus, so the code is updated to get that object as well.

I defaulted the ck/up/hal/pm variables to "False", this corrects a bug where if they weren't set it was causing an exception when they were being checked with if statements later. This had prevented anything from working if ck was not available, for example. Apparently the other way to fix this is to check if the variable is in the locals() or globals() prior to use:

Code: Select all
if 'myVar' in locals():
  # myVar exists.


But I went with the make-sure-it's-set approach since I am still in denial about using a dynamically typed language.

I changed the getting of the various dbus interfaces to have independent try/except blocks, so it just keeps trying to get interfaces and hopefully one of them succeeds. Ugly but it works, and it should be easy to add in org.gnome.sessionmanager (and any other interfaces) the same way.

I added in the calls for getting the interface for PowerManager and invoking the methods on it. It is currently the last case, so if ck or hal are available it will use those first.

I tested Shutdown/Suspend/Reboot and all worked on my xubuntu install.
You do not have the required permissions to view the files attached to this post.
Japi42
 
Posts: 3
Joined: Fri Dec 19, 2014 5:48 pm

Re: Error on Exit

Postby sairuk » Tue Dec 23, 2014 6:09 am

Thanks, will have a play with it later sounds like a good set of fixes
mameau - My random bits | Wah!Ki - A Wah!Cade wiki | Mah!Cade - Experimental Wah!cade Branch | ListGen | Lazarus
User avatar
sairuk
 
Posts: 432
Joined: Sat May 22, 2010 12:37 am

Re: Error on Exit

Postby Zombie » Tue Dec 23, 2014 12:31 pm

Is this the reason I can't pm-suspend in userland anymore?
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: Error on Exit

Postby nfc.labs » Fri Jan 02, 2015 12:39 pm

Hi all,
I saw no presentation topic (please correct me if I'm wrong), so I go straight to the point.
Don't know exactly how it works on Launchpad with bug recovery, expecially in this case where the main project seems to be abandoned and branch is active waiting for merging since years.

Have Ubuntu 14.04. I just tried R154.
Exit issue seems now to be ok. But not a new one pops up, when launching games.

Traceback (most recent call last):
File "/usr/local/share/wahcade/win_main.py", line 711, in on_winMain_key_press
self.launch_auto_apps_then_game()
File "/usr/local/share/wahcade/win_main.py", line 1027, in launch_auto_apps_then_game
self.launch_game(game_cmdline_args)
File "/usr/local/share/wahcade/win_main.py", line 1173, in launch_game
cmd = '%s >> %s 2>&1' % (cmd, self.self.log_filename)
AttributeError: WinMain instance has no attribute 'self'


wahcade.log
[Fri Jan 2 12:27:46 2015]: //======================= NEW LOG RUN =======================//
[Fri Jan 2 12:27:46 2015]: Wah!Cade updating user config files in: /home/mame/.wahcade
[Fri Jan 2 12:27:46 2015]: Lock file found: Removing
[Fri Jan 2 12:27:46 2015]: Lock File removed successfully
[Fri Jan 2 12:27:46 2015]: No custom splash found, loading /usr/local/share/wahcade/pixmaps/wahcade-logo.png
[Fri Jan 2 12:27:46 2015]: [TWITTER] support disabled due to missing options
[Fri Jan 2 12:27:46 2015]: [TWITTER] consumer_key cannot be blank in wahcade.ini, details available at https://dev.twitter.com/
[Fri Jan 2 12:27:46 2015]: [TWITTER] consumer_secret cannot be blank in wahcade.ini, details available at https://dev.twitter.com/
[Fri Jan 2 12:27:46 2015]: [TWITTER] access_key cannot be blank in wahcade.ini, details available at https://dev.twitter.com/
[Fri Jan 2 12:27:46 2015]: [TWITTER] access_key cannot be blank in wahcade.ini, details available at https://dev.twitter.com/
[Fri Jan 2 12:27:47 2015]: Selected platform: M.A.M.E.
[Fri Jan 2 12:27:47 2015]: Created Video gstreamer objects
[Fri Jan 2 12:27:47 2015]: Selected gameslist: All Games
[Fri Jan 2 12:27:47 2015]: Error: Music Path [] does not exist
[Fri Jan 2 12:27:47 2015]: Fullscreen mode
[Fri Jan 2 12:27:52 2015]: [LAUNCH] Single extension only
[Fri Jan 2 12:27:52 2015]: [LAUNCH] Setting extension to: zip
[Fri Jan 2 12:27:52 2015]: [PLUGIN] No plugin found for launcher_zip
[Fri Jan 2 12:27:52 2015]: ******** Command from Wah!Cade is: /usr/games/mame looping
[Fri Jan 2 12:27:52 2015]: ******** Begin command output


I was editing the /usr/local/share/wahcade/win_main.py as following and looks ok.
Code: Select all
        if not self.debug_mode:
            self.log_msg('******** Command from Wah!Cade is:  %s ' % cmd)
            #redirect output to log file
            self.log_msg('******** Begin command output')
            if sys.platform == 'win32':
                #cmd = '%s >> %s' % (cmd, self.self.log_filename)
                cmd = '%s >> %s' % (cmd, self.log_filename)
            else:
                #cmd = '%s >> %s 2>&1' % (cmd, self.self.log_filename)
                cmd = '%s >> %s 2>&1' % (cmd, self.log_filename)
nfc.labs
 
Posts: 1
Joined: Fri Jan 02, 2015 12:14 pm

Re: Error on Exit

Postby sairuk » Sun Jan 04, 2015 12:00 am

Hrrmm, how did that happen?? that is definitely not correct and creeped in with commit 154.

Thanks for letting us know.

Registering bugs on launchpad is the same as any project, the intent with leaving 'Mah!Cade' on launchpad was for it to be merged with the main project eventually. Just register bugs alongside the main project and list which version you are using. we'll work through it from there.
mameau - My random bits | Wah!Ki - A Wah!Cade wiki | Mah!Cade - Experimental Wah!cade Branch | ListGen | Lazarus
User avatar
sairuk
 
Posts: 432
Joined: Sat May 22, 2010 12:37 am


Return to Wah!Cade

Who is online

Users browsing this forum: No registered users and 2 guests

cron