retrieve data from centralSystem.org
Project description
simplify data retrieving on centralSystem.org
download file
import central_system
from central_system import Client, ApiRequest, Method
c = Client(data_endpoint="",access_key="", secret_key="",authorized_endpoint="")
api_request = ApiRequest(data_address="1754C67BE4821000", request_path="api-provider/download/local/123456",
method=Method.POST)
try:
# 模式一
r = c.call_api(api_request)
with open('./img8.jpg', 'wb') as f:
f.write(r.content)
# 模式二
f = open('./img5.jpg', 'wb')
response_stream = c.call_api_stream(api_request)
with response_stream as r:
for chunk in r.iter_bytes(chunk_size=4096):
f.write(chunk)
finally:
f.close()
do http
import central_system
from central_system import Client, ApiRequest, Method
c = Client(data_endpoint="",access_key="", secret_key="",authorized_endpoint="")
params = {'pkey1': 'value1', 'pkey2': 'value2'}
json = {'jkey1': 'value1', 'jkey2': 'value2'}
headers = {'user-agent': 'my-app/0.0.1'}
api_request = ApiRequest(data_address="178589E198821000", request_path="post",
method=Method.POST, headers=headers, params=params, json=json, timeout=10)
response = c.call_api(api_request)
print(response.content)
do pgsql
import central_system
from central_system import Client, ApiRequest, Method
c = Client(data_endpoint="",access_key="", secret_key="",authorized_endpoint="")
json = {"payload": "{ \"sql\": \"select * from zs.student\" }"}
api_request = ApiRequest(data_address="1785CB2070C21000", request_path="pg",
method=Method.POST, json=json, timeout=10)
response = c.call_api(api_request)
print(response.content)
do odps
import logging
import central_system
from central_system import Client, ApiRequest, Method
c = Client(data_endpoint="",access_key="", secret_key="",authorized_endpoint="")
json = {"payload": "{ \"selectSql\": \"select * from user \" }"}
api_request = ApiRequest(data_address="174FB94000C21000", request_path="get/odps",
method=Method.POST, json=json, timeout=10)
response = c.call_api(api_request)
print(response.content)
enable log
import logging
import central_system
central_system.set_file_logger("../log/central.log", level=logging.DEBUG)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
central_system-1.0.2.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file central_system-1.0.2.tar.gz
.
File metadata
- Download URL: central_system-1.0.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f68ef83607fc29be750ccdbd1d8e51cc2036e2bf6633786dedac0bac8f3fd45e |
|
MD5 | 45c139c2098a14c230f51e66dd1ad7fc |
|
BLAKE2b-256 | 520841e2f5f52badc85f0bf1a8dcc4ab3b00b6ac271470d2aacacae1ecc63ead |
File details
Details for the file central_system-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: central_system-1.0.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0ee250303568fb291837b8d77986d6f72d0b1f3b67586a7f0deae0c0118a7ed |
|
MD5 | 05f319d487da4ba1cbc41762a0ee5793 |
|
BLAKE2b-256 | 7c1af43dce538661a4e6ab180b61aefbab4d387b2f6f762094fd358740baafc1 |