/usr/lib/python2.7/dist-packages/gnomeblog/blog.py is in gnome-blog 0.9.1-7.
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | import gconf
class FeatureNotSupported(Exception):
def __init__(self, unknownMethod):
Exception.__init__(self, "Blog protocol does not support '%s'" % (unknownMethod))
def getBlogList (gconf_prefix):
client = gconf.client_get_default()
username, password, protocol, url = _getSettings(client, gconf_prefix)
blog_backend = _getBlogBackend(protocol)
try:
return blog_backend.getBlogList(username, password, url, client, gconf_prefix)
except AttributeError, e:
raise FeatureNotSupported("getBlogList")
def postEntry (title, entry, gconf_prefix):
client = gconf.client_get_default()
username, password, protocol, url = _getSettings(client, gconf_prefix)
blog_backend = _getBlogBackend(protocol)
return blog_backend.postEntry(username, password,
url, title, entry,
client, gconf_prefix)
def uploadImage (image, gconf_prefix):
client = gconf.client_get_default()
username, password, protocol, url = _getSettings(client, gconf_prefix)
blog_backend = _getBlogBackend(protocol)
try:
imageurl = blog_backend.uploadImage(username, password,
url,
image.name,
image.file_contents,
image.mime_type,
client, gconf_prefix)
if imageurl == None:
raise FeatureNotSupported("uploadImage")
except AttributeError, e:
raise FeatureNotSupported("uploadImage")
return imageurl
def _getSettings(client, gconf_prefix):
print "Using prefix %s" % (gconf_prefix)
username = client.get_string(gconf_prefix + "/blog_username")
password = client.get_string(gconf_prefix + "/blog_password")
protocol = client.get_string(gconf_prefix + "/blog_protocol")
url = client.get_string(gconf_prefix + "/xmlrpc_url")
if not username:
import hig_alert
hig_alert.reportError("Error: no username given", "please use the Preferences window to set a username and a password")
return
if not password:
import hig_alert
hig_alert.reportError("Error: no password given", "please use the Preferences window to set a password")
return
if not url:
import hig_alert
hig_alert.reportError("Error: no url given", "please use the Preferences window to set an URL")
return
return username, password, protocol, url
def _getBlogBackend(protocol):
modulename = "gnomeblog.%s" % (protocol)
protocolModule = __import__(modulename, globals(), locals(), ['blog'])
return protocolModule.blog
|