mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
Fixed audio upload dialog
This commit is contained in:
parent
2268619101
commit
8988d63f33
@ -102,7 +102,7 @@ class basicTweet(object):
|
|||||||
self.message.text_focus()
|
self.message.text_focus()
|
||||||
|
|
||||||
def attach(self, *args, **kwargs):
|
def attach(self, *args, **kwargs):
|
||||||
def completed_callback():
|
def completed_callback(dlg):
|
||||||
url = dlg.uploaderFunction.get_url()
|
url = dlg.uploaderFunction.get_url()
|
||||||
pub.unsubscribe(dlg.uploaderDialog.update, "uploading")
|
pub.unsubscribe(dlg.uploaderDialog.update, "uploading")
|
||||||
dlg.uploaderDialog.destroy()
|
dlg.uploaderDialog.destroy()
|
||||||
|
@ -57,13 +57,13 @@ class audioUploader(object):
|
|||||||
url = base_url + '?apikey=' + self.config['sound']['sndup_api_key']
|
url = base_url + '?apikey=' + self.config['sound']['sndup_api_key']
|
||||||
else:
|
else:
|
||||||
url = base_url
|
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":
|
elif self.dialog.get("services") == "TwUp":
|
||||||
url = "http://api.twup.me/post.json"
|
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")
|
pub.subscribe(self.uploaderDialog.update, "uploading")
|
||||||
self.uploaderDialog.get_response()
|
self.uploaderDialog.get_response(self.uploaderFunction.perform_threaded)
|
||||||
self.uploaderFunction.perform_threaded()
|
# self.uploaderFunction.perform_threaded()
|
||||||
|
|
||||||
def get_available_services(self):
|
def get_available_services(self):
|
||||||
services = []
|
services = []
|
||||||
|
@ -11,7 +11,7 @@ from pubsub import pub
|
|||||||
log = logging.getLogger("extra.AudioUploader.transfer")
|
log = logging.getLogger("extra.AudioUploader.transfer")
|
||||||
class Transfer(object):
|
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.url = url
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
log.debug("Uploading audio to %s, filename %s" % (url, 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.FOLLOWLOCATION, int(follow_location))
|
||||||
self.curl.setopt(self.curl.VERBOSE, int(verbose))
|
self.curl.setopt(self.curl.VERBOSE, int(verbose))
|
||||||
super(Transfer, self).__init__(*args, **kwargs)
|
super(Transfer, self).__init__(*args, **kwargs)
|
||||||
|
self.obj = obj
|
||||||
|
|
||||||
def elapsed_time(self):
|
def elapsed_time(self):
|
||||||
if not self.start_time:
|
if not self.start_time:
|
||||||
@ -61,7 +62,7 @@ class Transfer(object):
|
|||||||
log.debug("Upload finished.")
|
log.debug("Upload finished.")
|
||||||
self.complete_transfer()
|
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 = threading.Thread(target=self.perform_transfer)
|
||||||
self.background_thread.daemon = True
|
self.background_thread.daemon = True
|
||||||
self.background_thread.start()
|
self.background_thread.start()
|
||||||
@ -69,7 +70,7 @@ class Transfer(object):
|
|||||||
def complete_transfer(self):
|
def complete_transfer(self):
|
||||||
if callable(self.completed_callback):
|
if callable(self.completed_callback):
|
||||||
self.curl.close()
|
self.curl.close()
|
||||||
self.completed_callback()
|
self.completed_callback(self.obj)
|
||||||
|
|
||||||
class Upload(Transfer):
|
class Upload(Transfer):
|
||||||
|
|
||||||
|
@ -56,8 +56,9 @@ class TransferDialog(widgetUtils.BaseDialog):
|
|||||||
def create_buttons(self):
|
def create_buttons(self):
|
||||||
self.cancel_button = wx.Button(parent=self.pane, id=wx.ID_CANCEL)
|
self.cancel_button = wx.Button(parent=self.pane, id=wx.ID_CANCEL)
|
||||||
|
|
||||||
def get_response(self):
|
def get_response(self, fn):
|
||||||
self.Show()
|
wx.CallAfter(fn, 0.01)
|
||||||
|
self.ShowModal()
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
self.Destroy()
|
self.Destroy()
|
||||||
|
Loading…
Reference in New Issue
Block a user