无效用户蟒蛇

userful的Python项目详细描述


python用户版

the Userful REST API的非官方python客户端。

请注意,此客户端功能不完整,将根据需要添加调用。

用法

所有客户端方法都返回一个requests.Response对象。他们都不做状态检查 由客户端的用户决定是否检查返回状态代码。

初始化

可以使用环境变量或在实例化客户端时配置客户端。

如果由于配置错误而导致身份验证失败,将引发requests.exceptions.HTTPError

使用环境变量

以下环境变量可用于配置客户端:

  • userful_user-用于身份验证的用户名(必需)
  • userful_pass-用于身份验证的密码(必需)。记住在环境中储存秘密 变量可能是危险的。因此,您可能希望在灌输期间提供密码。
  • userful_host-userful api的主机名或IP地址(必需)
  • userful端口-userful api的端口(可选,默认为9000

导出这些变量后,可以按如下方式实例化客户端:

from userful.client import UserfulClient

client = UserfulClient()

初始化期间通过

from userful.client import UserfulClient

client = UserfulClient(user="myuser", password="s00persecret", host="myuserfulhost.com")

配方

在区域上切换源

# Change the source of the zone. This DOES NOT actually change what is on the screen.
# However, this source now becomes the default for the zone.
client.switch_source_by_zone('Zone-0', 'Userful Desktop')

# Actually make the zone start playing the new source
client.play_by_zone('Zone-0')
<更新现有的源代码>
# The PUT call to update a source is not idempotent, so we need to start by
# grabbing the existing source object

payload = client.get_sources(name='my_source')

# Get the ID of the source
source_id = payload['sourceId']

# Change the name of the source in the payload
payload['sourceName'] = 'my_new_source_name'

# Send the new data to the API
res = client.update_source(source_id, payload)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
SpringWeb中的java更新/通知其他用户   java Lambda性能测试   java Bukkit插件:空白符号   java在按下按钮后改变彩色正方形的大小   javajavac相当于“D”?   java序列化接口   属性无法从属性文件返回值   java我应该使用什么查询来使用Jsoup从html页面提取符号?   java Android Studio项目结构问题   JAVA方法和返回值/公共变量(基础)   java将NativeQuery映射到POJO   java如何在下面的程序中消除NumberFormatException?   在java中获取链表与数组中的对象   java Android Firebase将用户发送到聊天室