Skip to main content

This is my common Python tool classes.

Main page is https://pypi.org/project/wcommon/ .

/data/apps/public/conf.ini content like:

[mysql]
host=example.com
port=3306
user=username
passwd=password
database=test
charset=utf8mb4

Find the localhost internal network ip:

from wcommon import *
ip = getLocalIp()
hostname = getLocalHostname()

Decode unusual json string:

from wcommon import *
line = """
{
    name:'java',
    system:'linux'
}
"""
result = dejson(line)
# output result
{"name":"java","system":"linux"}
# check the reuquirement list
check_requirement(['requests','flask'])

Operate mysql data:

mysql = Mysql(configuraion_file="/data/apps/public/conf.ini", section="mysql")
# query
rows = mysql.query("select * from example_table where status = %s order by id desc limit %s",(1,10))
for row in rows:
    print(row)
# bulk_insert
mysql.bulk_insert("test.person",["name","age"],[["mahuateng",40],["liyanhong",39]])
# bulk_insert
mysql.bulk_insert2("test.person",[{"name":"ma2","age":40},{"name":"liyanhong2","age":39},{"name":"ren"}] )

Feature

1.3.8

可以通过check_requirement方法检测依赖包是否已经安装,如果没有安装,则提示安装。

1.6.5

为Elasticsearch增加query方法

1.8.0.0

增加 AppleScriptTool 类。此类只在Mac上有效

2.0.0

增加MqServer和MqProducer类,这两个类是对zeromq的包装

2.0.5

增加MqConsumer类

2.6.1

增加DubboKit类

    client = DubboTool("10.50.5.10", 20880)
    # 获取服务代理
    StatisticsApi = client.new("com.example.bigdata.statistics.api.StatisticsApi")
    # 直接调用方法,就像本地函数一样
    result = StatisticsApi.getExtUrlData({"sceneId": "264420791", "product": "tracker_view"})
    print("调用结果:", result)

Metadata

Release files for wcommon 3.0.0

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

Source distribution (sdist)

Source distribution for wcommon 3.0.0
File Size Uploaded Provenance Actions
wcommon-3.0.0.tar.gz 20.4 kB Without provenance Details for wcommon-3.0.0.tar.gz

Release files / wcommon-3.0.0.tar.gz

Download URL wcommon-3.0.0.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f769873039a5eee7f49898e60d55c7ea502e9b015f41dd7b5f6c6fb82a19630f
BLAKE2b-256 checksum
How to use checksums
6eb9845caa00d64bc8b2d371b600c1c99d90a72bbdb276efcc39546b1aabbb2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Security for wcommon 3.0.0

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

3.0.0 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