platform_config_util.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. __title__ = '平台配置操作工具类'
  5. @Time : 2020/9/26 21:51
  6. @Author : Kenny-PC
  7. @Software: PyCharm
  8. # code is far away from bugs with the god animal protecting
  9. I love animals. They taste delicious.
  10. ┏┓ ┏┓
  11. ┏┛┻━━━┛┻┓
  12. ┃ ☃ ┃
  13. ┃ ┳┛ ┗┳ ┃
  14. ┃ ┻ ┃
  15. ┗━┓ ┏━┛
  16. ┃ ┗━━━┓
  17. ┃ 神兽保佑 ┣┓
  18. ┃ 永无BUG! ┏┛
  19. ┗┓┓┏━┳┓┏┛
  20. ┃┫┫ ┃┫┫
  21. ┗┻┛ ┗┻┛
  22. """
  23. import os
  24. import time
  25. import pandas as pd
  26. def get_yuewen_account_list():
  27. """
  28. description: 阅文账号列表
  29. return: [['email', 'appsecert']] ->list
  30. """
  31. return get_account_list('阅文', 'yuewen_account_config.csv')
  32. def get_zhangdu_account_list():
  33. """
  34. description: 掌读账号列表
  35. return: [['uid', 'appsecert', 'channel']] ->list
  36. """
  37. return get_account_list('掌读', 'zhangdu_account_config.csv')
  38. def get_huasheng_account_list():
  39. """
  40. description: 花生账号列表
  41. return: [['apiKey', 'apiSecurity', 'stage']] ->list
  42. """
  43. return get_account_list('花生', 'huasheng_account_config.csv')
  44. def get_zhangzhongyun_account_list():
  45. """
  46. description: 掌中云账号列表
  47. return: [['key', 'secert', 'stage']] ->list
  48. """
  49. return get_account_list('掌中云', 'zhangzhongyun_account_config.csv')
  50. def get_youshuge_account_list():
  51. """
  52. description: 悠书阁账号列表
  53. return: [['host_name', 'channel_id', 'secert_key', 'channel', 'stage']] ->list
  54. """
  55. return get_account_list('悠书阁', 'youshuge_account_config.csv')
  56. def get_yangguang_account_list():
  57. """
  58. des cription: 阳光账号列表
  59. return: [['host_name', 'channel_id', 'secert_key', 'channel', 'stage']] ->list
  60. """
  61. return get_account_list('阳光', 'yangguang_account_config.csv')
  62. def get_wending_account_list():
  63. """
  64. des cription: 文鼎账号列表
  65. return: [['consumerkey', 'secretkey', 'siteid', 'stage', 'account']] ->list
  66. """
  67. return get_account_list('文鼎', 'wending_account_config.csv')
  68. def get_qiyue_account_list():
  69. """
  70. des cription: 七悦账号列表
  71. return: [['stage','token']] ->list
  72. """
  73. return platform_config_util.get_account_list('七悦', 'qiyue_account_config.csv')
  74. def get_account_list(platform, account_file_name):
  75. """
  76. description: 读取账号列表
  77. return: [['value1_1', 'value1_3'...]...] ->list
  78. """
  79. # 得到当前文件的父目录
  80. parent_dir_path = os.path.dirname(os.path.abspath('.'))
  81. # print(parent_dir_path)
  82. file_path = parent_dir_path + "/tests/conf/account/" + account_file_name
  83. # print('配置文件:', file_path)
  84. data = pd.read_csv(file_path, header=None, keep_default_na=False, encoding='utf8')
  85. account = []
  86. for i in data.index:
  87. account.append(list(data.values[i]))
  88. account_list = list(account) # 若想用二维列表的形式读取即删掉此行语句
  89. print('读取到【{platform}】账号数量【{quantity}】个'.format(platform=platform, quantity=len(account_list)))
  90. return account_list
  91. def get_zhangzhongyun_query_time(st_unix, et_unix):
  92. """
  93. description: 掌中云的时间格式比较特殊,需要转换下
  94. return: 2020-09-25T00:00:00+08:00,2020-09-26T00:00:00+08:00 -> (start_time,end_time)
  95. """
  96. start_time = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(st_unix)) + '+08:00'
  97. end_time = time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(et_unix)) + '+08:00'
  98. return start_time, end_time
  99. def get_youshuge_order_query_time(st_unix, et_unix):
  100. """
  101. description: 悠书阁的订单查询是按天查询的,没有按小时查询,且每小时查询的时候要判断结束时间要比开始时间大一天,否则查询不到数据
  102. return: 2020-10-10,2020-10-11 -> (start_time,end_time)
  103. """
  104. start_time = time.strftime("%Y-%m-%d", time.localtime(st_unix))
  105. end_time = time.strftime("%Y-%m-%d", time.localtime(et_unix))
  106. if start_time == end_time:
  107. # 如果是同一天,则结束时间加一天
  108. end_time = time.strftime("%Y-%m-%d", time.localtime(et_unix + 86400))
  109. return start_time, end_time