/usr/share/pyshared/gwibber/microblog/uploader/__init__.py is in gwibber-service 3.4.0-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | import imageshack, ubuntuone_uploader
from gi.repository import Gio
IMAGESHACK_KEY = "168DEFKRd9cb284c67a29e715a3abcd19d3884a7"
gsettings = Gio.Settings.new("org.gwibber.preferences")
def upload_imageshack(path, uploader, success_callback, failure_callback):
u = imageshack.Uploader(IMAGESHACK_KEY)
try:
if path.startswith("http://"):
imgUrl = u.uploadURL(path)
else:
imgUrl = u.uploadFile(path)
if uploader == "imageshack":
img = imgUrl.split('image_link')[1].split('>')[1].split('<')[0]
else:
img = imgUrl.split('yfrog_link')[1].split('>')[1].split('<')[0]
except imageshack.ServerException, e:
print str(e)
img = None
failure_callback(path, str(e))
else:
success_callback(path, img)
def upload_ubuntuone(path, success_callback, failure_callback):
try:
u = ubuntuone_uploader.Uploader(success_callback, failure_callback)
if path.startswith("http://") or path.startswith("https://"):
raise Exception("Cannot publish web URLs to Ubuntu One")
u.uploadFile(path) # u will call success_callback or failure_callback
except e:
failure_callback(path, str(e))
def upload(path, success_callback, failure_callback):
uploader = gsettings.get_string("image-uploader") or "imageshack"
if uploader == "imageshack" or uploader == "yfrog":
return upload_imageshack(path, uploader, success_callback, failure_callback)
elif uploader == "ubuntuone":
return upload_ubuntuone(path, success_callback, failure_callback)
return upload_imageshack(path)
|