
    6h                     f    d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlZg i ddfdZdS )    N)platform_config)get_all_platform)create_db_connection)insert_chat_dataFc                   K   d }| D ]5}t          j        |          }	 t                      }|                    d          |                    d          z   }|                    d          }|                    d          }	t          j        |	                                                                          }
t          j        |||
d|                    d                    }|j	        dk    r|
                                                    d	          }|                    d
          |                    d          }|                    d          }|                    d          }|                    d          }t          ||                    d          |                    d          z             }t          t          fd|          d           }|                    d          }|                    d          |                    d          z   d| z   }dddd| d}| d| | d| ||dd|sdnddddd}t          j        |||          }|j	        dk    rnd| d|sdnd d  d!|s| d| nd" d#|s| d| nd" d$|j	         d}t          || d%|d&         d'         |f(           |                    |           d {V  # t"          $ rU}d)| d* d+| d)}t          || d,|d&         d'         |f(           |                    |           d {V  Y d }~/d }~ww xY wd S )-NAPI_URLLOGINlogin_accountlogin_password)accountpasswordheaders)urljsonr      tokenplatforms_dates_timee_datee_timeMAINTAIN)
auth_tokenapi_urlc                     | d         k    S )Nr    )xmaintain_targets    8/Users/gualin/Documents/wsky_tg_auto_maintain/api/api.py<lambda>z#call_maintain_api.<locals>.<lambda>.   s    Qz]o5U     uid/zapplication/jsonTWDzBearer )zContent-TypeCurrencyExchange_codeAuthorization    r   )r   temp_maintenance_start_timetemp_maintenance_end_timemaintenance_start_timemaintenance_end_timestatus_frontstatus_backendis_under_maintenanceis_scheduledis_exclusive_brandenable_buffer_walletz%
                                    z&
                                    
u   維護流程已確認u   維護流程已取消u5   
                                    
維護平台：u;   
                                    
開始維護時間：-u;   
                                    
結束維護時間：u8   
                                    
API回應代碼：u%   維護流程已確認,API呼叫成功from
first_name)
connectiondataz
                        u)   
                        
維護平台：u2   
                        
API呼叫失敗原因：u%   維護流程已確認,API呼叫失敗)r   getr   hashlibmd5encode	hexdigestrequestspoststatus_coder   r   nextfilterputr   reply	Exception)maintain_platformfmt_datacancel_maintainbotr7   r   config	login_apir   r   md5_password	login_resr   r   r   r   r   all_platformplatform_dataplatform_uidmaintain_apir   r8   responseresponse_msge	error_msgr   s                              @r   call_maintain_apirV      s     J% a a $X..^	-//J

9--

70C0CCIjj11Gzz"233H";x'8'899CCEEL & ,  

9--  I $++!((,,W55"*,,z":":!h//!h//!h//!h///56::V_K`K`cicmcmnxcycyKyzzz $V,U,U,U,UVb%c%cdh i i,0077%zz)44vzz*7M7MMPbT`PbPbb %7 %%*%6u%6%6	  !06<3G3Gv3G3G390D0DF0D0D.4,2#$%&4C+J11#$)*+,  $<$#   '3..$(%-$( $(FU'r'>'>[r$( $( 7F$( $( Yh<pv<P<P<P<P<Pmp	$( $(
 Yh<pv<P<P<P<P<Pmp$( $( :B9M$( $( $(L %#-'NNNK5(    ))L111111111 	 	 	! *9  45  I
 #-'NNNK5(    ))I&&&&&&&&&HHHH	ea as   J;K
L<'A
L77L<)ossysr>   config.platform_configr   utils.get_all_platformr   db.db_connectionr   db.db_operationsr   r:   rV   r   r!   r   <module>r]      s    				 



  2 2 2 2 2 2 3 3 3 3 3 3 1 1 1 1 1 1 - - - - - - 02bQV[_ d d d d d dr!   