Skip to main content

娱网科道内部python 公用包

Project description

娱网科道内部python 公用包


使用 pip 安装

$ pip install ywkd_tools

pip 地址


PRC 调用

from ywkd_tools.inner_service_apis import InnerServices
InnerServices.setup(service_name=<调用者名称>, base_url=<RPC Domain>, secret=<RPC 认证密码>)

# 发送短信
InnerServices.MSG().send_sms([57], 'SMS_177552091', {'username': 'tester','password': 'pwd12345'})

# 用户过滤

# 调用自定义方法 fun

# 获取用户详情

# 实例1:
class AViewOrSerializer(xxx):
    def some_method(...):
        cperm = InnerServices.Cperm()

# 实例2:
def asyn_job(...):
    cperm = InnerServices.Cperm(request_id='xxxxxxxxxx') # or cperm = InnerServices.Cperm(request=request)

Auth 认证

# 在初始化文件中执行
from ywkd_tools.auth import Auth
Auth.setup(service_name=<调用者名称>, rpc_base_url=<RPC Domain>, rpc_secret=<RPC 认证密码>)

# 在django view文件中
from ywkd_tools.auth import Auth

class SomeView(BaseView):
    """需要认证的Django Vew"""

    authentication_classes = [Auth.RSTFBasciAuthentication]

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)

    def post(self, request, *args, **kwargs):
        return self.create(request, *args, **kwargs)

# 在对外提供RPC服务的文件中
from modernrpc.core import rpc_method
from modernrpc.auth import set_authentication_predicate
from ywkd_tools.auth import Auth

def ping():
    """不需要认证的rpc 接口"""
    return 'pong'

def get_import_info():
    """需要认证的rpc 接口"""
    return ...


# 确保您拥有setuptools并wheel 安装了最新版本
$ python3 -m pip install --upgrade setuptools wheel

# 安装Twine
$ python3 -m pip install --upgrade twine

# 从setup.py位于的同一目录运行此命令
$ python3 sdist bdist_wheel

# 运行Twine以上传所有存档dist
$ python3 -m twine upload dist/*
$ python3 -m twine upload --skip-existing dist/*

Project details

Download files

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

Files for ywkd-tools, version 1.0.18
Filename, size File type Python version Upload date Hashes
Filename, size ywkd_tools-1.0.18-py3-none-any.whl (14.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size ywkd_tools-1.0.18.tar.gz (10.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page