コード例 #1
0
    def test_revisions(self):
        original_title = 'Revisions test'
        post = WordPressPost()
        post.title = original_title
        post.slug = 'revisions-test'
        post.content = 'This is a test post using the XML-RPC API.'
        post_id = self.client.call(posts.NewPost(post))
        self.assertTrue(post_id)

        post.title = 'Revisions test updated'
        post.content += ' This is a second revision.'
        response = self.client.call(posts.EditPost(post_id, post))
        self.assertTrue(response)

        # test wp.getRevisions
        revision_list = self.client.call(posts.GetRevisions(post_id, ['post']))
        self.assert_list_of_classes(revision_list, WordPressPost)

        # workaround for WP bug #22686/22687
        # an auto-draft revision will survive wp.newPost, so pick the 2nd revision
        self.assertEqual(2, len(revision_list))
        real_rev = revision_list[1]
        self.assertTrue(real_rev)
        self.assertNotEquals(post_id, real_rev.id)

        # test wp.restoreRevision
        response2 = self.client.call(posts.RestoreRevision(real_rev.id))
        self.assertTrue(response2)
        post2 = self.client.call(posts.GetPost(post_id))
        self.assertEquals(original_title, post2.title)

        # cleanup
        self.client.call(posts.DeletePost(post_id))
コード例 #2
0
    def test_category_post(self):
        # create a test post
        post = WordPressPost()
        post.title = 'Test Post'
        post.slug = 'test-post'
        post.user = self.userid
        post.id = self.client.call(posts.NewPost(post))

        # create a test category
        cat = WordPressTerm()
        cat.name = 'Test Category'
        cat.taxonomy = 'category'
        cat.id = self.client.call(taxonomies.NewTerm(cat))

        # set category on post
        try:
            post.terms = [cat]
            response = self.client.call(posts.EditPost(post.id, post))
            self.assertTrue(response)

            # fetch categories for the post to verify
            post2 = self.client.call(posts.GetPost(post.id, ['terms']))
            post_cats = post2.terms
            self.assert_list_of_classes(post_cats, WordPressTerm)
            self.assertEqual(post_cats[0].id, cat.id)
        finally:
            # cleanup
            self.client.call(taxonomies.DeleteTerm(cat.taxonomy, cat.id))
            self.client.call(posts.DeletePost(post.id))
コード例 #3
0
    def test_post_lifecycle(self):
        # create a post object
        post = WordPressPost()
        post.title = 'Test post'
        post.slug = 'test-post'
        post.content = 'This is test post using the XML-RPC API.'
        post.comment_status = 'open'
        post.user = self.userid

        # create the post as a draft
        post_id = self.client.call(posts.NewPost(post))
        self.assertTrue(post_id)

        # fetch the newly-created post
        post2 = self.client.call(posts.GetPost(post_id))
        self.assertTrue(isinstance(post2, WordPressPost))
        self.assertEqual(str(post2.id), post_id)

        # update the post
        post2.content += '<br><b>Updated:</b> This post has been updated.'
        post2.post_status = 'publish'
        response = self.client.call(posts.EditPost(post_id, post2))
        self.assertTrue(response)

        # delete the post
        response = self.client.call(posts.DeletePost(post_id))
        self.assertTrue(response)
コード例 #4
0
def remove_template_files(file_name):
	try:
		os.remove(sass_directory + '_'+ file_name + '.scss')
	except:
		print sass_directory + '_'+ file_name + '.scss already deleted'
	try:
		os.removedirs(image_directory + file_name)
	except:
		print image_directory + file_name + ' already deleted'
	try:
		os.remove(page_template_directory + file_name + '.php')
	except:
		print page_template_directory + file_name + '.php already deleted'

	file_lines = []
	with open('assets/scss/foundation.scss') as f:
		content = f.readlines()
		for line in content:
			if('@import "templates/'+file_name+'"' in line):
				continue
			else:
				file_lines.append(line)

	f = open('assets/scss/foundation.scss','w')
	f.writelines(file_lines)
	f.close()
	page_id = find_id(file_name.capitalize())
	client = Client(site_host + 'xmlrpc.php', username, password)
	client.call(posts.DeletePost(page_id))
コード例 #5
0
def pedir_id_para_eliminar():
    limpiar_pantalla()
    id_entrada_eliminar = int(input("Introduce el ID de la entrada que deseas eliminar [-1 para salir] "))
    if id_entrada_eliminar != -1:
        print("Eliminando entrada con el id {}".format(id_entrada_eliminar))
        resultado = cliente.call(posts.DeletePost(id_entrada_eliminar))
        if resultado is True:
            input("Eliminado correctamente")
        else:
            input("Algo salió mal")
    imprimir_menu_opciones()
コード例 #6
0
def wp_truncate():
    client = Client(os.getenv('SCRAPY_WP_RPCURL'),
                    os.getenv('SCRAPY_WP_USERNAME'),
                    os.getenv('SCRAPY_WP_PASSWORD'))
    while 1:
        posts_slice = client.call(posts.GetPosts())
        if len(posts_slice):
            for p in posts_slice:
                client.call(posts.DeletePost(p.id))
        else:
            break
