changeset 885261472f0d in /home/hg/repos/gajim-plugins
author: Linus Heckemann <[email protected]>
branches: gtk3
details:gajim-plugins?cmd=changeset;node=885261472f0d
description: httpupload: Improve error handling
- An error during the upload now no longer hangs everything (GUI
changes placed
in main thread)
- Some formatting changes
- Update version in manifest (I think a new minor version is in order
for GTK3
support!)
- Add self to authors in manifest (shameless plugs, whoop whoop)
- Remove claim of supporting older versions of gajim
diffstat:
httpupload/httpupload.py | 28 ++++++++++++++++++----------
httpupload/manifest.ini | 5 +++--
2 files changed, 21 insertions(+), 12 deletions(-)
diffs (93 lines):
diff -r b6ea6f5bdd96 -r 885261472f0d httpupload/httpupload.py
--- a/httpupload/httpupload.py Sat Aug 20 00:09:14 2016 +0200
+++ b/httpupload/httpupload.py Sat Aug 20 00:30:17 2016 +0200
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
##
-from gi.repository import GObject, Gtk
+from gi.repository import GObject, Gtk, GLib
import os
+import sys
import time
from urllib.request import Request, urlopen
import mimetypes # better use the magic packet, but that's not a
standard lib
@@ -322,7 +323,7 @@
def upload_complete(response_code):
if response_code == 0:
return # Upload was aborted
- if response_code >= 200 and response_code < 300:
+ if 200 <= response_code < 300:
log.info("Upload completed successfully")
xhtml = None
is_image = mime_type.split('/', 1)[0] == 'image'
@@ -354,13 +355,20 @@
_('Got unexpected http response code from
server: ') + str(response_code),
transient_for=self.chat_control.parent_win.window)
+ def on_upload_error():
+ progress_window.close_dialog()
+ ErrorDialog(_('Could not upload file'),
+ _('Got unexpected exception while uploading file'
+ ' (see error log for more information)'),
+ transient_for=self.chat_control.parent_win.window)
+ return 0
+
def uploader():
progress_messages.put(_('Uploading file via HTTP...'))
try:
headers = {'User-Agent': 'Gajim %s' % gajim.version,
'Content-Type': mime_type}
- request = Request(put.getData(), data=data,
headers=headers)
- request.get_method = lambda: 'PUT'
+ request = Request(put.getData(), data=data,
headers=headers, method='PUT')
log.debug("opening urllib upload request...")
transfer = urlopen(request, timeout=30)
data.close()
@@ -369,11 +377,8 @@
except UploadAbortedException:
log.info("Upload aborted")
except:
- progress_window.close_dialog()
- ErrorDialog(_('Could not upload file'),
- _('Got unexpected exception while uploading
file (see error log for more information)'),
-
transient_for=self.chat_control.parent_win.window)
- raise # fill error log with useful information
+ log.error("Exception during upload",
exc_info=sys.exc_info())
+ GLib.idle_add(on_upload_error)
return 0
log.info("Uploading file to '%s'..." % str(put.getData()))
@@ -383,7 +388,10 @@
is_supported = gajim.get_jid_from_account(self.chat_control.account)
in jid_to_servers and \
gajim.connections[self.chat_control.account].connection !=
None
- log.info("jid_to_servers of %s: %s ; connection: %s" %
(gajim.get_jid_from_account(self.chat_control.account),
str(jid_to_servers[gajim.get_jid_from_account(self.chat_control.account)]),
str(gajim.connections[self.chat_control.account].connection)))
+ log.info("jid_to_servers of %s: %s ; connection: %s",
+ gajim.get_jid_from_account(self.chat_control.account),
+
str(jid_to_servers[gajim.get_jid_from_account(self.chat_control.account)]),
+ str(gajim.connections[self.chat_control.account].connection))
if not is_supported:
progress_window.close_dialog()
log.error("upload component vanished, account got disconnected??")
diff -r b6ea6f5bdd96 -r 885261472f0d httpupload/manifest.ini
--- a/httpupload/manifest.ini Sat Aug 20 00:09:14 2016 +0200
+++ b/httpupload/manifest.ini Sat Aug 20 00:30:17 2016 +0200
@@ -1,7 +1,7 @@
[info]
name: HttpUpload
short_name: httpupload
-version: 0.4.0
+version: 0.5.0
description: This plugin is designed to send a file to a contact or muc by
using httpupload.<br/>
Your server must support <a
href="http://xmpp.org/extensions/xep-0363.html">XEP-0363: HTTP Upload</a>.<br/>
Conversations supported this.<br/>
@@ -11,6 +11,7 @@
authors: Thilo Molitor <[email protected]>
Anders Sandblad <[email protected]>
Philipp Hörist <[email protected]>
+ Linus Heckemann <[email protected]>
homepage: https://trac-plugins.gajim.org/wiki/HttpUploadPlugin
-min_gajim_version: 0.16.5
+min_gajim_version: 0.16.10
max_gajim_version: 0.16.10.1
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits