Package: guolei-py3-components
guolei_py3_componentsa python3 components by guoleiutila common util modulefromguolei_py3_componentsimportutilutil.get_uuid_str(1)# use util other mehods ...@util.call_str_to_encrypt("md5")defencrypt_str():return"123456"print(encrypt_str())# output e10adc3949ba59abbe56e057f20f883etaobaoa taobao modulefromguolei_py3_componentsimporttaobao# get ip data# @see http://ip.taobao.com/instructions.htmltaobao.get_ip_data(ip="")wechata wechat operation class modulefromguolei_py3_componentsimportwechat# init wechat classwechat_obj=wechat.Wehcat("your appid","your appsecret")# get access tokenaccess_token=wechat_obj.get_access_token()# get js api ticketjs_api_ticket=wechat_obj.get_js_api_ticket(access_token)# get signaturessignatures=wechat_obj.get_signatures(js_api_ticket="",url="",type="shar1")# get code urlcode_url=wechat_obj.get_code_url(url="")# get openidopen_id=wechat_obj.get_open_id(code="")databasea database module# get pymysql conn objfromguolei_py3_componentsimportdatabasepymysql_conn_config={"host":"localhost","port":"root","user":"luis","passwd":"123456","db":"test","charset":"utf8",}pymysql_conn_obj=database.get_pymysql_connection(**pymysql_conn_config)# call pymysql execute by decoratorpymysql_conn_config={"host":"localhost","port":"root","user":"luis","passwd":"123456","db":"test","charset":"utf8",}pymysql_conn_obj=database.get_pymysql_connection(**pymysql_conn_config)@database.call_pymysql_execute(pymysql_conn_obj)defpymysql_execute():query="insert into tables...;"args={}returnquery,argsprint(pymysql_execute())# call pymysql find by decoratorfromguolei_py3_componentsimportdatabasepymysql_conn_config={"host":"localhost","port":"root","user":"luis","passwd":"123456","db":"test","charset":"utf8",}pymysql_conn_obj=database.get_pymysql_connection(**pymysql_conn_config)@database.call_pymysql_find(pymysql_conn_obj)defpymysql_find():query="select * from table;"args={}returnquery,argsprint(pymysql_find())# call pymysql find first by decoratorfromguolei_py3_componentsimportdatabasepymysql_conn_config={"host":"localhost","port":"root","user":"luis","passwd":"123456","db":"test","charset":"utf8",}pymysql_conn_obj=database.get_pymysql_connection(**pymysql_conn_config)@database.call_pymysql_find_first(pymysql_conn_obj)defpymysql_find_first():# You'd better add limit 1 at the end of SQLquery="select * from table limit 1;"args={}returnquery,argsprint(pymysql_find_first())# get strictredis conn objfromguolei_py3_componentsimportdatabaseconn_config={"host":"localhost","port":6379,"db":0,"password":'123456'}strictredis_conn_obj=database.get_strictredis_connection(**conn_config)# call strictredis command by decoratorfromguolei_py3_componentsimportdatabaseconn_config={...},strictredis_conn_obj=database.get_strictredis_connection(**conn_config)@call_strictredis_command(strictredis_conn_obj,get)defstrictredis_command():return(args),{..kwargs}loggerfromguolei_py3_componentsimportloggergetloggingloggerobjlogging_logger_obj=logger.get_logging_logger(is_save_file=True)# call logging logger log by decoratorfromguolei_py3_componentsimportloggerlogging_logger_obj=logger.get_logging_logger(is_save_file=True)@logger.call_logging_logger_log(logging_logger_obj,attr,prefix)defa():return""mailfromguolei_py3_components.mailimportMailmail_obj=Mail()mail_obj.smtp_host="smtp.exmail.qq.com"mail_obj.smtp_port=465mail_obj.sender_name="sender<sender@qq.com>"mail_obj.sender_account="sender@qq.com"mail_obj.sender_password="123456"mail_obj.to_addresses=["receiver<receiver@qq.com>"]mail_obj.cc_addresses=[]mail_obj.bcc_addresses=[]attachments=[{"name":"attachment.txt","path":"/home/attachment.txt"}]mail_obj.smtp_ssl_send_mail("subject","message",attachments)otherother component developing...