Merge lp:~dobey/ubuntuone-client/fix-711324 into lp:ubuntuone-client

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 1348
Merged at revision: 1348
Proposed branch: lp:~dobey/ubuntuone-client/fix-711324
Merge into: lp:ubuntuone-client
Diff against target: 73 lines (+27/-25)
1 file modified
bin/ubuntuone-login (+27/-25)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/fix-711324
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+130630@code.launchpad.net

Commit message

Trap DBusException to avoid errors when dbus session bus is not available.

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

looks good
+1

review: Approve
Revision history for this message
Mike McCracken (mikemc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-login'
2--- bin/ubuntuone-login 2012-10-15 20:12:29 +0000
3+++ bin/ubuntuone-login 2012-10-19 20:09:20 +0000
4@@ -1,8 +1,6 @@
5 #!/usr/bin/python
6 # -*- coding: utf-8 -*-
7 #
8-# Author: Natalia B. Bidart <natalia.bidart@canonical.com>
9-#
10 # Copyright 2010-2012 Canonical Ltd.
11 #
12 # This program is free software: you can redistribute it and/or modify it
13@@ -32,7 +30,6 @@
14 """The script tu ron the Ubuntu One Login D-Bus service."""
15
16 # Invalid name "ubuntuone-login"
17-# pylint: disable=C0103
18
19 import logging
20 import os
21@@ -54,25 +51,30 @@
22
23 if __name__ == "__main__":
24 # Register DBus service for making sure we run only one instance
25- bus = dbus.SessionBus()
26- name = bus.request_name(DBUS_BUS_NAME,
27- dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
28- if name == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
29- logger.error("Ubuntu One login manager already running, quitting.")
30- sys.exit(0)
31-
32- if os.environ.get('U1_DEBUG'):
33- debug_handler = logging.StreamHandler(sys.stderr)
34- debug_handler.setFormatter(basic_formatter)
35- debug_handler.setLevel(logging.DEBUG)
36- logger.setLevel(logging.DEBUG)
37- logger.addHandler(debug_handler)
38-
39- logger.info("Starting Ubuntu One login manager for bus %r.", DBUS_BUS_NAME)
40- bus_name = dbus.service.BusName(DBUS_BUS_NAME, bus=dbus.SessionBus())
41- mainloop = GLib.MainLoop()
42- CredentialsManagement(timeout_func=GLib.timeout_add,
43- shutdown_func=mainloop.quit,
44- bus_name=bus_name, object_path=DBUS_CREDENTIALS_PATH)
45-
46- mainloop.run()
47+ try:
48+ bus = dbus.SessionBus()
49+ name = bus.request_name(DBUS_BUS_NAME,
50+ dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
51+ if name == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
52+ logger.error("Ubuntu One login manager already running, quitting.")
53+ sys.exit(0)
54+ except dbus.DBusException:
55+ pass
56+ else:
57+ if os.environ.get('U1_DEBUG'):
58+ debug_handler = logging.StreamHandler(sys.stderr)
59+ debug_handler.setFormatter(basic_formatter)
60+ debug_handler.setLevel(logging.DEBUG)
61+ logger.setLevel(logging.DEBUG)
62+ logger.addHandler(debug_handler)
63+
64+ logger.info("Starting Ubuntu One login manager for bus %r.",
65+ DBUS_BUS_NAME)
66+ bus_name = dbus.service.BusName(DBUS_BUS_NAME, bus=bus)
67+ mainloop = GLib.MainLoop()
68+ CredentialsManagement(timeout_func=GLib.timeout_add,
69+ shutdown_func=mainloop.quit,
70+ bus_name=bus_name,
71+ object_path=DBUS_CREDENTIALS_PATH)
72+
73+ mainloop.run()

Subscribers

People subscribed via source and target branches