代码拉取完成,页面将自动刷新
同步操作将从 tedi/weixin_enterprise 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- coding: utf-8 -*-
import xmlrpclib
def connect(url,port,db,username,pwd):
url = '%s:%s/xmlrpc/common'%(url,port)
sock = xmlrpclib.ServerProxy(url)
uid = sock.login(db,username,pwd)
return uid
def get_data(url,port,db,uid,pwd):
url = '%s:%s/xmlrpc/2/object'%(url,port)
sock = xmlrpclib.ServerProxy(url)
#item_ids = sock.execute(db,uid,pwd,'hr.social.item.type','search',[])
#items = sock.execute(db,uid,pwd,'hr.social.item.type','read',item_ids,['name','short_name'])
#print 'item type is %s' % items
items_2 = sock.execute(db,uid,pwd,'hr.social.item.type','search_read',[],['name','short_name'])
country_ids = sock.execute(db,uid,pwd,'res.country','search',[['code','=','CN']])
provines = sock.execute(db,uid,pwd,'res.country.state','search_read',[['country_id','in',country_ids]],['id','name'])
print 'provines is %s' % provines
print 'items_2 is %s' % items_2
#sock.execute_kw(db, uid, pwd,'res.partner','read',[1,3,2,5,6,4],['name'])
def get_data_from_odoo():
db = 'banan'
uid = 1
pwd = 'p@ssw0rd'
url = 'http://120.26.81.93:9000/xmlrpc/2/object'
sock = xmlrpclib.ServerProxy(url)
res = sock.execute_kw(db,uid,'p@ssw0rd','mail.message','search_read',[[['model','=','mail.group']]],{'fields':['model','subject','date','body'],'limit':1,'order':'id desc'})
res = res[0]
#print res['body']
s = res['body']
print type(s),s
s = res['body'].encode('utf8')
print type(s),s
#import pdb
#pdb.set_trace()
e = res['body'].encode('utf8')
#e = res['body']
#import cgi
#e = cgi.escape(e)
#e = "中国"
#e = "<b>HelloM</b> \n Hell o\n skkssks"
news = [
{'title':res['date'],'description':e,'url':"http://www.sina.com",'picurl':"http://www.sinaimg.cn/dy/slidenews/1_img/2015_17/2841_567113_575641.jpg"}
#{'title':res['date'],'description':e,'url':"http://www.sina.com",'picurl':""}
]
return news
def send_message():
from webchartapi import NewsMessage,WebChartApi
sCorpID = "wx2b6a644956aea8d6"
corpsecret = "LB437Fd5jpguFMfNV2wecwZ-5UBTlulbSLW78Qmt1hXnUD3RG8tTn0LIZO8mYwJz"
api = WebChartApi(sCorpID,corpsecret)
token = api.get_access_token()
#news = [
# {'title':"This is a demo",'description':"description",'url':"http://www.sina.com",'picurl':"http://www.sinaimg.cn/dy/slidenews/1_img/2015_17/2841_567113_575641.jpg"}
#]
news = get_data_from_odoo()
message = NewsMessage(3,touser="tedi3231",news=news)
res = api.send_message(token,message)
print 'res = %s, token is %s' %(res, token)
if __name__ == "__main__":
#uid = connect('http://114.215.192.144','8069','policy','admin','admin')
#print 'uid = %s' % uid
#get_data('http://114.215.192.144','8069','policy',uid,'admin')
send_message()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。