~duplicity-team/duplicity/0.7-series

« back to all changes in this revision

Viewing changes to duplicity/backends/giobackend.py

  • Committer: Kenneth Loafman
  • Date: 2014-12-12 14:39:54 UTC
  • Revision ID: kenneth@loafman.com-20141212143954-wyln65yd1ynzsrlx
* Source formatted, using PyDev, all source files to fix some easily fixed
  PEP8 issues. Use ignore space when comparing against previous versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
        for line in lines:
38
38
            parts = line.split('=', 1)
39
39
            if len(parts) == 2:
40
 
                if parts[0] == 'DBUS_SESSION_BUS_PID': # cleanup at end
 
40
                if parts[0] == 'DBUS_SESSION_BUS_PID':  # cleanup at end
41
41
                    atexit.register(os.kill, int(parts[1]), signal.SIGTERM)
42
42
                os.environ[parts[0]] = parts[1]
43
43
 
47
47
       URLs look like schema://user@server/path.
48
48
    """
49
49
    def __init__(self, parsed_url):
50
 
        from gi.repository import Gio #@UnresolvedImport
51
 
        from gi.repository import GLib #@UnresolvedImport
 
50
        from gi.repository import Gio  # @UnresolvedImport
 
51
        from gi.repository import GLib  # @UnresolvedImport
52
52
 
53
53
        class DupMountOperation(Gio.MountOperation):
54
54
            """A simple MountOperation that grabs the password from the environment
86
86
        self.remote_file.mount_enclosing_volume(Gio.MountMountFlags.NONE,
87
87
                                                op, None,
88
88
                                                self.__done_with_mount, loop)
89
 
        loop.run() # halt program until we're done mounting
 
89
        loop.run()  # halt program until we're done mounting
90
90
 
91
91
        # Now make the directory if it doesn't exist
92
92
        try:
96
96
                raise
97
97
 
98
98
    def __done_with_mount(self, fileobj, result, loop):
99
 
        from gi.repository import Gio #@UnresolvedImport
100
 
        from gi.repository import GLib #@UnresolvedImport
 
99
        from gi.repository import Gio  # @UnresolvedImport
 
100
        from gi.repository import GLib  # @UnresolvedImport
101
101
        try:
102
102
            fileobj.mount_enclosing_volume_finish(result)
103
103
        except GLib.GError as e:
111
111
        pass
112
112
 
113
113
    def __copy_file(self, source, target):
114
 
        from gi.repository import Gio #@UnresolvedImport
 
114
        from gi.repository import Gio  # @UnresolvedImport
115
115
        source.copy(target,
116
116
                    Gio.FileCopyFlags.OVERWRITE | Gio.FileCopyFlags.NOFOLLOW_SYMLINKS,
117
117
                    None, self.__copy_progress, None)
118
118
 
119
119
    def _error_code(self, operation, e):
120
 
        from gi.repository import Gio #@UnresolvedImport
121
 
        from gi.repository import GLib #@UnresolvedImport
 
120
        from gi.repository import Gio  # @UnresolvedImport
 
121
        from gi.repository import GLib  # @UnresolvedImport
122
122
        if isinstance(e, GLib.GError):
123
123
            if e.code == Gio.IOErrorEnum.FAILED and operation == 'delete':
124
124
                # Sometimes delete will return a generic failure on a file not
132
132
                return log.ErrorCode.backend_no_space
133
133
 
134
134
    def _put(self, source_path, remote_filename):
135
 
        from gi.repository import Gio #@UnresolvedImport
 
135
        from gi.repository import Gio  # @UnresolvedImport
136
136
        source_file = Gio.File.new_for_path(source_path.name)
137
137
        target_file = self.remote_file.get_child(remote_filename)
138
138
        self.__copy_file(source_file, target_file)
139
139
 
140
140
    def _get(self, filename, local_path):
141
 
        from gi.repository import Gio #@UnresolvedImport
 
141
        from gi.repository import Gio  # @UnresolvedImport
142
142
        source_file = self.remote_file.get_child(filename)
143
143
        target_file = Gio.File.new_for_path(local_path.name)
144
144
        self.__copy_file(source_file, target_file)
145
145
 
146
146
    def _list(self):
147
 
        from gi.repository import Gio #@UnresolvedImport
 
147
        from gi.repository import Gio  # @UnresolvedImport
148
148
        files = []
149
149
        enum = self.remote_file.enumerate_children(Gio.FILE_ATTRIBUTE_STANDARD_NAME,
150
150
                                                   Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
160
160
        target_file.delete(None)
161
161
 
162
162
    def _query(self, filename):
163
 
        from gi.repository import Gio #@UnresolvedImport
 
163
        from gi.repository import Gio  # @UnresolvedImport
164
164
        target_file = self.remote_file.get_child(filename)
165
165
        info = target_file.query_info(Gio.FILE_ATTRIBUTE_STANDARD_SIZE,
166
166
                                      Gio.FileQueryInfoFlags.NONE, None)