mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Show error messages in failed audio uploads. Hopefully Fixes api uploads in sndup
This commit is contained in:
parent
3c0824aad4
commit
80cb5567d5
@ -10,6 +10,8 @@ import sound
|
||||
from pubsub import pub
|
||||
if system == "Windows":
|
||||
from wxUI.dialogs import message, urlList
|
||||
from wxUI import commonMessageDialogs
|
||||
|
||||
from extra import translator, SpellChecker, autocompletionUsers
|
||||
from extra.AudioUploader import audioUploader
|
||||
elif system == "Linux":
|
||||
@ -114,11 +116,12 @@ class basicTweet(object):
|
||||
url = dlg.uploaderFunction.get_url()
|
||||
pub.unsubscribe(dlg.uploaderDialog.update, "uploading")
|
||||
dlg.uploaderDialog.destroy()
|
||||
if url != 0:
|
||||
if "sndup.net/" in url:
|
||||
self.message.set_text(self.message.get_text()+url+" #audio")
|
||||
self.text_processor()
|
||||
else:
|
||||
output.speak(_(u"Unable to upload the audio"))
|
||||
commonMessageDialogs.common_error(url)
|
||||
|
||||
dlg.cleanup()
|
||||
dlg = audioUploader.audioUploader(self.session.settings, completed_callback)
|
||||
self.message.text_focus()
|
||||
|
@ -52,7 +52,7 @@ class audioUploader(object):
|
||||
self.uploaderDialog = wx_transfer_dialogs.UploadDialog(self.file)
|
||||
output.speak(_(u"Attaching..."))
|
||||
if self.dialog.get("services") == "SNDUp":
|
||||
base_url = "http://sndup.net/post.php"
|
||||
base_url = "https://sndup.net/post.php"
|
||||
if len(self.config["sound"]["sndup_api_key"]) > 0:
|
||||
url = base_url + '?apikey=' + self.config['sound']['sndup_api_key']
|
||||
else:
|
||||
|
@ -55,6 +55,7 @@ class Upload(object):
|
||||
def perform_transfer(self):
|
||||
log.debug("starting upload...")
|
||||
self.start_time = time.time()
|
||||
print self.url
|
||||
self.response=requests.post(url=self.url, data=self.monitor, headers={"Content-Type":self.m.content_type}, allow_redirects=self.follow_location, stream=True)
|
||||
log.debug("Upload finished.")
|
||||
self.complete_transfer()
|
||||
@ -69,5 +70,15 @@ class Upload(object):
|
||||
self.completed_callback(self.obj)
|
||||
if hasattr(self,'fin') and callable(self.fin.close):
|
||||
self.fin.close()
|
||||
|
||||
def get_url(self):
|
||||
return self.response.json()['url']
|
||||
try:
|
||||
data = self.response.json()
|
||||
except:
|
||||
return _("Error in file upload: {0}").format(self.data.content,)
|
||||
if data.has_key("url") and data["url"] != "0":
|
||||
return data["url"]
|
||||
elif data.has_key("error") and data["error"] != "0":
|
||||
return data["error"]
|
||||
else:
|
||||
return _("Error in file upload: {0}").format(self.data.content,)
|
@ -86,3 +86,6 @@ def delete_filter():
|
||||
|
||||
def existing_filter():
|
||||
return wx.MessageDialog(None, _(u"This filter already exists. Please use a different title"), _(u"Error"), wx.OK).ShowModal()
|
||||
|
||||
def common_error(reason):
|
||||
return wx.MessageDialog(None, reason, _(u"Error"), wx.OK).ShowModal()
|
Loading…
Reference in New Issue
Block a user