Example #1
0
import queue
import threading
from HiveNetLib.base_tools.run_tool import RunTool
# 根据当前文件路径将包路径纳入,在非安装的情况下可以引用到
sys.path.append(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.path.pardir,
                     os.path.pardir)))
from HiveNetLib.simple_restful.server import FlaskServer, FlaskServerExit
from HiveNetLib.simple_queue import MemoryQueue
# 动态安装包
import HiveNetLib.deps_tool as deps_tool
try:
    import gevent
except ImportError:
    deps_tool.install_package('gevent')
    import gevent

process_install_flask = False
while True:
    try:
        from flask_socketio import SocketIO, emit
        import socketio
        break
    except ImportError:
        if not process_install_flask:
            deps_tool.install_package('flask-socketio')
            process_install_flask = True
            continue
        raise
Example #2
0
import os
import sys
import json
from random import Random
# 根据当前文件路径将包路径纳入,在非安装的情况下可以引用到
sys.path.append(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.path.pardir,
                     os.path.pardir)))
# 动态添加包安装
import HiveNetLib.deps_tool as deps_tool
try:
    import dicttoxml
except ImportError:
    deps_tool.install_package('dicttoxml')
    import dicttoxml
try:
    from lxml import etree
except ImportError:
    deps_tool.install_package('lxml')
    from lxml import etree

__MOUDLE__ = 'string_tool'  # 模块名
__DESCRIPT__ = u'字符串处理模块'  # 模块描述
__VERSION__ = '0.1.0'  # 版本
__AUTHOR__ = u'黎慧剑'  # 作者
__PUBLISH__ = '2018.08.29'  # 发布日期


class StringTool(object):
Example #3
0
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!

import sys
import os
# 根据当前文件路径将包路径纳入,在非安装的情况下可以引用到
sys.path.append(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.path.pardir,
                     os.path.pardir)))
import HiveNetLib.deps_tool as deps_tool
try:
    import grpc
except ImportError:
    deps_tool.install_package('grpcio')
    import grpc
import HiveNetLib.simple_grpc.msg_pb2 as msg__pb2


