~ubuntu-branches/ubuntu/precise/ubuntuone-client/precise

« back to all changes in this revision

Viewing changes to ubuntuone/platform/linux/__init__.py

  • Committer: Package Import Robot
  • Author(s): Rodney Dawes
  • Date: 2011-12-21 15:46:25 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20111221154625-ujvunri4frsecj2k
Tags: 2.99.0-0ubuntu1
* New upstream release.
  - Verify timestamp to avoid invalid auth failures (LP: #692597)
  - Files in new UDFs not uploaded due to filtering (LP: #869920)
* debian/patches:
  - Remove upstreamed patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# ubuntuone.platform.linux - linux platform imports
2
2
#
3
 
# Author: Lucio Torre <lucio.torre@canonical.com>
4
 
#
5
 
# Copyright 2009 Canonical Ltd.
 
3
# Copyright 2009-2011 Canonical Ltd.
6
4
#
7
5
# This program is free software: you can redistribute it and/or modify it
8
6
# under the terms of the GNU General Public License version 3, as published
22
20
 
23
21
platform = "linux"
24
22
 
25
 
import dbus
26
 
from dbus.mainloop.glib import DBusGMainLoop
27
 
from twisted.internet import defer
28
23
 
29
24
from ubuntuone.platform.linux.os_helper import (
30
25
    access,
37
32
    make_dir,
38
33
    make_link,
39
34
    move_to_trash,
 
35
    native_rename,
40
36
    normpath,
41
37
    open_file,
42
38
    path_exists,
56
52
    stat_path,
57
53
    walk,
58
54
)
59
 
from ubuntuone.platform.linux.logger import setup_filesystem_logging, get_filesystem_logger
60
 
from ubuntuone.platform.linux.filesystem_notifications import FilesystemMonitor
61
 
from ubuntuone.platform.linux.notification import Notification
62
 
 
63
 
 
64
 
class ExternalInterface(object):
65
 
    """An ExternalInterface implemented with a DBus interface."""
66
 
 
67
 
    def __init__(self, main, glib_loop=False, broadcast_events=False,
68
 
                 dbus_iface=None):
69
 
        # avoid circular dependencies
70
 
 
71
 
        if dbus_iface is None:
72
 
            from ubuntuone.platform.linux import dbus_interface
73
 
            if not glib_loop:
74
 
                self.bus = dbus.SessionBus()
75
 
            else:
76
 
                loop = DBusGMainLoop(set_as_default=True)
77
 
                self.bus = dbus.SessionBus(loop)
78
 
 
79
 
            self.dbus_iface = dbus_interface.DBusInterface(
80
 
                self.bus, main, send_events=broadcast_events)
81
 
 
82
 
        else:
83
 
            self.dbus_iface = dbus_iface
84
 
            self.bus = None
85
 
 
86
 
    def _get_credentials(self):
87
 
        return self.dbus_iface.oauth_credentials
88
 
 
89
 
    def _set_credentials(self, credentials):
90
 
        self.dbus_iface.oauth_credentials = credentials
91
 
 
92
 
    oauth_credentials = property(fget=_get_credentials, fset=_set_credentials)
93
 
 
94
 
    def shutdown(self, with_restart):
95
 
        self.dbus_iface.shutdown(with_restart)
96
 
 
97
 
    def connect(self, *args, **kwargs):
98
 
        self.dbus_iface.connect(*args, **kwargs)
99
 
 
100
 
 
101
 
def is_already_running():
102
 
    """Check if there is another instance registered in DBus."""
103
 
    from ubuntuone.platform.linux import dbus_interface
104
 
    bus = dbus.SessionBus()
105
 
    request = bus.request_name(dbus_interface.DBUS_IFACE_NAME,
106
 
                               dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
107
 
    if request == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
108
 
        return defer.succeed(True)
109
 
    else:
110
 
        return defer.succeed(False)
 
55
from ubuntuone.platform.linux.logger import (
 
56
    setup_filesystem_logging,
 
57
    get_filesystem_logger,
 
58
)
 
59
from ubuntuone.platform.linux.filesystem_notifications import (
 
60
    FilesystemMonitor,
 
61
    _GeneralINotifyProcessor,
 
62
)
 
63
from ubuntuone.platform.linux import notification
 
64
from ubuntuone.platform.linux.dbus_interface import (
 
65
    DBusInterface as ExternalInterface,
 
66
    is_already_running,
 
67
)