hwj35
2026-03-17 98ef95c03b6a5cebc8e8abe9fedcf84f2ffdbac7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
½ic@s¸dZddlZddlZddlZddlZddlmZddlmZddlm    Z    edddgƒZ
d    dd
„ƒYZ d dd „ƒYZ d dd„ƒYZ dS(s-
Îļþ¹ÜÀíÄ£¿é
¸ºÔðÈÕÖ¾ÎļþµÄ´´½¨¡¢Ð´ÈëºÍ¹ÜÀí
iÿÿÿÿN(t
namedtuple(t packet_logger(t
ClientsMgrtFileInfot    server_idt
event_typetFileWriteStatscBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(s ÎļþдÈëͳ¼ÆcCs%tjƒ|_d|_d|_dS(Ni(t    threadingtLocktlockt success_countt
fail_count(tself((s .\\EventServerPY\file_manager.pyt__init__s    cCs#|j|jd7_WdQXdS(Ni(R    R
(R ((s .\\EventServerPY\file_manager.pyt add_successs
cCs#|j|jd7_WdQXdS(Ni(R    R (R ((s .\\EventServerPY\file_manager.pytadd_fail!s
cCs|j |jSWdQXdS(N(R    R
(R ((s .\\EventServerPY\file_manager.pytget_success_count%s
cCs|j |jSWdQXdS(N(R    R (R ((s .\\EventServerPY\file_manager.pytget_fail_count)s
cCs&|jd|_d|_WdQXdS(Ni(R    R
R (R ((s .\\EventServerPY\file_manager.pytreset-s
    (    t__name__t
__module__t__doc__R RRRRR(((s .\\EventServerPY\file_manager.pyRs                    t    WriteFilecBs;eZdZd„Zd„Zd„Zd„Zd„ZRS(sµ¥¸öÎļþдÈëÆ÷cCs;||_d|_t|_||_||_|jƒdS(N(tfilenametNonet file_handletFalsetis_readytsuccess_callbackt fail_callbackt    open_file(R RRR((s .\\EventServerPY\file_manager.pyR 6s                     cCs›y`tjj|jƒ}|rAtjj|ƒ rAtj|ƒnt|jdƒ|_t|_    Wn4t
k
r–}t |_    d|jt |ƒfGHnXdS(s´ò¿ªÎļþtabs.[WriteFile] Failed to open file: %s, error: %sN( tostpathtdirnameRtexiststmakedirstopenRtTrueRt    ExceptionRtstr(R tdir_pathte((s .\\EventServerPY\file_manager.pyR>s     cCsÃ|js#|jr|jƒntSyN|djdƒ}|jj|ƒ|jjƒ|jrl|jƒntSWnKt    k
r¾}d|j
t |ƒfGHt|_|jrº|jƒntSXdS(sдÈë×Ö·û´®Êý¾Ýs
tgbks*[WriteFile] Failed to write: %s, error: %sN( RRRtencodeRtwritetflushRR&R'RR((R tdatatlineR*((s .\\EventServerPY\file_manager.pyt write_stringMs"                        cCs=|jr9y|jjƒWnnXd|_t|_ndS(s¹Ø±ÕÎļþN(RtcloseRRR(R ((s .\\EventServerPY\file_manager.pyR2ds        cCs|jƒdS(N(R2(R ((s .\\EventServerPY\file_manager.pyt__del__ns(RRRR RR1R2R3(((s .\\EventServerPY\file_manager.pyR3s                 
tFileMgrcBs_eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z    d„Z
d    „Z RS(
s
Îļþ¹ÜÀíÆ÷cCs||_tjƒ|_i|_tƒ|_|jjƒ|_t    j
j |jƒs™yt    j |jƒWq™t k
r•}d|jt|ƒfGHq™XndS(Ns1[FileMgr] Failed to create log dir: %s, error: %s(tconfigRRR    tfile_mapRtstatstget_log_file_pathtlog_pathR R!R#R$R'R((R R5R*((s .\\EventServerPY\file_manager.pyR us         cCsÎtjƒ}|j|ƒ}|dkr>tjd|dƒnt||ƒ}|jr||jkrv|j|ƒnC|j|}|j    ||ƒs¹|j
ƒ|j|=|j|ƒn|j|SWdQXdS(s»ñÈ¡ÎļþдÈëʵÀýis@FileMgr: WARNING - cid=%d has no server_id set! Defaulting to S0tWARNN( Rtinstancetget_client_server_idRtlog_textRR    R6t_create_file_writert_check_file_validR2(R tcidRt clients_mgrRt    file_infot
write_file((s .\\EventServerPY\file_manager.pyt get_instanceƒs  
 
 
c    Cs|jjƒ}d|j}tjj|j|ƒ}tjjƒj    dƒ}tjj||ƒ}|dkrƒd|j
|f}n|dkr½tjjƒj    dƒ}d|j
|f}nG|dkr÷tjjƒj    dƒ}d|j
|f}n d    |j
}tjj||ƒS(
s »ñÈ¡Îļþ·¾¶sS%ds%Y-%m-%dis    %s_%s.txtis %Y-%m-%d_%His %Y%m%d_%H%M%Ss%s.txt( R5tget_write_modeRR R!tjoinR9tdatetimetnowtstrftimeR(    R RBt
write_modet server_foldert folder_pathtdate_strt date_folderRt date_time_str((s .\\EventServerPY\file_manager.pyt_get_file_pathœs     cCs |js tS|jjƒ}tjjƒjdƒ}||jkrGtS|dkrœ|jjƒd}y)t    j
j |jƒ}||krŽtSWqœqœXnt S(s¼ì²éÎļþÊÇ·ñÓÐЧ(ÊÇ·ñÐèÒªÇл»)s%Y-%m-%dii( RRR5RERGRHRIRtget_max_file_sizeR R!tgetsizeR&(R RCRBRJt current_datetmax_sizet    file_size((s .\\EventServerPY\file_manager.pyR?µs      cCs>|j|ƒ}t||jj|jjƒ}||j|<dS(s´´½¨ÎļþдÈëÆ÷N(RPRR7RRR6(R RBtfilepathRC((s .\\EventServerPY\file_manager.pyR>Ìs     cCs|j||ƒ}|j|ƒS(s дÈëʼþÊý¾Ý(RDR1(R R@Rt
event_dataRC((s .\\EventServerPY\file_manager.pyt write_eventÖscCs |jjƒS(s»ñÈ¡³É¹¦Ð´Èë´ÎÊý(R7R(R ((s .\\EventServerPY\file_manager.pyRÛscCs |jjƒS(s»ñȡʧ°ÜдÈë´ÎÊý(R7R(R ((s .\\EventServerPY\file_manager.pyRßscCsE|j6x!|jjƒD]}|jƒqW|jjƒWdQXdS(s ¹Ø±ÕËùÓÐÎļþN(R    R6tvaluesR2tclear(R RC((s .\\EventServerPY\file_manager.pyt    close_allãs
( RRRR RDRPR?R>RXRRR[(((s .\\EventServerPY\file_manager.pyR4rs                    
            ((((RR ttimeRGRt collectionsRRtclients_managerRRRRR4(((s .\\EventServerPY\file_manager.pyt<module>s    ?