platform_config_util.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. # 得到当前文件的父目录
  27. parent_dir_path = os.path.dirname(os.path.abspath('.'))
  28. def get_yuewen_account_list():
  29. """
  30. description: 阅文账号列表
  31. return: [['email', 'appsecert']] ->list
  32. """
  33. return get_account_list('阅文', 'yuewen_account_config.csv')
  34. def get_zhangdu_account_list():
  35. """
  36. description: 掌读账号列表
  37. return: [['uid', 'appsecert', 'channel']] ->list
  38. """
  39. return get_account_list('掌读', 'zhangdu_account_config.csv')
  40. def get_huasheng_account_list():
  41. """
  42. description: 花生账号列表
  43. return: [['apiKey', 'apiSecurity', 'stage']] ->list
  44. """
  45. return get_account_list('花生', 'huasheng_account_config.csv')
  46. def get_zhangzhongyun_account_list():
  47. """
  48. description: 掌中云账号列表
  49. return: [['key', 'secert', 'stage']] ->list
  50. """
  51. return get_account_list('掌中云', 'zhangzhongyun_account_config.csv')
  52. def get_youshuge_account_list():
  53. """
  54. description: 悠书阁账号列表
  55. return: [['host_name', 'channel_id', 'secert_key', 'channel', 'stage']] ->list
  56. """
  57. return get_account_list('悠书阁', 'youshuge_account_config.csv')
  58. def get_account_list(platform, account_file_name):
  59. """
  60. description: 读取账号列表
  61. return: [['value1_1', 'value1_3'...]...] ->list
  62. """
  63. # print(parent_dir_path)
  64. file_path = parent_dir_path + "/tests/conf/account/" + account_file_name
  65. # print(file_path)
  66. data = pd.read_csv(file_path, header=None, encoding='utf8')
  67. account = []
  68. for i in data.index:
  69. account.append(list(data.values[i]))
  70. account_list = list(account) # 若想用二维列表的形式读取即删掉此行语句
  71. print('读取到【{platform}】账号数量【{quantity}】个'.format(platform=platform, quantity=len(account_list)))
  72. return account_list
  73. def get_zhangzhongyun_format_time(st_unix):
  74. """
  75. description: 掌中云的时间格式比较特殊,需要转换下
  76. return: 2020-09-25T00:00:00+08:00 -> str
  77. """
  78. return time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(st_unix)) + '+08:00'