Skip to main content

一些常用的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()

Metadata

Release files for python-common-tools 2.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-common-tools 2.6.1
File Size Uploaded Provenance
python_common_tools-2.6.1.tar.gz 7.5 kB Without provenance Details

Release files / python_common_tools-2.6.1.tar.gz

Download URL python_common_tools-2.6.1.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9ab27c8a38c99bd71b3e0b37423d010a1b122fc1d4f30ce9ccc10c7f72323c5b
BLAKE2b-256 checksum
How to use checksums
be1e06fc70ae4f68fe020b8ab311ec70e0a410fb688b14681977d3a44ed977ca
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for python-common-tools 2.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.6.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page