Ejemplo n.º 1
0
    def postEntry (self, username, password, base_url, title, entry, keywords, client, gconf_prefix):
        global appkey

        url = self._getURL(base_url, client, gconf_prefix)
        
        if (base_url == None):
            hig_alert.reportError(_("Could not post Blog entry"), _("No XML-RPC server URL to post blog entries to is set, or the value could not be retrieved from GConf. Your entry will remain in the blogger window."))
            return False

        blog_id  = client.get_string(gconf_prefix + "/blog_id")

        if (blog_id == None):
            blog_id = ""

        if (username == None):
            username = ""

        if (password == None):
            password = ""
            
        content = title + "\n" + entry
        success = True

        #check for GNOME proxy configurations and use if required
        proxy_transport = proxy.GnomeProxyTransport(client)
        server = proxy_transport.get_server(url); 

        try:
            server.blogger.newPost(appkey, blog_id, username, password,
                                   content, xmlrpclib.True)
        except xmlrpclib.Fault, e:
            hig_alert.handleBloggerAPIFault(e, _("Could not post blog entry"), username, blog_id, url)
            success = False
Ejemplo n.º 2
0
    def postEntry (self, username, password, base_url, title,
                   entry, keywords, client, gconf_prefix):

        url = self._getURL(base_url, client, gconf_prefix)

        if (base_url == None):
            hig_alert.reportError("Could not post Blog entry", "No XML-RPC server URL to post blog entries to is set, or the value could not be retrieved from GConf. Your entry will remain in the blogger window.")
            return False

        blog_id  = client.get_string(gconf_prefix + "/blog_id")

        success = True

        #check for GNOME proxy configurations and use if required
        proxy_transport = proxy.GnomeProxyTransport(client)
        server = proxy_transport.get_server(url);

        content = {}
        content['title'] = title
        content['description'] = entry
	content['mt_keywords'] = keywords

        try:
            server.metaWeblog.newPost(blog_id, username, password, content, xmlrpclib.True)
        except xmlrpclib.Fault, e:
            hig_alert.handleBloggerAPIFault(e, "Could not post blog entry", username, blog_id, url)
            success = False
Ejemplo n.º 3
0
    def getBlogList(self, username, password, base_url, client, gconf_prefix):
        global appkey
        
        url = self._getURL(base_url, client, gconf_prefix)

        print ("Getting list for RPC interface %s" % (url))
        
        #check for GNOME proxy configurations and use if required
        proxy_transport = proxy.GnomeProxyTransport(client)
        server = proxy_transport.get_server(url); 

        try:
            bloglist = server.blogger.getUsersBlogs(appkey, username, password)
        except xmlrpclib.Fault, e:
            hig_alert.handleBloggerAPIFault(e, _("Could not get list of blogs"), username, None, url)
            return
Ejemplo n.º 4
0
    def uploadImage (self, username, password, base_url,
                     file_name, file_contents, mime_type, client, gconf_prefix):

        url = self._getURL(base_url, client, gconf_prefix)

        blog_id  = client.get_string(gconf_prefix + "/blog_id")

        success = True
        
        #check for GNOME proxy configurations and use if required
        proxy_transport = proxy.GnomeProxyTransport(client)
        server = proxy_transport.get_server(url); 

        content = {}
        content['name'] = file_name
        content['type'] = mime_type
        content['bits'] = xmlrpclib.Binary(file_contents)

        imageurl = None

        try:
            imageurl = (server.metaWeblog.newMediaObject(blog_id, username, password, content))['url']
        except xmlrpclib.Fault, e:
            hig_alert.handleBloggerAPIFault(e, "Could not post Image", username, blog_id, url)