text stringlengths 81 112k |
|---|
Construct a container object from the output of GET /containers/json.
def from_ps(cls, client, dictionary, **kwargs):
"""
Construct a container object from the output of GET /containers/json.
"""
name = get_container_name(dictionary)
if name is None:
return None
... |
A log stream can only be attached if the container uses a json-file
log driver.
def attach_log_stream(self):
"""A log stream can only be attached if the container uses a json-file
log driver.
"""
if self.has_api_logs:
self.log_stream = self.attach(stdout=True, stderr... |
Return a value from the container or None if the value is not set.
:param key: a string using dotted notation for nested dictionary
lookups
def get(self, key):
"""Return a value from the container or None if the value is not set.
:param key: a string using dotted notation ... |
Rename the container to a hopefully unique temporary container name
by prepending the short id.
def rename_to_tmp_name(self):
"""Rename the container to a hopefully unique temporary container name
by prepending the short id.
"""
self.client.rename(
self.id,
... |
Build a key combination, such as:
ctrl-t
def build(cls, keys, down=None):
"""Build a key combination, such as:
ctrl-t
"""
codes = []
for key in keys.split('-'):
key = keycode(key)
codes.append(key)
events = []
if down is None or... |
id is a string describing the runtime, e.g 'flashgames
Returns a configured DockerRuntime object
def runtime_spec(self, id):
"""
id is a string describing the runtime, e.g 'flashgames
Returns a configured DockerRuntime object
"""
try:
return self.runtimes[i... |
Used in the tests
def _manual_recv(self, method, body, headers={}):
"""Used in the tests"""
headers.setdefault('sent_at', time.time())
return self.recv(self._make_context(), {'method': method, 'body': body, 'headers': headers}) |
Install a signal handler for HUP, INT, and TERM to call exit, allowing clean shutdown.
When running a universe environment, it's important to shut down the container when the
agent dies so you should either call this or otherwise arrange to exit on signals.
def exit_on_signal():
"""
Install a signal ha... |
We currently close our fbs files by killing them, so sometimes they end
up with bad data at the end. Close our reader if we expect `size` bytes
and get fewer.
This is a hack and should be removed when we cleanly close our
connections in fbs_writer.
https://github.com/openai/uni... |
Call from main thread. Returns the list of newly-available (handle, env) pairs.
def pop(self, n=None):
"""Call from main thread. Returns the list of newly-available (handle, env) pairs."""
self.error_buffer.check()
envs = []
if n is None:
while True:
try:
... |
Call from main thread. Initiate a request for more environments
def allocate(self, handles, initial=False, params={}):
"""Call from main thread. Initiate a request for more environments"""
assert all(re.search('^\d+$', h) for h in handles), "All handles must be numbers: {}".format(handles)
self... |
Universe method to configure the environment.
Args:
ignore_clock_skew (bool): Assume remotes are on the same machine as us,
for the purposes of diagnostics measurement.
If true, we skip measuring the clock skew over the network,
and skip generating diagnostics wh... |
return {pid: {'user': 0.0, 'sys': 0.0}}, chrome_reset
def cpu_times(self):
''' return {pid: {'user': 0.0, 'sys': 0.0}}, chrome_reset '''
chrome_procs = self.get_chrome_procs()
new_pids = {p.pid for p in chrome_procs}
old_pids = {pid for pid in self.last_cpu_times}
try:
... |
We often need to aggregate together multiple infos. Most keys can
just be clobbered by the new info, but e.g. any keys which contain
counts should be added. The merge schema is indicated by the key
namespace.
Namespaces:
- stats.timers: Timing
- stats.gauges: Gauge values
- stats.*: Counts... |
Old visual observation is discarded, because it is outdated frame.
Text observations are merged, because they are messages sent from the rewarder.
def _merge_observation(accum_observation, observation):
"""
Old visual observation is discarded, because it is outdated frame.
Text observations are merged,... |
Open the file and write the metadata header to describe this recording. Called after we establish an end-to-end connection
This uses Version 1 of our protocol
Version 0 can be seen here: https://github.com/openai/universe/blob/f85a7779c3847fa86ec7bb513a1da0d3158dda78/bin/recording_agent.py
def begin_r... |
Record a message to our rewards.demo file if it is has been opened
def record_message(self, msg, from_rewarder):
"""Record a message to our rewards.demo file if it is has been opened"""
if self.file:
# Include an authoritative timestamp (because the `sent_at` from the server is likely to be... |
Takes a list of the following form: [(a1, b1), (a2, b2), ...] and
returns a string a_mean-b_mean, flooring out at 0.
def display_timestamps_pair_compact(time_m_2):
"""Takes a list of the following form: [(a1, b1), (a2, b2), ...] and
returns a string a_mean-b_mean, flooring out at 0.
"""
if len(time... |
Takes a list of the following form: [(a1, b1), (a2, b2), ...] and
returns a string (a_mean+/-a_error, b_mean+/-b_error).
def display_timestamps_pair(time_m_2):
"""Takes a list of the following form: [(a1, b1), (a2, b2), ...] and
returns a string (a_mean+/-a_error, b_mean+/-b_error).
"""
if len(time... |
Return a string describing a set of modifiers.
Example::
>>> modifiers_string(MOD_SHIFT | MOD_CTRL)
'MOD_SHIFT|MOD_CTRL'
:Parameters:
`modifiers` : int
Bitwise combination of modifier constants.
:rtype: str
def modifiers_string(modifiers):
'''Return a string desc... |
Mutates the info_n dictionary.
def add_metadata(self, observation_n, info_n, available_at=None):
"""Mutates the info_n dictionary."""
if self.instance_n is None:
return
with pyprofile.push('vnc_env.diagnostics.Diagnostics.add_metadata'):
async = self.pool.imap_unordered... |
Extract metadata from a pixel observation and add it to the info
def add_metadata(self, observation, info, available_at=None):
"""Extract metadata from a pixel observation and add it to the info
"""
observation = observation['vision']
if observation is None: return
if self.netwo... |
Assumes you hold the lock
def _print_if_needed(self):
"""Assumes you hold the lock"""
if self._in_txn or self.print_frequency is None:
return
elif self.last_export is not None and \
self.last_export + self.print_frequency > time.time():
return
self.... |
Given a generator which yields strings and a splitter function,
joins all input, splits on the separator and yields each chunk.
Unlike string.split(), each chunk includes the trailing
separator, except for the last one if none was found on the end
of the input.
def split_buffer(stream, splitter=None, ... |
Set up log levels, and split verbose logs to a file
Configure the client-side environment logs to print
to stdout at "info" level, and also to print to a
verbose log file located at /tmp/universe-<pid>.log
or another path you specify at "debug" level.
We suggest calling this met... |
Set DOCKER_HOST (and probably DOCKER_TLS_VERIFY and DOCKER_CERT_PATH) to connect to a docker instance through TCP.
Leave DOCKER_HOST unset and it will use the default, typically unix:/var/run/docker.sock
It also needs to know how to connect to ports on the docker container after creating it.
Set DOCKER_NET... |
Call from main thread. Returns the list of newly-available (handle, env) pairs.
def pop(self, n=None):
"""Call from main thread. Returns the list of newly-available (handle, env) pairs."""
if self._popped:
assert n is None
return []
self._popped = True
envs = []... |
Returns a tuple of (log_fn, log_f, bin_fn, bin_f) to be written to by vectorized env channel i
Or all Nones if recording is inactive on that channel
def _get_writer(self, i):
"""
Returns a tuple of (log_fn, log_f, bin_fn, bin_f) to be written to by vectorized env channel i
Or all Nones ... |
Return true if we are past our limit
def _past_limit(self):
"""Return true if we are past our limit"""
if self._max_episode_steps is not None and self._max_episode_steps <= self._elapsed_steps:
logger.debug("Env has passed the step limit defined by TimeLimit.")
return True
... |
Write data to server
def recvProxyData(self, data):
"""Write data to server"""
if self.initialized:
self.sendData(data)
else:
self.queued_data.append(data) |
Write data to server
def sendData(self, data):
"""Write data to server"""
# Not set up yet
if self.client_log is None:
self.client_log_buffer.append(data)
else:
self.client_log.write(data)
self.transport.write(data) |
Crops the visual observations of an environment so that they only contain the game screen.
Removes anything outside the game that usually belongs to universe (browser borders and so on).
def CropObservations(env):
""""
Crops the visual observations of an environment so that they only contain the game scree... |
Play a list of vnc_actions forward over the current keysyms state
NOTE: Since we are squashing a set of diffs into a single keyboard state, some information may be lost.
For example if the Z key is down, then we receive [(Z-up), (Z-down)], the output will not reflect any change in Z
You can mak... |
Call from any thread
def recv_rpc(self, context, payload):
"""Call from any thread"""
logger.debug("Adding RPC payload to ControlBuffer queue: %s", payload)
self.buf.put(('rpc', (context, payload)))
with self.cv:
self.cv.notifyAll() |
Call from main thread.
def get(self, *args, **kwargs):
"""Call from main thread."""
payload = self.buf.get(*args, **kwargs)
logger.debug("Removing RPC payload from ControlBuffer queue: %s", payload)
return payload |
text channel to communicate with the agent
def send_env_text(self, text, episode_id):
''' text channel to communicate with the agent '''
reactor.callFromThread(self._send_env_text, text, episode_id) |
Return an iterable of functions.
Each function can be used to format the logs output of a container.
def build_log_presenters(service_names, monochrome):
"""Return an iterable of functions.
Each function can be used to format the logs output of a container.
"""
prefix_width = max_name_width(servi... |
Consume the queue by reading lines off of it and yielding them.
def consume_queue(queue, cascade_stop):
"""Consume the queue by reading lines off of it and yielding them."""
while True:
try:
item = queue.get(timeout=0.1)
except Empty:
yield None
continue
... |
Will set the crypting key for this object.
def setKey(self, key):
"""Will set the crypting key for this object."""
key = self._guardAgainstUnicode(key)
self.__key = key |
setPadding() -> bytes of length 1. Padding character.
def setPadding(self, pad):
"""setPadding() -> bytes of length 1. Padding character."""
if pad is not None:
pad = self._guardAgainstUnicode(pad)
self._padding = pad |
Will set the Initial Value, used in conjunction with CBC mode
def setIV(self, IV):
"""Will set the Initial Value, used in conjunction with CBC mode"""
if not IV or len(IV) != self.block_size:
raise ValueError("Invalid Initial Value (IV), must be a multiple of " + str(self.block_size) + " bytes")
IV = self._gu... |
Turn the string data, into a list of bits (1, 0)'s
def __String_to_BitList(self, data):
"""Turn the string data, into a list of bits (1, 0)'s"""
if _pythonMajorVersion < 3:
# Turn the strings into integers. Python 3 uses a bytes
# class, which already has this behaviour.
data = [ord(c) for c in data]
l ... |
Turn the list of bits -> data, into a string
def __BitList_to_String(self, data):
"""Turn the list of bits -> data, into a string"""
result = []
pos = 0
c = 0
while pos < len(data):
c += data[pos] << (7 - (pos % 8))
if (pos % 8) == 7:
result.append(c)
c = 0
pos += 1
if _pythonMajorVersion... |
Permutate this block with the specified table
def __permutate(self, table, block):
"""Permutate this block with the specified table"""
return list(map(lambda x: block[x], table)) |
Create the 16 subkeys K[1] to K[16] from the given key
def __create_sub_keys(self):
"""Create the 16 subkeys K[1] to K[16] from the given key"""
key = self.__permutate(des.__pc1, self.__String_to_BitList(self.getKey()))
i = 0
# Split into Left and Right sections
self.L = key[:28]
self.R = key[28:]
while ... |
encrypt(data, [pad], [padmode]) -> bytes
data : Bytes to be encrypted
pad : Optional argument for encryption padding. Must only be one byte
padmode : Optional argument for overriding the padding mode.
The data must be a multiple of 8 bytes and will be encrypted
with the already specified key. Data does not... |
decrypt(data, [pad], [padmode]) -> bytes
data : Bytes to be encrypted
pad : Optional argument for decryption padding. Must only be one byte
padmode : Optional argument for overriding the padding mode.
The data must be a multiple of 8 bytes and will be decrypted
with the already specified key. In PAD_NORMAL... |
Will set the crypting key for this object. Either 16 or 24 bytes long.
def setKey(self, key):
"""Will set the crypting key for this object. Either 16 or 24 bytes long."""
self.key_size = 24 # Use DES-EDE3 mode
if len(key) != self.key_size:
if len(key) == 16: # Use DES-EDE2 mode
self.key_size = 16
else... |
Sets the type of crypting mode, pyDes.ECB or pyDes.CBC
def setMode(self, mode):
"""Sets the type of crypting mode, pyDes.ECB or pyDes.CBC"""
_baseDes.setMode(self, mode)
for key in (self.__key1, self.__key2, self.__key3):
key.setMode(mode) |
setPadding() -> bytes of length 1. Padding character.
def setPadding(self, pad):
"""setPadding() -> bytes of length 1. Padding character."""
_baseDes.setPadding(self, pad)
for key in (self.__key1, self.__key2, self.__key3):
key.setPadding(pad) |
Sets the type of padding mode, pyDes.PAD_NORMAL or pyDes.PAD_PKCS5
def setPadMode(self, mode):
"""Sets the type of padding mode, pyDes.PAD_NORMAL or pyDes.PAD_PKCS5"""
_baseDes.setPadMode(self, mode)
for key in (self.__key1, self.__key2, self.__key3):
key.setPadMode(mode) |
Will set the Initial Value, used in conjunction with CBC mode
def setIV(self, IV):
"""Will set the Initial Value, used in conjunction with CBC mode"""
_baseDes.setIV(self, IV)
for key in (self.__key1, self.__key2, self.__key3):
key.setIV(IV) |
decrypt(data, [pad], [padmode]) -> bytes
data : bytes to be encrypted
pad : Optional argument for decryption padding. Must only be one byte
padmode : Optional argument for overriding the padding mode.
The data must be a multiple of 8 bytes and will be decrypted
with the already specified key. In PAD_NORMAL... |
解析微信支付结果通知
def parse_payment_result(self, xml):
"""解析微信支付结果通知"""
try:
data = xmltodict.parse(xml)
except (xmltodict.ParsingInterrupted, ExpatError):
raise InvalidSignatureException()
if not data or 'xml' not in data:
raise InvalidSignatureException()... |
新增永久图文素材
详情请参考
https://mp.weixin.qq.com/wiki?id=mp1494572718_WzHIY
:param articles: 图文素材数组
:type articles: list[dict]
:return: 返回的 JSON 数据包
def add_articles(self, articles):
"""
新增永久图文素材
详情请参考
https://mp.weixin.qq.com/wiki?id=mp1494572718_WzHIY
... |
新增其它类型永久素材
详情请参考
http://mp.weixin.qq.com/wiki/14/7e6c03263063f4813141c3e17dd4350a.html
:param media_type: 媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb)
:param media_file: 要上传的文件,一个 File-object
:param title: 视频素材标题,仅上传视频素材时需要
:param introduction: 视频素材简介,仅上传视频素材时需要
... |
获取永久素材
详情请参考
http://mp.weixin.qq.com/wiki/4/b3546879f07623cb30df9ca0e420a5d0.html
:param media_id: 素材的 media_id
:return: 图文素材返回图文列表,其它类型为素材的内容
def get(self, media_id):
"""
获取永久素材
详情请参考
http://mp.weixin.qq.com/wiki/4/b3546879f07623cb30df9ca0e420a5d0.html
... |
修改永久图文素材
详情请参考
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738732
:param media_id: 要修改的图文消息的 id
:param index: 要更新的文章在图文消息中的位置(多图文消息时,此字段才有意义),第一篇为 0
:param article: 图文素材
:return: 返回的 JSON 数据包
def update_article(self, media_id, index, article):
"""... |
修改永久图文素材
详情请参考
http://mp.weixin.qq.com/wiki/4/19a59cba020d506e767360ca1be29450.html
:param media_id: 要修改的图文消息的 id
:param index: 要更新的文章在图文消息中的位置(多图文消息时,此字段才有意义),第一篇为 0
:param articles: 图文素材数组
:return: 返回的 JSON 数据包
def update_articles(self, media_id, index, articles):
... |
查看指定文章的评论数据
def list_comment(self, msg_data_id, index=1, begin=0, count=50, type=0):
"""
查看指定文章的评论数据
"""
return self._post(
'comment/list',
data={
'msg_data_id': msg_data_id,
'index': index,
'begin': begin,
... |
将评论标记精选
def markelect_comment(self, msg_data_id, index, user_comment_id):
"""
将评论标记精选
"""
return self._post(
'comment/markelect',
data={
'msg_data_id': msg_data_id,
'index': index,
'user_comment_id': user_comment_id... |
将评论取消精选
def unmarkelect_comment(self, msg_data_id, index, user_comment_id):
"""
将评论取消精选
"""
return self._post(
'comment/unmarkelect',
data={
'msg_data_id': msg_data_id,
'index': index,
'user_comment_id': user_commen... |
删除评论
def delete_comment(self, msg_data_id, index, user_comment_id):
"""
删除评论
"""
return self._post(
'comment/delete',
data={
'msg_data_id': msg_data_id,
'index': index,
'user_comment_id': user_comment_id,
... |
回复评论
def add_reply_comment(self, msg_data_id, index, user_comment_id, content):
"""
回复评论
"""
return self._post(
'comment/reply/add',
data={
'msg_data_id': msg_data_id,
'index': index,
'user_comment_id': user_comment... |
删除回复
def delete_reply_comment(self, msg_data_id, index, user_comment_id):
"""
删除回复
"""
return self._post(
'comment/reply/delete',
data={
'msg_data_id': msg_data_id,
'index': index,
'user_comment_id': user_comment_id... |
获取服务商凭证
https://work.weixin.qq.com/api/doc#90001/90143/91200
:param provider_secret: 服务商的secret,在服务商管理后台可见
:return: 返回的 JSON 数据包
def get_provider_token(self, provider_secret):
"""
获取服务商凭证
https://work.weixin.qq.com/api/doc#90001/90143/91200
:param provider_se... |
获取第三方应用凭证
https://work.weixin.qq.com/api/doc#90001/90143/9060
:param suite_id: 以ww或wx开头应用id(对应于旧的以tj开头的套件id)
:param suite_secret: 应用secret
:param suite_ticket: 企业微信后台推送的ticket
:return: 返回的 JSON 数据包
def get_suite_token(self, suite_id, suite_secret, suite_ticket):
"""
... |
获取企业号登录用户信息
详情请参考
https://qydev.weixin.qq.com/wiki/index.php?title=获取企业号登录用户信息
:param provider_access_token: 服务提供商的 accesstoken
:param auth_code: OAuth 2.0 授权企业号管理员登录产生的 code
:return: 返回的 JSON 数据包
def get_login_info(self, auth_code, provider_access_token=None):
"""
... |
获取登录企业号官网的url
详情请参考
https://qydev.weixin.qq.com/wiki/index.php?title=获取登录企业号官网的url
:param provider_access_token: 服务提供商的 accesstoken
:param login_ticket: 通过get_login_info得到的login_ticket, 10小时有效
:param target: 登录跳转到企业号后台的目标页面
:param agentid: 可选,授权方应用id
:return: 返回... |
获取用户增减数据
详情请参考
http://mp.weixin.qq.com/wiki/3/ecfed6e1a0a03b5f35e5efac98e864b7.html
:param begin_date: 起始日期
:param end_date: 结束日期
:return: 统计数据列表
def get_user_summary(self, begin_date, end_date):
"""
获取用户增减数据
详情请参考
http://mp.weixin.qq.com/wiki/3/... |
获取累计用户数据
详情请参考
http://mp.weixin.qq.com/wiki/3/ecfed6e1a0a03b5f35e5efac98e864b7.html
:param begin_date: 起始日期
:param end_date: 结束日期
:return: 统计数据列表
def get_user_cumulate(self, begin_date, end_date):
"""
获取累计用户数据
详情请参考
http://mp.weixin.qq.com/wiki/3... |
企业付款接口
:param user_id: 接受收红包的用户在公众号下的 openid
:param amount: 付款金额,单位分
:param desc: 付款说明
:param client_ip: 可选,调用接口机器的 IP 地址
:param check_name: 可选,校验用户姓名选项,
NO_CHECK:不校验真实姓名,
FORCE_CHECK:强校验真实姓名(未实名认证的用户会校验失败,无法转账),
... |
企业付款到银行卡接口
:param true_name: 开户人名称
:param bank_card_no: 银行卡号
:param bank_code: 银行编号
:param amount: 付款金额,单位分
:param desc: 付款说明
:param out_trade_no: 可选,商户订单号,需保持唯一性,默认自动生成
:return: 返回的结果信息
def transfer_bankcard(self, true_name, bank_card_no, bank_code, amount, des... |
企业付款查询接口
:param out_trade_no: 商户调用企业付款API时使用的商户订单号
:return: 返回的结果数据
def query_bankcard(self, out_trade_no):
"""
企业付款查询接口
:param out_trade_no: 商户调用企业付款API时使用的商户订单号
:return: 返回的结果数据
"""
data = {
'mch_id': self.mch_id,
'partner_trad... |
获得模板ID
详情请参考
https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277
:param template_id_short: 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
:return: 模板 ID
def get(self, template_id_short):
"""
获得模板ID
详情请参考
https://mp.weixin.qq.com/wiki?t=resource/res_main... |
申请设备ID
详情请参考
http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html
:param quantity: 申请的设备ID的数量,单次新增设备超过500个,需走人工审核流程
:param reason: 申请理由,不超过100个字
:param poi_id: 可选,设备关联的门店ID
:param comment: 可选,备注,不超过15个汉字或30个英文字母
:return: 申请的设备信息
def apply_device... |
更新设备信息
详情请参考
http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html
:param device_id: 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
:param uuid: UUID
:param major: major
:param minor: minor
:param comment: 设备的备注信息,不超过15个汉字或30个英文字母。
:ret... |
配置设备与门店的关联关系
详情请参考
http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html
:param poi_id: 待关联的门店ID
:param device_id: 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
:param uuid: UUID
:param major: major
:param minor: minor
:return: 返回的 JSO... |
查询设备列表
详情请参考
http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html
:param identifiers: 设备 ID 信息列表
:param apply_id: 批次ID,申请设备ID超出500个时所返回批次ID
:param begin: 设备列表的起始索引值
:param count: 待查询的设备个数
:return: 设备列表
def search_device(self, identifiers=None, a... |
编辑页面信息
详情请参考
http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html
:param page_id: 摇周边页面唯一ID
:param title: 在摇一摇页面展示的主标题,不超过6个字
:param description: 在摇一摇页面展示的副标题,不超过7个字
:param icon_url: 在摇一摇页面展示的图片。图片需先上传至微信侧服务器,
用“素材管理-上传图片素材”接口上传图片,... |
查询页面列表
详情请参考
http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html
:param page_ids: 指定页面的id列表
:param begin: 页面列表的起始索引值
:param count: 待查询的页面个数
:return: 页面查询结果信息
def search_pages(self, page_ids=None, begin=0, count=10):
"""
查询页面列表
详情... |
上传图片素材
详情请参考
http://mp.weixin.qq.com/wiki/5/e997428269ff189d8f9a4b9e177be2d9.html
:param media_file: 要上传的文件,一个 File-object
:param media_type: 摇一摇素材类型, 取值为 icon或者 license, 默认 icon.
:return: 上传的素材信息
def add_material(self, media_file, media_type='icon'):
"""
上传图片素材... |
配置设备与页面的关联关系
详情请参考
http://mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html
:param page_ids: 待关联的页面列表
:param bind: 关联操作标志位, 0为解除关联关系,1为建立关联关系
:param append: 新增操作标志位, 0为覆盖,1为新增
:param device_id: 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
:param... |
获取摇周边的设备及用户信息
详情请参考
http://mp.weixin.qq.com/wiki/3/34904a5db3d0ec7bb5306335b8da1faf.html
:param ticket: 摇周边业务的ticket,可在摇到的URL中得到,ticket生效时间为30分钟
:return: 设备及用户信息
def get_shake_info(self, ticket):
"""
获取摇周边的设备及用户信息
详情请参考
http://mp.weixin.qq.com/wiki/3/349... |
以设备为维度的数据统计接口
http://mp.weixin.qq.com/wiki/0/8a24bcacad40fe7ee98d1573cb8a6764.html
:param begin_date: 起始时间,最长时间跨度为30天
:param end_date: 结束时间,最长时间跨度为30天
:param device_id: 设备编号,若填了UUID、major、minor,则可不填设备编号,若二者都填,则以设备编号为优先
:param uuid: UUID
:param major: major
:param... |
以页面为维度的数据统计接口
详情请参考
http://mp.weixin.qq.com/wiki/0/8a24bcacad40fe7ee98d1573cb8a6764.html
:param page_id: 页面 ID
:param begin_date: 起始时间,最长时间跨度为30天
:param end_date: 结束时间,最长时间跨度为30天
:return: 统计数据
def get_page_statistics(self, page_id, begin_date, end_date):
"""
... |
查询设备ID申请审核状态
详情请参考
http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html
:param apply_id: 批次ID,申请设备ID时所返回的批次ID
:return: 批次状态信息
def get_apply_status(self, apply_id):
"""
查询设备ID申请审核状态
详情请参考
http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7e... |
申请签约 api
https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_1&index=1
:param plan_id: 模板id 协议模板id,设置路径见开发步骤。
:param contract_code: 签约协议号 商户侧的签约协议号,由商户生成
:param contract_display_account: 用户账户展示名称 签约用户的名称,用于页面展示,页面样例可见案例与规范
:param notify_url: 回调通知url 用于接收签约成功消息的回调通知地址,以htt... |
查询签约关系 api
:param contract_id: 可选 委托代扣协议id 委托代扣签约成功后由微信返回的委托代扣协议id,选择contract_id查询,则此参数必填
:param plan_id: 可选 模板id 商户在微信商户平台配置的代扣模板id,选择plan_id+contract_code查询,则此参数必填
:param contract_code: 可选 签约协议号 商户请求签约时传入的签约协议号,商户侧须唯一。选择plan_id+contract_code查询,则此参数必填
:param openid: 可选 openid 用户标识,必须保证... |
申请扣款 api
:param body: 商品描述 商品或支付单简要描述
:param out_trade_no: 可选 商户订单号 商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
:param total_fee: 总金额 订单总金额,单位为分,只能为整数,详见支付金额
:param contract_id: 委托代扣协议id 签约成功后,微信返回的委托代扣协议id
:param notify_url: 回调通知url 接受扣款结果异步回调通知的url
:param detail: 可选 商品详情 商品名称明... |
查询订单 api
:param transaction_id: 二选一 微信订单号 微信的订单号,优先使用
:param out_trade_no: 二选一 商户订单号 商户系统内部的订单号,当没提供transaction_id时需要传这个。
:return: 返回的结果信息
def query_order(self, transaction_id=None, out_trade_no=None):
"""
查询订单 api
:param transaction_id: 二选一 微信订单号 微信的订单号,优先使用
:... |
申请解约
https://pay.weixin.qq.com/wiki/doc/api/pap.php?chapter=18_4&index=6
:param contract_id: 合同ID
:param plan_id: 模板ID
:param contract_code: 合同号
:param contract_termination_remark: 解约原因
:param version: 版本号
:return:
def apply_cancel_signing(self, contract_id=Non... |
提交审核/取消发布商品
详情请参考
http://mp.weixin.qq.com/wiki/15/1007691d0f1c10a0588c6517f12ed70f.html
:param standard: 商品编码标准
:param key: 商品编码内容
:param status: 设置发布状态。on 为提交审核,off 为取消发布
:return: 返回的 JSON 数据包
def modify_product_status(self, standard, key, status):
"""
... |
查询商品信息
详情请参考
http://mp.weixin.qq.com/wiki/15/7fa787701295b884410b5163e13313af.html
:param standard: 商品编码标准
:param key: 商品编码内容
:return: 返回的 JSON 数据包
def get_product(self, standard, key):
"""
查询商品信息
详情请参考
http://mp.weixin.qq.com/wiki/15/7fa787701... |
批量查询商品信息
详情请参考
http://mp.weixin.qq.com/wiki/15/7fa787701295b884410b5163e13313af.html
:param offset: 可选,批量查询的起始位置,从 0 开始,包含该起始位置
:param limit: 可选,批量查询的数量,默认为 10
:param status: 可选,支持按状态拉取。on为发布状态,off为未发布状态,
check为审核中状态,reject为审核未通过状态,all为所有状态
:param... |
清除商品信息
详情请参考
http://mp.weixin.qq.com/wiki/15/7fa787701295b884410b5163e13313af.html
:param standard: 商品编码标准
:param key: 商品编码内容
:return: 返回的 JSON 数据包
def clear_product(self, standard, key):
"""
清除商品信息
详情请参考
http://mp.weixin.qq.com/wiki/15/7fa7877... |
主动发送消息给设备
详情请参考
https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-3
:param device_type: 设备类型,目前为“公众账号原始ID”
:param device_id: 设备ID
:param user_id: 微信用户账号的openid
:param content: 消息内容,BASE64编码
:return: 返回的 JSON 数据包
def send_message(self, device_type, device_id... |
第三方主动发送设备状态消息给微信终端
详情请参考
https://iot.weixin.qq.com/wiki/document-2_10.html
:param device_type: 设备类型,目前为“公众账号原始ID”
:param device_id: 设备ID
:param user_id: 微信用户账号的openid
:param msg_type: 消息类型:2--设备状态消息
:param status: 设备状态:0--未连接, 1--已连接
:return: 返回的 JSON 数据包... |
通过 ticket 换取二维码地址
详情请参考
https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-4
:param ticket: 二维码 ticket
:param data: 额外数据
:return: 二维码地址
def get_qrcode_url(self, ticket, data=None):
"""
通过 ticket 换取二维码地址
详情请参考
https://iot.weixin.qq.com/wiki/ne... |
绑定设备
详情请参考
https://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7
:param ticket: 绑定操作合法性的凭证(由微信后台生成,第三方H5通过客户端jsapi获得)
:param device_id: 设备id
:param user_id: 用户对应的openid
:return: 返回的 JSON 数据包
def bind(self, ticket, device_id, user_id):
"""
绑定设备
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.