Skip to main content

A utility library for everyday use.

Project description

安装:

pip install long-utils

图像

图中找图

from long_utils.image.search import ImgFindImg

img = ImgFindImg(img_source='static/big.png', img_search='static/small.png')
img.find_coord(is_debug=True)

# 或者只拿取小图在原图中的坐标rectangle, 小图在原图中的大小result,confidence表示准确率
res = img.find_coord()
# [{'result': (539.0, 21.5), 'rectangle': ((524, 10), (524, 33), (554, 10), (554, 33)), 'confidence': 1.0}]
print(res)

其他

日志输出

from long_utils import Log

logger = Log(show_line=True, show_file_name=True, show_time=True)

logger.error(message="xxxx")
logger.success(message="xxxx")
logger.warning(message="xxxx")
logger.info(message="xxxx")
logger.debug(message="xxxx")

logger.success_bg('xxxx')
logger.error_bg('xxxx')
logger.warning_bg('xxxx')
logger.debug_bg('xxxx')
logger.info_bg('xxxx')
logger.color('xxxx', fg='blue', bg='black')

对象存储OSS

配置

from long_utils.storage.config import SSconfig
from long_utils.storage.aliyun.oss import AliyumOss

access_key = 'xxx'
access_key_secret = 'xxx'
endpoint = 'https://oss-cn-shanghai.aliyuncs.com'
bucket_name = 'xxx'
ss_config = SSconfig(
    access_key_id=access_key,
    access_key_secret=access_key_secret,
    bucket_url=endpoint,
    bucket_name=bucket_name
)
aliyun_client = AliyumOss(
    config=ss_config
)

分片下载文件到本地

aliyun_client.multipart_upload_file(key='xxx.pth', local_file='xxx.pth')

如果需要知道下载进度,可以:

def progress_callback(block_size, total_size):
    print(f"正在下载: {block_size / total_size * 100:.2f}%")

aliyun_client.multipart_upload_file(key='xxx.pth', local_file='xxx.pth', progress_callback=progress_callback)

分片上传本地文件

aliyun_client.multipart_upload_file(key='xxx.pth', file='xxxx.pth')

如果需要知道上传进度,可以:

def progress_callback(block_size, total_size):
    print(f"正在上传: {block_size / total_size * 100:.2f}%")

aliyun_client.multipart_upload_file(key='xxx.pth', file='xxx.pth', progress_callback=progress_callback)

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

long-utils-0.7.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

long_utils-0.7.1-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file long-utils-0.7.1.tar.gz.

File metadata

  • Download URL: long-utils-0.7.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.5

File hashes

Hashes for long-utils-0.7.1.tar.gz
Algorithm Hash digest
SHA256 071748e53d85fed48cda4ef5bea1f93338fa1df79bccc236b86283f4420e5ce3
MD5 ae2bfa589f31d4a88d3db33896f7d907
BLAKE2b-256 f47bcf611a3426ec25b99fdfcb75bae1bb7a20e5ce7469749227f5663cfc8789

See more details on using hashes here.

File details

Details for the file long_utils-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: long_utils-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.5

File hashes

Hashes for long_utils-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 51521fe492a035ec189852483836d2b079b8f250fb6e6b1dd76370dfa8ab804f
MD5 b01d0a9046e9631694b7e3efd422d5ba
BLAKE2b-256 2a5e2dbd1530007da5d2bf80421e62476fcce120d89b02c6c03bd97a3e24daf1

See more details on using hashes here.

Supported by

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