diff --git a/src/controller/messages.py b/src/controller/messages.py index 0a4aba36..ff64aaa8 100644 --- a/src/controller/messages.py +++ b/src/controller/messages.py @@ -102,7 +102,7 @@ class basicTweet(object): self.message.text_focus() def attach(self, *args, **kwargs): - def completed_callback(): + def completed_callback(dlg): url = dlg.uploaderFunction.get_url() pub.unsubscribe(dlg.uploaderDialog.update, "uploading") dlg.uploaderDialog.destroy() diff --git a/src/extra/AudioUploader/audioUploader.py b/src/extra/AudioUploader/audioUploader.py index 73299df6..4c62c5c7 100644 --- a/src/extra/AudioUploader/audioUploader.py +++ b/src/extra/AudioUploader/audioUploader.py @@ -57,13 +57,13 @@ class audioUploader(object): url = base_url + '?apikey=' + self.config['sound']['sndup_api_key'] else: url = base_url - self.uploaderFunction = transfer.Upload(field='file', url=url, filename=self.file, completed_callback=completed_callback) + self.uploaderFunction = transfer.Upload(obj=self, field='file', url=url, filename=self.file, completed_callback=completed_callback) elif self.dialog.get("services") == "TwUp": url = "http://api.twup.me/post.json" - self.uploaderFunction = transfer.Upload(field='file', url=url, filename=self.file, completed_callback=completed_callback) + self.uploaderFunction = transfer.Upload(obj=self, field='file', url=url, filename=self.file, completed_callback=completed_callback) pub.subscribe(self.uploaderDialog.update, "uploading") - self.uploaderDialog.get_response() - self.uploaderFunction.perform_threaded() + self.uploaderDialog.get_response(self.uploaderFunction.perform_threaded) +# self.uploaderFunction.perform_threaded() def get_available_services(self): services = [] diff --git a/src/extra/AudioUploader/transfer.py b/src/extra/AudioUploader/transfer.py index 2b80a94e..b8dc8b22 100644 --- a/src/extra/AudioUploader/transfer.py +++ b/src/extra/AudioUploader/transfer.py @@ -11,7 +11,7 @@ from pubsub import pub log = logging.getLogger("extra.AudioUploader.transfer") class Transfer(object): - def __init__(self, url=None, filename=None, follow_location=True, completed_callback=None, verbose=False, *args, **kwargs): + def __init__(self, obj=None, url=None, filename=None, follow_location=True, completed_callback=None, verbose=False, *args, **kwargs): self.url = url self.filename = filename log.debug("Uploading audio to %s, filename %s" % (url, filename)) @@ -27,6 +27,7 @@ class Transfer(object): self.curl.setopt(self.curl.FOLLOWLOCATION, int(follow_location)) self.curl.setopt(self.curl.VERBOSE, int(verbose)) super(Transfer, self).__init__(*args, **kwargs) + self.obj = obj def elapsed_time(self): if not self.start_time: @@ -61,7 +62,7 @@ class Transfer(object): log.debug("Upload finished.") self.complete_transfer() - def perform_threaded(self): + def perform_threaded(self, *args, **kwargs): self.background_thread = threading.Thread(target=self.perform_transfer) self.background_thread.daemon = True self.background_thread.start() @@ -69,7 +70,7 @@ class Transfer(object): def complete_transfer(self): if callable(self.completed_callback): self.curl.close() - self.completed_callback() + self.completed_callback(self.obj) class Upload(Transfer): diff --git a/src/extra/AudioUploader/wx_transfer_dialogs.py b/src/extra/AudioUploader/wx_transfer_dialogs.py index 18ecbd1c..035e0cc1 100644 --- a/src/extra/AudioUploader/wx_transfer_dialogs.py +++ b/src/extra/AudioUploader/wx_transfer_dialogs.py @@ -56,8 +56,9 @@ class TransferDialog(widgetUtils.BaseDialog): def create_buttons(self): self.cancel_button = wx.Button(parent=self.pane, id=wx.ID_CANCEL) - def get_response(self): - self.Show() + def get_response(self, fn): + wx.CallAfter(fn, 0.01) + self.ShowModal() def destroy(self): self.Destroy()