upgrade_alipay_app.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. import datetime
  4. import os
  5. import sys
  6. import bson
  7. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  8. sys.path.insert(0, PROJECT_ROOT)
  9. from script.base import init_env, get_logger
  10. logger = get_logger(__name__)
  11. init_env(interactive = True)
  12. from apps.web.core.models import WechatPayApp, AliApp
  13. # mchid = '1480791292'
  14. # sslcert_path = 'E:/cert/1480791292_20210528_cert/apiclient_cert.pem'
  15. # sslkey_path = 'E:/cert/1480791292_20210528_cert/apiclient_key.pem'
  16. def is_valid_string(str):
  17. try:
  18. bson._make_c_string(str)
  19. return True
  20. except Exception as e:
  21. return False
  22. #
  23. # apps = AliApp.objects().all()
  24. #
  25. # for app in apps: # type: AliApp
  26. # print('app id is: {}'.format(str(app.id)))
  27. #
  28. # if os.path.isfile(app.app_private_key_path):
  29. # with open(app.app_private_key_path) as f:
  30. # content = str(f.read())
  31. # if is_valid_string(content):
  32. # app.appPrivateKey = content
  33. # else:
  34. # print('ssl cert is not valid.')
  35. #
  36. # else:
  37. # print('ssl cert path is not exist.')
  38. #
  39. # if os.path.isfile(app.public_key_path):
  40. # with open(app.public_key_path) as f:
  41. # content = str(f.read())
  42. # if is_valid_string(content):
  43. # app.alipayPublicKey = content
  44. # else:
  45. # print('ssl key is not valid.')
  46. # else:
  47. # print('ssl key path is not exist.')
  48. #
  49. # app.dateTimeUpdated = datetime.datetime.now()
  50. #
  51. # print app.appPrivateKey
  52. # print app.alipayPublicKey
  53. #
  54. # app.save()
  55. # app = AliApp.objects(id='5fa9010ec3631dd06e35c709').first()
  56. # if app.signKeyType != 'cert':
  57. # print 'not valid'
  58. # else:
  59. # with open('F:\\publish\\alitransfer\\alipayCertPublicKey_RSA2.crt') as f:
  60. # content = str(f.read())
  61. # if is_valid_string(content):
  62. # app.publicKeyCert = content
  63. # app.dateTimeUpdated = datetime.datetime.now()
  64. # app.inhouse = True
  65. # app.save()
  66. # else:
  67. # print 'error'
  68. # with open('F:\\publish\\alitransfer\\appCertPublicKey_2021001191645419.crt') as f:
  69. # content = str(f.read())
  70. # if is_valid_string(content):
  71. # app.appPublicKeyCert = content
  72. # app.dateTimeUpdated = datetime.datetime.now()
  73. # # app.inhouse = True
  74. # app.save()
  75. # else:
  76. # print 'error'