add function

This commit is contained in:
yumoqing 2019-09-16 15:11:14 +08:00
parent b9f6e47c55
commit d9fd408dd6
5 changed files with 19 additions and 9 deletions

View File

@ -1,6 +1,9 @@
import os import os
import sys import sys
import appPublic.myjson as json try:
import ujson as json
except:
import json
from jinja2 import Environment,FileSystemLoader from jinja2 import Environment,FileSystemLoader
import codecs import codecs
from appPublic.argsConvert import ArgsConvert from appPublic.argsConvert import ArgsConvert
@ -39,6 +42,7 @@ class MyTemplateEngine:
self.env.globals.update({k:v}) self.env.globals.update({k:v})
def _render(self,template,data): def _render(self,template,data):
# print('**********template=',template,'**data=',data,'type_data=',type(data),'************')
uRet = template.render(**data) uRet = template.render(**data)
return uRet return uRet

View File

@ -32,14 +32,17 @@ class RSA:
text = pem.decode('utf8') text = pem.decode('utf8')
f.write(text) f.write(text)
def write_publickey(self,public_key,fname): def publickeyText(self,public_key):
pem = public_key.public_bytes( pem = public_key.public_bytes(
encoding=serialization.Encoding.PEM, encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo format=serialization.PublicFormat.SubjectPublicKeyInfo
) )
with open(fname,'w') as f:
text = pem.decode('utf8') text = pem.decode('utf8')
return text
def write_publickey(self,public_key,fname):
text = self.publickeyText(public_key)
with open(fname,'w') as f:
f.write(text) f.write(text)
def read_privatekey(self,fname,password=None): def read_privatekey(self,fname,password=None):

View File

@ -1,6 +1,9 @@
from appPublic.rsa import RSA from appPublic.rsa import RSA
from appPublic.rc4 import RC4 from appPublic.rc4 import RC4
try:
import ujson as json import ujson as json
except:
import json
import random import random
class DeliverPacket: class DeliverPacket:

View File

@ -53,7 +53,7 @@ def monthMaxDay(y,m):
def date2str(dt=None): def date2str(dt=None):
if dt is None: if dt is None:
dt = curDatetime() dt = curDatetime()
return '%04d-%02d-%-02d' % (dt.year,dt.month,dt.day) return '%04d-%02d-%02d' % (dt.year,dt.month,dt.day)
def time2str(dt): def time2str(dt):
return '%02d:%02d:%02d' % (dt.hour,dt,minute,dt.second) return '%02d:%02d:%02d' % (dt.hour,dt,minute,dt.second)

View File

@ -9,7 +9,7 @@ from setuptools import setup, find_packages
# python setup.py bdist_egg generate a egg file # python setup.py bdist_egg generate a egg file
# Release information about eway # Release information about eway
version = "5.0.18" version = "5.1.1"
name = "appPublic" name = "appPublic"
description = "appPublic" description = "appPublic"
author = "yumoqing" author = "yumoqing"