WebObs Python客户端
webobsclient的Python项目详细描述
webobsclient
WebObs Python客户端。在
安装
webobsclient可在PyPI上使用。您可以通过以下方式安装最新版本 键入以下命令:
pip install -U webobsclient
要求
- Python 3.5+
- httplib2型
- 六
- 熊猫
- SQL炼金术
您还可以在requirements.txt
文件中找到所有依赖包。在
提出请求
您需要指定您的WebObs登录的username
和{
有时,使用y1
、m1
、d1
、和{starttime
和endtime
选项指示请求的时间范围。
例如:
importwebobsclientclient=webobsclient.MC3Client(username='USER',password='PASSWORD')response,content=client.request(starttime='2019-06-15 12:00:00',endtime='2019-07-15 12:00:00',slt=0,type='ALL',duree='ALL',ampoper='eq',amplitude='ALL',locstatus=0,located=0,hideloc=0,mc='MC3',dump='bul',graph='movsum')print(response)print(content)
请注意,starttime
和endtime
选项仅在^{
Sefran3客户端的另一个示例:
importwebobsclientclient=webobsclient.Sefran3Client(username='USER',password='PASSWORD')response,content=client.request(s3='SEFRAN',mc3='MC3',date='201907150829',id=550)print(response)print(content)
请注意,请求和WebObs中的日期时间都是UTC时区。如果 您使用的是本地时区,您应该先将其转换为UTC时区 提出请求。在
正在解析MC3 CSV公告
webobsclient
提供了一些实用程序类来解析mc3csv
从
WebObs回应:
importwebobsclientfromwebobsclient.parserimportMC3Parserclient=webobsclient.MC3Client(username='USER',password='PASSWORD')response,content=client.request(type='VTA',starttime='2019-10-01',endtime='2019-10-31',slt=0,duree='ALL',ampoper='eq',amplitude='ALL',locstatus=0,located=0,hideloc=0,mc='MC3',dump='bul',graph='movsum')parser=MC3Parser(content,use_local_tz=True)print(parser.to_dictionary())
上面的示例从
2019-10-01
到{use_local_tz=True
选项。这将转换具有日期时间类型的任何列
从UTC到亚洲/雅加达时区,因为MC3Parser类使用亚洲/雅加达
默认时区。方法to_dictionary()
将mc3csv转换为Python
字典。在
mc3csv使用预定义的列shemas进行解析。你可以看到柱子
webobsclient/schemas.py
中的架构。在
有关可用方法和选项的详细信息,请参阅中的源代码
webobsclient/parser.py
。在
更改WebObs主机
这个包主要用于BPPTKG与我们的WebObs服务器交互。
库中的默认WebObs主机是192.168.0.25
。如果你的WebObs主机是
不同的是,您可以按如下方式更改WebObs主机:
importwebobsclientclient=webobsclient.MC3Client(username='USER',password='PASSWORD')client.api.host='192.168.5.10'
支持的WebObs客户端
目前只支持WebObs MC3和Sefran3。将添加更多客户端 未来的版本。在
支持
该项目由Indra Rudianto负责维护。如果你对 这个项目,你可以联系他在indrarudianto.official@gmail.com。在
许可证
通过为项目捐款,您同意您的捐款将 根据麻省理工学院的执照授权。看到了吗 LICENSE用于 细节。在
- 项目
标签: