python common tools
Project description
一些常用的python工具箱
安装
pip3 install python_common_tools
使用
import time
# 使得函数使用缓存
from python_common_tools.cache import cache_function,cache_daily_function
@cache_function('.')
def f(self, a, b, c):
time.sleep(3)
return a + b + c
@cache_daily_function('.')
def f2(self, a, b, c):
time.sleep(3)
return a + b + c
# 快速设置日志
from python_common_tools.log import setup_logger
logger = setup_logger("test.log")
# 搞定异常处理的网络请求
from python_common_tools.network import secure_requests, secure_requests_json
resp = secure_requests("https://www.gethtml.com/test", retry_times=3,log_err=True)
j = secure_requests_json("https://www.getjson.com/test",timeout=10)
# linux系统相关的获取命令执行结果 获取最新版本号 打开远程服务器上的文件
from python_common_tools.linux import get_bash_output, get_latest_commit_id, open_remote_file
dirfiles = get_bash_output(["ls", "-l"])
commit_id = get_latest_commit_id()
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
Built Distribution
Close
Hashes for python_common_tools-1.0.19.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dfed9c3cc7a8580b91329e4c702b3d91527c3614ac38e3f181897ab7a14c0d6 |
|
MD5 | 842280631e88c4e1b572cdf9b2dd9a29 |
|
BLAKE2b-256 | 3317ddf2223341ba76bbef6257f4f2f04a3c598cf8efe3b4c0f374fc31ce39a5 |
Close
Hashes for python_common_tools-1.0.19-py3.6.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddfe31c3b39a65c167375f891cd614059cc7341e586156173cb339b4b15c7c5b |
|
MD5 | 335bacd74195d04d88360e62b7b9d700 |
|
BLAKE2b-256 | 5871e669de804c4f45923bbb6e2c442085f7f8ad6dc4e64a0418fcf84f7991b2 |