add function
This commit is contained in:
parent
b9f6e47c55
commit
d9fd408dd6
@ -1,6 +1,9 @@
|
||||
import os
|
||||
import sys
|
||||
import appPublic.myjson as json
|
||||
try:
|
||||
import ujson as json
|
||||
except:
|
||||
import json
|
||||
from jinja2 import Environment,FileSystemLoader
|
||||
import codecs
|
||||
from appPublic.argsConvert import ArgsConvert
|
||||
@ -39,6 +42,7 @@ class MyTemplateEngine:
|
||||
self.env.globals.update({k:v})
|
||||
|
||||
def _render(self,template,data):
|
||||
# print('**********template=',template,'**data=',data,'type_data=',type(data),'************')
|
||||
uRet = template.render(**data)
|
||||
return uRet
|
||||
|
||||
|
@ -32,14 +32,17 @@ class RSA:
|
||||
text = pem.decode('utf8')
|
||||
f.write(text)
|
||||
|
||||
def write_publickey(self,public_key,fname):
|
||||
def publickeyText(self,public_key):
|
||||
pem = public_key.public_bytes(
|
||||
encoding=serialization.Encoding.PEM,
|
||||
format=serialization.PublicFormat.SubjectPublicKeyInfo
|
||||
)
|
||||
|
||||
with open(fname,'w') as f:
|
||||
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)
|
||||
|
||||
def read_privatekey(self,fname,password=None):
|
||||
|
@ -1,6 +1,9 @@
|
||||
from appPublic.rsa import RSA
|
||||
from appPublic.rc4 import RC4
|
||||
import ujson as json
|
||||
try:
|
||||
import ujson as json
|
||||
except:
|
||||
import json
|
||||
import random
|
||||
|
||||
class DeliverPacket:
|
||||
|
@ -53,7 +53,7 @@ def monthMaxDay(y,m):
|
||||
def date2str(dt=None):
|
||||
if dt is None:
|
||||
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):
|
||||
return '%02d:%02d:%02d' % (dt.hour,dt,minute,dt.second)
|
||||
|
Loading…
Reference in New Issue
Block a user