本文整理汇总了Python中wordpress_xmlrpc.WordPressPost.comment_status方法的典型用法代码示例。如果您正苦于以下问题:Python WordPressPost.comment_status方法的具体用法?Python WordPressPost.comment_status怎么用?Python WordPressPost.comment_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wordpress_xmlrpc.WordPressPost
的用法示例。
在下文中一共展示了WordPressPost.comment_status方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_file
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def post_file(wp, f, t, y, m, d):
p = WordPressPost()
p.title = t
p.content = slurp(f)
# 9am zulu is early Eastern-Pacific
p.date = p.date_modified = datetime(y,m,d,9)
p.post_status = 'publish'
p.comment_status = 'closed'
if wp:
wp.call(NewPost(p))
示例2: create_wordpress_draft
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def create_wordpress_draft(publish_target, title, html, tags):
post = WordPressPost()
today = datetime.date.today()
post.title = title
post.content = html
client = Client( publish_target["url"] + "/xmlrpc.php", publish_target["username"], publish_target["password"])
category = client.call(taxonomies.GetTerm('category', publish_target["default_category_id"]))
post.terms.append(category)
post.user = publish_target["default_user_id"]
post.terms_names = {'post_tag': tags}
post.comment_status = 'open'
post.id = client.call(posts.NewPost(post))
return post
示例3: toWordPressPost
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def toWordPressPost(self):
post = WordPressPost()
if self.title:
post.title = self.title
if self.content:
post.content = self.content
post.date = self.published
post.date_modified = self.updated
post.comment_status = True
post.post_status = 'publish'
return post
示例4: _create_wp_post
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def _create_wp_post(song, content):
# Create the NewPost object - see docs at
# http://python-wordpress-xmlrpc.readthedocs.io/en/latest/ref/wordpress.html
# We're missing some fields but ehhhh who knows if they even exist anymore
post = WordPressPost()
post.title = str(song)
post.content = content
post.comment_status = 'open'
post.ping_status = 'closed'
post.post_status = 'publish'
post.post_type = 'post'
post.excerpt = song.tagline
post.date = datetime.now(tz=timezone.utc)
post.date_modified = datetime.now(tz=timezone.utc)
return NewPost(post)
示例5: upload
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def upload(name, title):
client = Client("http://domain.com/xmlrpc.php", "username", "password")
imgfile = os.path.join(DATA_DIR, name)
# imgfile = 'op/%s'%name
data = {"name": name, "type": "image/jpg"}
with open(imgfile, "rb+") as imag:
data["bits"] = xmlrpc_client.Binary(imag.read())
response = client.call(media.UploadFile(data))
attachment_id = response["id"]
_title = lxml.html.fromstring(title).text
post = WordPressPost()
post.title = _title
post.post_status = "publish"
post.thumbnail = attachment_id
post.comment_status = "open"
post.id = client.call(posts.NewPost(post))
示例6: parseDocument
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def parseDocument(filename):
lines = open(filename, 'r').readlines()
values = {'title':'', 'permalink':'', 'layout':'post', 'tags':'', 'categories':'default', 'published': 'false'}
start = False
config = False
for i in range(len(lines)):
line = lines[i].strip()
if config == False:
if line == '---':
if (start == False):
start = True
else: # end
if (values['title'] == '' or values['permalink'] == ''):
printf('title and permalink should not be null!\n'); exit()
else:# config ok
config = True
else:
try:
key = line[:line.find(':')]
value = line[line.find(':')+1:]
values[key] = value.strip()
except:
printf('config failed! (key, value) = (' + key + ', ' + value + ')\n');exit()
else: #config ok
while len(lines[i]) <= 1: #filter first blank lines
i+=1
rawcontent = parseMedia(lines[i:])
rawfilename = filename[:-3] + '.raw.id-'
open(rawfilename, 'w').writelines(rawcontent)
post = WordPressPost()
post.title = values['title']
post.slug = values['permalink']
post.content = pandocTool.md2html(rawfilename)
post.post_type = values['layout']
post.post_status = 'publish' if values['published'].lower() == 'true' else 'draft'
post.comment_status = 'open' #default
post.pint_status = 'open' #default
post.terms_names = {}
#values['tags'] = values['tags'].replace(',', ',') compatible with jekyll, use blank
#values['categories'] = values['categories'].replace(',', ',')
if len(values['tags']) > 0:
post.terms_names['post_tag'] = [ tag.strip() for tag in values['tags'].split() if len(tag) > 0]
if len(values['categories']) > 0:
post.terms_names['category'] = [ cate.strip() for cate in values['categories'].split() if len(cate) > 0]
return post
示例7: publish
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def publish(pic, title, content):
'''
publish a post and set to open to comment and ping(trackback)
'''
attachment = upload(pic)
wp_client = Client(rpc_service_url, user, password)
post = WordPressPost()
post.title = title
post.content = "%s\n\n<a href='%s'><img class='alignnone size-full wp-image-%s' alt='%s' src='%s' /></a>" % (content, attachment['url'], attachment['id'], attachment['file'], attachment['url'])
#post.tags='test, test2'
#post.categories=['pet','picture']
post.thumbnail = attachment['id']
#change status to publish
post.id = wp_client.call(posts.NewPost(post))
post.post_status = 'publish'
post.comment_status = 'open'
post.ping_status = 'open'
post.user = account_ids[r.randint(0, len(account_ids)-1)]
wp_client.call(posts.EditPost(post.id, post))
return post.id
示例8: post_data_to_site
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def post_data_to_site(titles, filenames):
post_ids = []
client = Client('http://domain.com/xmlrpc.php','username','password')
for i in range(0,len(titles)):
post_title, filename = titles[i], filenames[i]
imgfile = os.path.join(DATA_DIR, filename)
data = {'name':filename, 'type':'image/jpg'}
with open(imgfile, 'rb+') as img:
data['bits'] = xmlrpc_client.Binary(img.read())
response = client.call(media.UploadFile(data))
attachment_id = response['id']
post = WordPressPost()
post.title = post_title
post.post_status = 'publish'
post.thumbnail = attachment_id
post.comment_status = 'open'
post.id = client.call(posts.NewPost(post))
post_ids.append(post.id)
print post.id
return post_ids
示例9: wordpress_post
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
def wordpress_post(config):
print("Connecting to: " + config.wordpress['xmlrpc'])
wp = Client(config.wordpress['xmlrpc'],
config.wordpress['username'],
config.wordpress['password'])
if config.attach_header:
print("Uploading header image...")
# Upload header image
data = {
'name': os.path.basename(config.png_header_file),
'type': 'image/png',
}
# Read the image and let the XMLRPC library encode it to base64
with open(config.png_header_file, 'rb') as img:
data['bits'] = xmlrpc_client.Binary(img.read())
response = wp.call(media.UploadFile(data))
attachment_id = response['id']
print("Posting blog...")
post = WordPressPost()
post.title = config.wordpress['title']
post.content = config.wordpress['content']
post.post_format = config.wordpress['post_format']
post.post_status = config.wordpress['post_status']
post.comment_status = config.wordpress['comment_status']
if config.attach_header:
post.thumbnail = attachment_id
post.terms_names = {
'post_tag': [config.wordpress['tags']],
'category': [config.wordpress['category']]
}
post.id = wp.call(NewPost(post))
if config.wordpress['podcast_plugin'] == 'Powerpress':
get_audio_size_and_duration(config)
示例10: str
# 需要导入模块: from wordpress_xmlrpc import WordPressPost [as 别名]
# 或者: from wordpress_xmlrpc.WordPressPost import comment_status [as 别名]
response = wordpress.call(media.UploadFile(data))
# substitute picture placeholders in content with WP loaded URL
if response['url'] is not None:
parsed_url = urlparse.urlparse(response['url'])
html_img='<a href=' + response['url'] + ' target=_blank><img class=aligncenter src=' + response['url'] + ' /></a>'
content = content.replace('[IMG' + str(filecount) + ']', html_img)
else:
print "DBG File '" + filename +"' cannot be found."
sys.exit(1)
# assemble post object (as draft first)
new_post = WordPressPost()
new_post.status = 'draft'
new_post.title = title
new_post.content = content
new_post.comment_status = 'open'
new_post.ping_status = 'open'
if post_date is not None and len(post_date.strip()) > 0:
#new_post.date = dateutil.parser.parse(post_date + " " + datetime.now(tzlocal()).tzname())
new_post.date = dateutil.parser.parse(post_date)
# categorise post
if categories is not None and len(categories.strip()) > 0:
for category in categories.split(','):
category_objects = wordpress.call(taxonomies.GetTerms('category', {'search': category, 'orderby': 'count', 'number': 1}))
if category_objects != None:
for category_object in category_objects:
new_post.terms.append(category_object)
# dump out post object