コード例 #7
0
def delete_all_post(client):

        allposts = client.call(posts.GetPosts({'number': 1765})) # add the number of total post on the web

        id_list = []
        for post in allposts:
            id_list.append(post.id)

        for item in id_list:
            check = client.call(posts.DeletePost(item))
            print(str(check))
コード例 #8
0
ファイル: delete.py プロジェクト: michaelyang/SmochiMusic
def main():
    postList = getPostList()
    for post in postList:
        success = wp.call(posts.DeletePost(post.id))
        if (success is True):
            with connection.cursor() as cursor:
                sql = 'UPDATE `upload_info` SET published = 0 where post_id = %s'
                cursor.execute(sql, (post.id))
                connection.commit()
        else:
            print('Couldn\'t delete ' + post.id)
    connection.close()
コード例 #9
0
def delete_post(wp_post_id):
    user = current_user
    client = check_login(user.wp_url, user.wp_username, login_session['pw'])
    wp_post = client.call(posts.GetPost(wp_post_id))
    if request.method == 'POST':
        client.call(posts.DeletePost(wp_post_id))
        flash('Post deleted successfully')
        return redirect(url_for('get_posts'))
    else:
        return render_template('posts/deletepost.html',
                               wp_post_id=wp_post_id,
                               post=wp_post)
コード例 #10
0
    def test_page_parent(self):
        parent_page = WordPressPage()
        parent_page.title = 'Parent page'
        parent_page.content = 'This is the parent page'
        parent_page.id = self.client.call(posts.NewPost(parent_page))
        self.assertTrue(parent_page.id)

        child_page = WordPressPage()
        child_page.title = 'Child page'
        child_page.content = 'This is the child page'
        child_page.parent_id = parent_page.id
        child_page.id = self.client.call(posts.NewPost(child_page))
        self.assertTrue(child_page.id)

        # re-fetch to confirm parent_id worked
        child_page2 = self.client.call(posts.GetPost(child_page.id))
        self.assertTrue(child_page2)
        self.assertEquals(child_page.parent_id, child_page2.parent_id)

        # cleanup
        self.client.call(posts.DeletePost(parent_page.id))
        self.client.call(posts.DeletePost(child_page.id))
コード例 #11
0
def delete_post_from_one_category(client):

        allposts = client.call(posts.GetPosts({'number': 1274})) # add the number of total post on the web
        delete_list = []

        for post in allposts:

            cat_list = []
            for term in post.terms:
                cat_list.append(str(term))

            if 'tourist site' in cat_list:
                delete_list.append(post.id)
         #       print(cat_list)

        print(len(delete_list))

        for item in delete_list:
            check = client.call(posts.DeletePost(item))
            print(str(check))
コード例 #12
0
    def test_page_lifecycle(self):
        page = WordPressPage()
        page.title = 'Test Page'
        page.content = 'This is my test page.'

        # create the page
        page_id = self.client.call(posts.NewPost(page))
        self.assertTrue(page_id)

        # fetch the newly created page
        page2 = self.client.call(
            posts.GetPost(page_id, results_class=WordPressPage))
        self.assertTrue(isinstance(page2, WordPressPage))
        self.assertEqual(str(page2.id), page_id)

        # edit the page
        page2.content += '<br><b>Updated:</b> This page has been updated.'
        response = self.client.call(posts.EditPost(page_id, page2))
        self.assertTrue(response)

        # delete the page
        response = self.client.call(posts.DeletePost(page_id))
        self.assertTrue(response)
コード例 #13
0
ファイル: upload.py プロジェクト: dklenowski/scripts
def delete(postid):
  logging.info("deleting post with id %s" % postid)
  wp_client.call(posts.DeletePost(postid))
コード例 #14
0
 def tearDown(self):
     self.client.call(posts.DeletePost(self.post_id))
     super(WordPressTestCase, self).tearDown()
コード例 #15
0
    def deleteImage(self):
        """ 
       
        Delets Images.
        -------              
      
        This function deletes images in regard with the maxpost setting, that definies
        how many images are stored in the cms database. Per default, the oldest Images will be deleted
        due to the ORDER_DIRECTION = 'ASC' Constant.
        -------      

        Parameters: 
        -------              
        no parameter allowed (except self)        
      
        Returns: 
        -------              
        nothing will be returned. 
      
        """

        # Authentication
        authenticator = Authenticator.Authenticator()
        credentials = authenticator.obtainCredentials(User.User())
        self.cms = authenticator.isValid(credentials)

        amount = OFFSET
        while True:
            ## Get posts serverfriendly
            if 'post_type' in self.post_configuration.postBasicInformation:
                self.images = self.cms.call(
                    posts.GetPosts({
                        'post_type':
                        self.post_configuration.postBasicInformation.get(
                            'post_type'),
                        'number':
                        INCREMENT,
                        'offset':
                        amount,
                        'orderby':
                        ORDERBY_FIELD,
                        'order':
                        ORDER_DIRECTION
                    }))

            # Delete the oldest post
            for image in self.images:
                if len(self.images
                       ) > self.post_configuration.postBasicInformation.get(
                           'maxposts'):
                    del self.images[-1]
                    self.cms.call(posts.DeletePost(image.id))

                else:
                    return

            amount = amount + INCREMENT


#==========================================================================
# END
#==========================================================================