From d9fd408dd67a93a34b6a50f91ca6be3369727085 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 16 Sep 2019 15:11:14 +0800 Subject: [PATCH] add function --- appPublic/myTE.py | 6 +++++- appPublic/rsa.py | 11 +++++++---- appPublic/rsaPeer.py | 7 +++++-- appPublic/timeUtils.py | 2 +- setup.py | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/appPublic/myTE.py b/appPublic/myTE.py index 6291e6d..a880212 100644 --- a/appPublic/myTE.py +++ b/appPublic/myTE.py @@ -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 diff --git a/appPublic/rsa.py b/appPublic/rsa.py index ad20fc1..7630927 100755 --- a/appPublic/rsa.py +++ b/appPublic/rsa.py @@ -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 ) - + text = pem.decode('utf8') + return text + + def write_publickey(self,public_key,fname): + text = self.publickeyText(public_key) with open(fname,'w') as f: - text = pem.decode('utf8') f.write(text) def read_privatekey(self,fname,password=None): @@ -167,4 +170,4 @@ if __name__ == '__main__': x = r.encode(ypub,text) ntext = r.decode(ypri,x) print(text,'<==>',ntext) - \ No newline at end of file + diff --git a/appPublic/rsaPeer.py b/appPublic/rsaPeer.py index 5933141..d54a99b 100755 --- a/appPublic/rsaPeer.py +++ b/appPublic/rsaPeer.py @@ -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: @@ -122,4 +125,4 @@ Twisted 18.9.0 documentation » Twisted Names (DNS) » Developer Guides » ''' print('<===>') print(c) print('<===>') - print(newtxt) \ No newline at end of file + print(newtxt) diff --git a/appPublic/timeUtils.py b/appPublic/timeUtils.py index 7e50f8a..91df2a0 100755 --- a/appPublic/timeUtils.py +++ b/appPublic/timeUtils.py @@ -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) diff --git a/setup.py b/setup.py index 1018bcf..3771454 100755 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ from setuptools import setup, find_packages # python setup.py bdist_egg generate a egg file # Release information about eway -version = "5.0.18" +version = "5.1.1" name = "appPublic" description = "appPublic" author = "yumoqing"