98 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Python
		
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			3.3 KiB
		
	
	
	
		
			Python
		
	
	
| #!/usr/bin/env python
 | |
| # coding:utf-8
 | |
| import enum
 | |
| import os
 | |
| import sys
 | |
| import time
 | |
| 
 | |
| curr_dir = os.path.split(os.path.abspath(__file__))[0]
 | |
| sys.path.append(os.path.join(curr_dir, 'firebase_tools'))
 | |
| sys.path.append(os.path.join(curr_dir, 'google_drive'))
 | |
| sys.path.append(os.path.join(curr_dir, 'ipm'))
 | |
| 
 | |
| import ipm.wechat_alert as wechat
 | |
| import ipm.clear_cdn as clear_cdn
 | |
| 
 | |
| from notification_helper import NotificationHelper
 | |
| from firebase_tools.firebase_helper import FirebaseHelperInstance, FirebaseHelper
 | |
| from google_drive.google_sheet import GoogleSheetHelper
 | |
| 
 | |
| firebase_helper = FirebaseHelperInstance()
 | |
| sheet_helper = GoogleSheetHelper()
 | |
| time_start = time.time()
 | |
| 
 | |
| def calc_step_time(step:str):
 | |
|     global time_start
 | |
|     time_end = time.time()
 | |
|     print(f'{step}步骤完成|耗时: {(time_end - time_start):.0f}秒')
 | |
|     time_start = time.time()
 | |
| 
 | |
| class env(enum.Enum):
 | |
|     debug = 'debug'         # 调试环境
 | |
|     release = 'release'     # 发布环境
 | |
| 
 | |
| class platform(enum.Enum):
 | |
|     No = 'None'
 | |
|     Android = 'Android'
 | |
|     iOS = 'iOS'
 | |
| 
 | |
| # region 项目定义
 | |
| class project(enum.Enum):
 | |
|     dof = 'dof'
 | |
|     d2 = 'd2'
 | |
|     find_out = 'find_out'
 | |
|     find_master = 'find_master'
 | |
|     find_it = 'find_it'
 | |
|     find_object = 'find_object'
 | |
|     food_sort = 'food_sort'
 | |
| 
 | |
| # endregion
 | |
| 
 | |
| # region firebase接口
 | |
| def get_firebase_instance(project_id) -> FirebaseHelper:
 | |
|     if project_id == project.dof.value:
 | |
|         return firebase_helper.get_firebase_dof()
 | |
|     elif project_id == project.d2.value:
 | |
|         return firebase_helper.get_firebase_d2()
 | |
|     elif project_id == project.find_out.value:
 | |
|         return firebase_helper.get_firebase_find_out()
 | |
|     elif project_id == project.find_master.value:
 | |
|         return firebase_helper.get_firebase_find_master()
 | |
|     elif project_id == project.find_it.value:
 | |
|         return firebase_helper.get_firebase_find_it()
 | |
|     elif project_id == project.find_object.value:
 | |
|         return firebase_helper.get_firebase_find_object()
 | |
|     elif project_id == project.food_sort.value:
 | |
|         return firebase_helper.get_firebase_food_sort()
 | |
|     else:
 | |
|         return None
 | |
| # endregion
 | |
| 
 | |
| # region 企业微信通知接口
 | |
| HOOK_URL = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4d38d2a3-4fd7-41c3-a3b1-10af3ba639b4'
 | |
| notification = NotificationHelper(HOOK_URL)
 | |
| def wechat_alert():
 | |
|     wechat.wechat_alert(notification.get_msg(), notification.get_hook_url(), notification.get_people_list())
 | |
| def wechat_alert_message(message: str):
 | |
|     wechat.wechat_alert(message, notification.get_hook_url())
 | |
| def wechat_alert_exception(e: Exception):
 | |
|     wechat.wechat_alert(str(e), notification.get_hook_url(), "15036516116")
 | |
| # endregion
 | |
| 
 | |
| def get_project_cdn(project_id):
 | |
|     if project_id == project.dof.value:
 | |
|         return 'https://cdn3-dof.fungame.cloud'
 | |
|     elif project_id == project.d2.value:
 | |
|         return 'https://cdn3-dof.fungame.cloud'
 | |
|     elif project_id == project.find_out.value:
 | |
|         return 'https://cdn3-find-out.fungame.cloud'
 | |
|     elif project_id == project.find_master.value:
 | |
|         return 'https://cdn3-find-master.fungame.cloud'
 | |
|     elif project_id == project.find_it.value:
 | |
|         return 'https://cdn3-find-it.fungame.cloud'
 | |
|     elif project_id == project.find_object.value:
 | |
|         return 'https://cdn3-find-object.fungame.cloud'
 | |
|     elif project_id == project.food_sort.value:
 | |
|         return 'https://cdn3-food-sort.fungame.cloud'
 | |
|     else:
 | |
|         return None |