~bmerry/duplicity/pydrive-regular

« back to all changes in this revision

Viewing changes to duplicity/backends/gdocsbackend.py

  • Committer: Michael Terry
  • Date: 2014-04-17 20:50:57 UTC
  • mto: This revision was merged to the branch mainline in revision 975.
  • Revision ID: michael.terry@canonical.com-20140417205057-4cxo1yebh0oer02a
Solve except 2to3 fix

Show diffs side-by-side

added added

removed removed

Lines of Context:
113
113
                self.__handle_error("Failed to initialize upload of file '%s' to remote folder '%s'"
114
114
                         % (source_path.get_filename(), self.folder.title.text), raise_errors)
115
115
            assert not file.close()
116
 
        except Exception, e:
 
116
        except Exception as e:
117
117
            self.__handle_error("Failed to upload file '%s' to remote folder '%s': %s"
118
118
                                % (source_path.get_filename(), self.folder.title.text, str(e)), raise_errors)
119
119
 
132
132
            else:
133
133
                self.__handle_error("Failed to find file '%s' in remote folder '%s'"
134
134
                                    % (remote_filename, self.folder.title.text), raise_errors)
135
 
        except Exception, e:
 
135
        except Exception as e:
136
136
            self.__handle_error("Failed to download file '%s' in remote folder '%s': %s"
137
137
                                 % (remote_filename, self.folder.title.text, str(e)), raise_errors)
138
138
 
143
143
            entries = self.__fetch_entries(self.folder.resource_id.text,
144
144
                                           GDocsBackend.BACKUP_DOCUMENT_TYPE)
145
145
            return [entry.title.text for entry in entries]
146
 
        except Exception, e:
 
146
        except Exception as e:
147
147
            self.__handle_error("Failed to fetch list of files in remote folder '%s': %s"
148
148
                                % (self.folder.title.text, str(e)), raise_errors)
149
149
 
166
166
                else:
167
167
                    log.Warn("Failed to fetch file '%s' in remote folder '%s'"
168
168
                             % (filename, self.folder.title.text))
169
 
            except Exception, e:
 
169
            except Exception as e:
170
170
                self.__handle_error("Failed to remove file '%s' in remote folder '%s': %s"
171
171
                                    % (filename, self.folder.title.text, str(e)), raise_errors)
172
172
 
184
184
                                     service='writely',
185
185
                                     captcha_token=captcha_token,
186
186
                                     captcha_response=captcha_response)
187
 
        except gdata.client.CaptchaChallenge, challenge:
 
187
        except gdata.client.CaptchaChallenge as challenge:
188
188
            print('A captcha challenge in required. Please visit ' + challenge.captcha_url)
189
189
            answer = None
190
190
            while not answer:
196
196
                                'access code for using this Duplicity backend. Follow the instrucction in '
197
197
                                'http://www.google.com/support/accounts/bin/static.py?page=guide.cs&guide=1056283&topic=1056286 '
198
198
                                'and create your application-specific password to run duplicity backups.')
199
 
        except Exception, e:
 
199
        except Exception as e:
200
200
            self.__handle_error('Error while authenticating client: %s.' % str(e))
201
201
 
202
202
    def __fetch_entries(self, folder_id, type, title=None):
238
238
 
239
239
            # Done!
240
240
            return result
241
 
        except Exception, e:
 
241
        except Exception as e:
242
242
            self.__handle_error('Error while fetching remote entries: %s.' % str(e))
243
243
 
244
244
duplicity.backend.register_backend('gdocs', GDocsBackend)