12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- # -*- coding: utf-8 -*-
- # !/usr/bin/env python
- import datetime
- import os
- import sys
- import bson
- PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
- sys.path.insert(0, PROJECT_ROOT)
- from script.base import init_env, get_logger
- logger = get_logger(__name__)
- init_env(interactive = True)
- from apps.web.core.models import WechatPayApp, AliApp
- # mchid = '1480791292'
- # sslcert_path = 'E:/cert/1480791292_20210528_cert/apiclient_cert.pem'
- # sslkey_path = 'E:/cert/1480791292_20210528_cert/apiclient_key.pem'
- def is_valid_string(str):
- try:
- bson._make_c_string(str)
- return True
- except Exception as e:
- return False
- #
- # apps = AliApp.objects().all()
- #
- # for app in apps: # type: AliApp
- # print('app id is: {}'.format(str(app.id)))
- #
- # if os.path.isfile(app.app_private_key_path):
- # with open(app.app_private_key_path) as f:
- # content = str(f.read())
- # if is_valid_string(content):
- # app.appPrivateKey = content
- # else:
- # print('ssl cert is not valid.')
- #
- # else:
- # print('ssl cert path is not exist.')
- #
- # if os.path.isfile(app.public_key_path):
- # with open(app.public_key_path) as f:
- # content = str(f.read())
- # if is_valid_string(content):
- # app.alipayPublicKey = content
- # else:
- # print('ssl key is not valid.')
- # else:
- # print('ssl key path is not exist.')
- #
- # app.dateTimeUpdated = datetime.datetime.now()
- #
- # print app.appPrivateKey
- # print app.alipayPublicKey
- #
- # app.save()
- # app = AliApp.objects(id='5fa9010ec3631dd06e35c709').first()
- # if app.signKeyType != 'cert':
- # print 'not valid'
- # else:
- # with open('F:\\publish\\alitransfer\\alipayCertPublicKey_RSA2.crt') as f:
- # content = str(f.read())
- # if is_valid_string(content):
- # app.publicKeyCert = content
- # app.dateTimeUpdated = datetime.datetime.now()
- # app.inhouse = True
- # app.save()
- # else:
- # print 'error'
- # with open('F:\\publish\\alitransfer\\appCertPublicKey_2021001191645419.crt') as f:
- # content = str(f.read())
- # if is_valid_string(content):
- # app.appPublicKeyCert = content
- # app.dateTimeUpdated = datetime.datetime.now()
- # # app.inhouse = True
- # app.save()
- # else:
- # print 'error'
|