class SimpleGRpcServiceStub(object):
    # missing associated documentation comment in .proto file
    pass

    def __init__(self, channel):
        """Constructor.

        Args:
          channel: A grpc.Channel.
        """
        self.GRpcCallSimple = channel.unary_unary(
            '/simpleGRpc.SimpleGRpcService/GRpcCallSimple',
            request_serializer=msg__pb2.RpcRequest.SerializeToString,
Example #4
0
@file msg_json.py

"""

import os
import sys
import json
# 根据当前文件路径将包路径纳入,在非安装的情况下可以引用到
sys.path.append(os.path.abspath(os.path.join(
    os.path.dirname(__file__), os.path.pardir, os.path.pardir)))
# 动态添加包安装
import HiveNetLib.deps_tool as deps_tool
try:
    from jsonpath_rw import jsonpath, parse
except ImportError:
    deps_tool.install_package('jsonpath-rw')
    from jsonpath_rw import jsonpath, parse
# 引用自有模块
from HiveNetLib.generic import CResult
from HiveNetLib.interface_tool.msg_fw import EnumMsgObjType, MsgFW
from HiveNetLib.interface_tool.msg_xml import MsgXML
from HiveNetLib.base_tools.exception_tool import ExceptionTool


__MOUDLE__ = 'msg_json'  # 模块名
__DESCRIPT__ = u'json报文处理模块'  # 模块描述
__VERSION__ = '0.1.0'  # 版本
__AUTHOR__ = u'黎慧剑'  # 作者
__PUBLISH__ = '2018.09.13'  # 发布日期

Example #5
0
# 根据当前文件路径将包路径纳入,在非安装的情况下可以引用到
sys.path.append(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.path.pardir,
                     os.path.pardir)))
import HiveNetLib.deps_tool as deps_tool
process_protobuf = False
while not process_protobuf:
    try:
        from google.protobuf import descriptor as _descriptor
        from google.protobuf import message as _message
        from google.protobuf import reflection as _reflection
        from google.protobuf import symbol_database as _symbol_database
        break
    except ImportError:
        deps_tool.install_package('googleapis-common-protos')
        process_protobuf = True
# @@protoc_insertion_point(imports)

_sym_db = _symbol_database.Default()

DESCRIPTOR = _descriptor.FileDescriptor(
    name='msg.proto',
    package='simpleGRpc',
    syntax='proto3',
    serialized_options=None,
    serialized_pb=_b(
        '\n\tmsg.proto\x12\nsimpleGRpc\"\x9b\x01\n\nRpcRequest\x12\x10\n\x08trace_id\x18\x01 \x01(\t\x12\x11\n\tparent_id\x18\x03 \x01(\t\x12\x13\n\x0btrace_level\x18\x04 \x01(\x05\x12\x14\n\x0cservice_name\x18\x05 \x01(\t\x12\x11\n\tpara_json\x18\x06 \x01(\t\x12\x16\n\x0ehas_para_bytes\x18\x07 \x01(\x08\x12\x12\n\npara_bytes\x18\x08 \x01(\x0c\"\xa2\x01\n\x0bRpcResponse\x12\x13\n\x0breturn_json\x18\x01 \x01(\t\x12\x18\n\x10has_return_bytes\x18\x02 \x01(\x08\x12\x14\n\x0creturn_bytes\x18\x03 \x01(\x0c\x12\x11\n\tcall_code\x18\x04 \x01(\t\x12\x10\n\x08\x63\x61ll_msg\x18\x05 \x01(\t\x12\x12\n\ncall_error\x18\x06 \x01(\t\x12\x15\n\rcall_msg_para\x18\x07 \x01(\t\" \n\rHealthRequest\x12\x0f\n\x07service\x18\x01 \x01(\t\"\x9b\x01\n\x0eHealthResponse\x12\x38\n\x06status\x18\x01 \x01(\x0e\x32(.simpleGRpc.HealthResponse.ServingStatus\"O\n\rServingStatus\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x0b\n\x07SERVING\x10\x01\x12\x0f\n\x0bNOT_SERVING\x10\x02\x12\x13\n\x0fSERVICE_UNKNOWN\x10\x03\x32\xa0\x03\n\x11SimpleGRpcService\x12\x43\n\x0eGRpcCallSimple\x12\x16.simpleGRpc.RpcRequest\x1a\x17.simpleGRpc.RpcResponse\"\x00\x12O\n\x18GRpcCallClientSideStream\x12\x16.simpleGRpc.RpcRequest\x1a\x17.simpleGRpc.RpcResponse\"\x00(\x01\x12O\n\x18GRpcCallServerSideStream\x12\x16.simpleGRpc.RpcRequest\x1a\x17.simpleGRpc.RpcResponse\"\x00\x30\x01\x12T\n\x1bGRpcCallBidirectionalStream\x12\x16.simpleGRpc.RpcRequest\x1a\x17.simpleGRpc.RpcResponse\"\x00(\x01\x30\x01\x12N\n\x13GRpcCallHealthCheck\x12\x19.simpleGRpc.HealthRequest\x1a\x1a.simpleGRpc.HealthResponse\"\x00\x62\x06proto3'
    ))

_HEALTHRESPONSE_SERVINGSTATUS = _descriptor.EnumDescriptor(
Example #6
0
"""

import sys
import os
import re
from enum import Enum
# 根据当前文件路径将包路径纳入,在非安装的情况下可以引用到
sys.path.append(
    os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
# 动态安装包
import HiveNetLib.deps_tool as deps_tool
try:
    import lxml.etree as ET
    import lxml.html as HT
except ImportError:
    deps_tool.install_package('lxml')
    import lxml.etree as ET
    import lxml.html as HT
try:
    import elementpath
except ImportError:
    deps_tool.install_package('elementpath')
    import elementpath
try:
    import chardet
except ImportError:
    deps_tool.install_package('chardet')
    import chardet

__MOUDLE__ = 'simple_xml'  # 模块名
__DESCRIPT__ = u'简单xml文件处理模块'  # 模块描述
Example #7
0
        os.path.join(os.path.dirname(__file__), os.path.pardir,
                     os.path.pardir)))
# 动态安装包
import HiveNetLib.deps_tool as deps_tool
process_install_flask = False
while True:
    try:
        from flask import Flask, request, jsonify
        from flask.wrappers import Response
        from flask_httpauth import HTTPTokenAuth
        from werkzeug.routing import Rule
        from flask_cors import CORS
        break
    except ImportError:
        if not process_install_flask:
            deps_tool.install_package('flask')
            deps_tool.install_package('flask-cors')
            deps_tool.install_package('flask-restful')
            deps_tool.install_package('flask-httpauth')
            deps_tool.install_package('werkzeug')
            process_install_flask = True
            continue
        raise
