Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_common_tools-2.6.1.tar.gz (7.5 kB view details)

Uploaded Source

File details

Details for the file python_common_tools-2.6.1.tar.gz.

File metadata

  • Download URL: python_common_tools-2.6.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.8.6

File hashes

Hashes for python_common_tools-2.6.1.tar.gz
Algorithm Hash digest
SHA256 9ab27c8a38c99bd71b3e0b37423d010a1b122fc1d4f30ce9ccc10c7f72323c5b
MD5 33777b9d24adcfca5aa20ba0e648e975
BLAKE2b-256 be1e06fc70ae4f68fe020b8ab311ec70e0a410fb688b14681977d3a44ed977ca

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page