platform_config_util.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. from util.date_util import *
  26. import pandas as pd
  27. def get_yuewen_account_list():
  28. """
  29. description: 阅文账号列表
  30. return: [['email', 'appsecert']] ->list
  31. """
  32. return get_account_list('阅文', 'yuewen_account_config.csv')
  33. def get_zhangdu_account_list():
  34. """
  35. description: 掌读账号列表
  36. return: [['uid', 'appsecert', 'channel']] ->list
  37. """
  38. return get_account_list('掌读', 'zhangdu_account_config.csv')
  39. def get_huasheng_account_list():
  40. """
  41. description: 花生账号列表
  42. return: [['apiKey', 'apiSecurity', 'stage']] ->list
  43. """
  44. return get_account_list('花生', 'huasheng_account_config.csv')
  45. def get_zhangzhongyun_account_list():
  46. """
  47. description: 掌中云账号列表
  48. return: [['key', 'secert', 'stage']] ->list
  49. """
  50. return get_account_list('掌中云', 'zhangzhongyun_account_config.csv')
  51. def get_youshuge_account_list():
  52. """
  53. description: 悠书阁账号列表
  54. return: [['host_name', 'channel_id', 'secert_key', 'channel', 'stage']] ->list
  55. """
  56. return get_account_list('悠书阁', 'youshuge_account_config.csv')
  57. def get_yangguang_account_list():
  58. """
  59. des cription: 阳光账号列表
  60. return: [['host_name', 'channel_id', 'secert_key', 'channel', 'stage']] ->list
  61. """
  62. return get_account_list('阳光', 'yangguang_account_config.csv')
  63. def get_wending_account_list():
  64. """
  65. des cription: 文鼎账号列表
  66. return: [['consumerkey', 'secretkey', 'siteid', 'stage', 'account']] ->list
  67. """
  68. return get_account_list('文鼎', 'wending_account_config.csv')
  69. def get_qiyue_account_list():
  70. """
  71. des cription: 七悦账号列表
  72. return: [['stage','token']] ->list
  73. """
  74. return get_account_list('七悦', 'qiyue_account_config.csv')
  75. def get_account_list(platform, account_file_name):
  76. """
  77. description: 读取账号列表
  78. return: [['value1_1', 'value1_3'...]...] ->list
  79. """
  80. # 得到当前文件的父目录
  81. parent_dir_path = os.path.dirname(os.path.abspath('.'))
  82. # print(parent_dir_path)
  83. file_path = parent_dir_path + "/tests/conf/account/" + account_file_name
  84. # print('配置文件:', file_path)
  85. data = pd.read_csv(file_path, header=None, keep_default_na=False, encoding='utf8',converters={0:str})
  86. account = []
  87. for i in data.index:
  88. account.append(list(data.values[i]))
  89. account_list = list(account) # 若想用二维列表的形式读取即删掉此行语句
  90. print('读取到【{platform}】账号数量【{quantity}】个'.format(platform=platform, quantity=len(account_list)))
  91. return account_list
  92. def get_youshuge_order_query_time(st_unix, et_unix):
  93. """
  94. description: 悠书阁的订单查询是按天查询的,没有按小时查询,且每小时查询的时候要判断结束时间要比开始时间大一天,否则查询不到数据
  95. return: 2020-10-10,2020-10-11 -> (start_time,end_time)
  96. """
  97. start_time = time.strftime("%Y-%m-%d", time.localtime(st_unix))
  98. end_time = time.strftime("%Y-%m-%d", time.localtime(et_unix))
  99. if start_time == end_time:
  100. # 如果是同一天,则结束时间加一天
  101. end_time = time.strftime("%Y-%m-%d", time.localtime(et_unix + 86400))
  102. return start_time, end_time