# 自有包引用
from HiveNetLib.base_tools.string_tool import StringTool
from HiveNetLib.simple_restful.cryptography import HCrypto

__MOUDLE__ = 'auth'  # 模块名
__DESCRIPT__ = u'restful api 鉴权模块'  # 模块描述
__VERSION__ = '0.1.0'  # 版本
__AUTHOR__ = u'黎慧剑'  # 作者
Example #8
0
import HiveNetLib.deps_tool as deps_tool
process_install_pycryptodome = False
while True:
    try:
        if sys.platform != 'win32':
            from Crypto import Random
            from Crypto.PublicKey import RSA
            from Crypto.Cipher import PKCS1_v1_5
        else:
            from Cryptodome import Random
            from Cryptodome.PublicKey import RSA
            from Cryptodome.Cipher import PKCS1_v1_5  # 注: JS加密的内容 PKCS1_OAEP 没有办法解密
        break
    except ImportError:
        if not process_install_pycryptodome:
            deps_tool.install_package('pycryptodome')
            process_install_pycryptodome = True
            continue
        raise
# 自有包引用
from HiveNetLib.base_tools.string_tool import StringTool

__MOUDLE__ = 'cryptography'  # 模块名
__DESCRIPT__ = u'通用的加解密处理公共模块'  # 模块描述
__VERSION__ = '0.1.0'  # 版本
__AUTHOR__ = u'黎慧剑'  # 作者
__PUBLISH__ = '2020.12.08'  # 发布日期


class HCrypto(object):
    """
Example #9
0
import re
from enum import Enum
import platform
import subprocess
import shutil
# 根据当前文件路径将包路径纳入,在非安装的情况下可以引用到
sys.path.append(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.path.pardir,
                     os.path.pardir)))
# 动态添加包安装
import HiveNetLib.deps_tool as deps_tool
try:
    import chardet
except ImportError:
    deps_tool.install_package('chardet')
    import chardet
# 引用自有模块
import HiveNetLib.base_tools.myzipfile as zipfile

__MOUDLE__ = 'file_tool'  # 模块名
__DESCRIPT__ = u'文件处理工具'  # 模块描述
__VERSION__ = '0.1.0'  # 版本
__AUTHOR__ = u'黎慧剑'  # 作者
__PUBLISH__ = '2018.08.29'  # 发布日期


class EnumFileSizeUnit(Enum):
    """
    文件大小单位
    @enum {int}
Example #10
0
process_install_selenium = False
while True:
    try:
        from selenium import webdriver
        from selenium.webdriver.support.ui import WebDriverWait
        from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
        import selenium.webdriver.chrome.options
        import selenium.webdriver.firefox.options
        from selenium.webdriver.common.proxy import Proxy, ProxyType
        from selenium.webdriver.remote.webelement import WebElement
        from selenium.webdriver.common.by import By
        from selenium.webdriver.common.keys import Keys
        break
    except ImportError:
        if not process_install_selenium:
            deps_tool.install_package('selenium')
            process_install_selenium = True
            continue
        raise
# 装载自有模块
from HiveNetLib.base_tools.run_tool import RunTool

__MOUDLE__ = 'simple_webdriver'  # 模块名
__DESCRIPT__ = u'selenium web driver的简单封装使用模块'  # 模块描述
__VERSION__ = '0.1.0'  # 版本
__AUTHOR__ = u'黎慧剑'  # 作者
__PUBLISH__ = '2021.07.15'  # 发布日期


class EnumWebDriverType(Enum):
    """
Example #11
0
import datetime
import logging
import traceback
import hashlib
from io import BytesIO, FileIO
# 根据当前文件路径将包路径纳入,在非安装的情况下可以引用到
sys.path.append(
    os.path.abspath(
        os.path.join(os.path.dirname(__file__), os.path.pardir,
                     os.path.pardir)))
# 动态添加包安装
import HiveNetLib.deps_tool as deps_tool
try:
    import netifaces
except ImportError:
    deps_tool.install_package('netifaces')
    import netifaces
# 引用自有模块
import HiveNetLib.base_tools.wget as wget
from HiveNetLib.base_tools.run_tool import RunTool
from HiveNetLib.base_tools.file_tool import FileTool

__MOUDLE__ = 'net_tool'  # 模块名
__DESCRIPT__ = u'网络处理相关工具'  # 模块描述
__VERSION__ = '0.1.0'  # 版本
__AUTHOR__ = u'黎慧剑'  # 作者
__PUBLISH__ = '2018.08.29'  # 发布日期


class NetTool(object):
    """