Skip to main content

常用工具类方法集合

Project description

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)

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

wcommon-2.6.3.tar.gz (19.1 kB view details)

Uploaded Source

File details

Details for the file wcommon-2.6.3.tar.gz.

File metadata

  • Download URL: wcommon-2.6.3.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.4

File hashes

Hashes for wcommon-2.6.3.tar.gz
Algorithm Hash digest
SHA256 e9002dda7252504e5b8713d27be97c3ca89e5caf10fe57f066ebb2d4e5f7af46
MD5 1e66883877888f5e6f666c01e1e6b9a4
BLAKE2b-256 73de2e43e352c4ba2c4a75a687d15f2861cec4160b03fc8dd297de74842954dd

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