add a doc

parents
#!/user/bin/python
# -*- coding: utf8 -*-
import requests
import json
import datetime
import random
import uuid
default_url = 'ec2-54-223-170-25.cn-north-1.compute.amazonaws.com.cn'
port ='8080'
path = '/receive/tkio/event'
URL = 'http://' + default_url + port + path
appid = '16dc0cb882d3dbec4f7f66251a84d6dd'
nowTime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
headers = {'Content-Type': 'application/json'}
s = json.dumps({"appid": appid,
"context": {"_deviceid": "5021FED7D1CEF374_1",
"_imei":"5021FED7D1CEF374_1",
"_idfa": "imei",
"_campaignid": "ad18fbb2efcd4905a4a487927e297842",
"_ip": "192.168.10.26",
"_androidid": "imei"
},
"when":nowTime,
"who": "zqy-test2",
"what":"event_0"
})
event=['event_0','event_1','event_2','event_3','event_4','event_5','event_6','event_7','event_8','event_9','event_10','event_11','event_12','event_13']
for index in range(len(event)):
print('当前:',event[index])
r = requests.post(url=URL, data=s, headers=headers, timeout=5)
print(r.url)
print(r.text)
print(r.status_code)
\ No newline at end of file
#!/usr/bin/env python
# encoding: utf-8
"""
@author: zqy@reyun.com
"""
import requests
import time
import json
class TaskName(object):
def __init__(self):
"""打印执行函数名"""
pass
def __call__(self, func):
def _call(*args, **kw):
print (func.__doc__ + "@ %s" % time.asctime(time.localtime(time.time())))
return func(*args, **kw)
return _call
class AppEventNature(object):
def __init__(self):
"""receive服务"""
self.host = "http://log.reyun.com"
self.path = "/receive/tkio"
self.headers = {
"Content-Type": "application/json;charset=UTF-8"
}
self.appid = "b6a138247d136b49466108bc5d7ff406"
self._deviceid = "ZQY_D1CEF374-K9"
self._campaignid = "ad18fbb2efcd4905a4a487927e297842"
self._ip = "113.211.641.187"
self._channelname="kanxiu_2"
self._cid="6043"
self._imei="ZQY_D1CEF374-K9"
self._timestamp=1511339363000
self.who="zqy"
self.when="2017-11-22 16:29:23"
self.data = {
"appid": self.appid,
"context": {
"_deviceid": self._deviceid,
"_campaignid": self._campaignid,
"_idfv": self._deviceid,
"_idfa": self._deviceid,
"_ip": self._ip,
"_channelname":self._channelname,
"_cid":self._cid,
"_imei":self._imei,
"_timestamp":self._timestamp
},
"who":self.who,
"when":self.when
}
@TaskName()
def action(self, eventName):
"""基础请求"""
url = self.host + self.path + "/" + eventName
data = self.data
r = requests.post(headers=self.headers,
url=url,
data=json.dumps(data))
print (r.text)
\ No newline at end of file
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment