36
36
windows = bool (os_name == 'nt' )
37
37
38
38
if windows :
39
- from subprocess import CREATE_NO_WINDOW , HIGH_PRIORITY_CLASS
39
+ from subprocess import CREATE_NO_WINDOW
40
40
else :
41
41
from os import getpgid , killpg
42
42
@@ -217,20 +217,16 @@ def kill_subprocess(subproc):
217
217
except Exception as ke :
218
218
print (f'kill_subprocess: { ke } ' )
219
219
220
- def compress_with_stats ( data ,compression ):
220
+ def compress_with_header_update ( header , data ,compression , datalabel , zip_file ):
221
221
t0 = perf_counter ()
222
222
data_ser = dumps (data )
223
223
data_ser_compr = ZstdCompressor (level = compression ,threads = - 1 ).compress (data_ser )
224
224
t1 = perf_counter ()
225
225
tdiff = t1 - t0
226
226
227
- return data_ser_compr ,tdiff ,asizeof (data_ser_compr ),asizeof (data_ser ),asizeof (data )
228
-
229
- def compress_with_header_update (header ,data ,compression ,datalabel ,zip_file ):
230
- data_compr ,tdiff ,size_1 ,size_2 ,size_3 = compress_with_stats (data ,compression )
231
- header .zipinfo [datalabel ]= (size_1 ,size_2 ,size_3 )
232
- header .compression_time [datalabel ] = tdiff
233
- zip_file .writestr (datalabel ,data_compr )
227
+ header .zipinfo [datalabel ]= (asizeof (data_ser_compr ),asizeof (data_ser ),asizeof (data ))
228
+ header .compression_time [datalabel ] = tdiff
229
+ zip_file .writestr (datalabel ,data_ser_compr )
234
230
235
231
CREATION_CODE = 0
236
232
EXPORT_CODE = 1
@@ -848,7 +844,8 @@ def find_items(self,
848
844
size_min ,size_max ,
849
845
timestamp_min ,timestamp_max ,
850
846
name_search_kind ,name_func_to_call ,
851
- cd_search_kind ,cd_func_to_call ):
847
+ cd_search_kind ,cd_func_to_call ,
848
+ print_info_fn ):
852
849
853
850
self .find_results = []
854
851
@@ -872,7 +869,7 @@ def find_items(self,
872
869
search_list_pop = search_list .pop
873
870
search_list_append = search_list .append
874
871
875
- cd_search_kind_is_regezp_glob_or_fuzzy = bool (cd_search_kind in ('regexp' ,'glob' ,'fuzzy' ))
872
+ cd_search_kind_is_regexp_glob_or_fuzzy = bool (cd_search_kind in ('regexp' ,'glob' ,'fuzzy' ))
876
873
cd_search_kind_is_dont_or_without = bool (cd_search_kind in ('dont' ,'without' ))
877
874
878
875
when_folder_may_apply = bool (cd_search_kind_is_dont_or_without and not use_size and not use_timestamp )
@@ -893,11 +890,6 @@ def find_items(self,
893
890
#if check_abort():
894
891
# break
895
892
896
- search_progress_update_quant += 1
897
- if search_progress_update_quant > 1024 :
898
- results_queue_put ([search_progress ])
899
- search_progress_update_quant = 0
900
-
901
893
search_progress += 1
902
894
903
895
name_nr ,code ,size ,mtime = data_entry [0 :4 ]
@@ -961,7 +953,7 @@ def find_items(self,
961
953
if not name_func_to_call (name ):
962
954
continue
963
955
except Exception as e :
964
- self . log . error ( 'find_items(1):%s' , str ( e ) )
956
+ print_info_fn ( f 'find_items(1):{ e } ' )
965
957
continue
966
958
967
959
#oczywistosc
@@ -971,18 +963,27 @@ def find_items(self,
971
963
if cd_search_kind_is_any :
972
964
if not has_cd or not cd_ok :
973
965
continue
974
- elif cd_search_kind_is_regezp_glob_or_fuzzy :
966
+ elif cd_search_kind_is_regexp_glob_or_fuzzy :
975
967
if has_cd and cd_ok :
976
968
cd_data = self_customdata [cd_nr ][2 ]
977
969
else :
978
970
continue
979
971
980
972
if cd_func_to_call :
981
973
try :
982
- if not cd_func_to_call (cd_data ):
983
- continue
974
+ if True : #entire file
975
+ if not cd_func_to_call (cd_data ):
976
+ continue
977
+ else :
978
+ found = False
979
+ for line in cd_data .splitlines ():
980
+ if cd_func_to_call (line ):
981
+ found = True
982
+ break
983
+ if not found :
984
+ continue
984
985
except Exception as e :
985
- self . log . error ( 'find_items(2):%s' , str ( e ) )
986
+ print_info_fn ( f 'find_items(2):{ e } ' )
986
987
continue
987
988
988
989
else :
@@ -1000,6 +1001,12 @@ def find_items(self,
1000
1001
results_queue_put ([search_progress ,size ,mtime ,* next_level ])
1001
1002
search_progress_update_quant = 0
1002
1003
1004
+ if search_progress_update_quant > 1024 :
1005
+ results_queue_put ([search_progress ])
1006
+ search_progress_update_quant = 0
1007
+ else :
1008
+ search_progress_update_quant += 1
1009
+
1003
1010
results_queue_put ([search_progress ])
1004
1011
results_queue_put (True )
1005
1012
@@ -1345,6 +1352,7 @@ def repack_record(self,record,new_label,new_compression,keep_cd,update_callback)
1345
1352
messages = []
1346
1353
1347
1354
new_file_path = sep .join ([self .db_dir ,f'rep.{ int (time ())} .dat' ])
1355
+
1348
1356
try :
1349
1357
src_file = record .file_path
1350
1358
@@ -1470,7 +1478,7 @@ def find_items_in_records_check(self,
1470
1478
filename_fuzzy_threshold ,cd_fuzzy_threshold ):
1471
1479
1472
1480
sel_range = [range_par ] if range_par else self .records
1473
- self .files_search_quant = sum ([record .header .quant_files for record in sel_range ])
1481
+ self .files_search_quant = sum ([record .header .quant_files + record . header . quant_folders for record in sel_range ])
1474
1482
1475
1483
if self .files_search_quant == 0 :
1476
1484
return 1
@@ -1530,14 +1538,16 @@ def find_items_in_records(self,
1530
1538
records_to_process .sort (reverse = True ,key = lambda x : x .header .quant_files )
1531
1539
1532
1540
record_commnad_list = {}
1541
+ is_frozen = bool (getattr (sys , 'frozen' , False ))
1542
+
1533
1543
for record_nr ,record in enumerate (records_to_process ):
1534
1544
if windows :
1535
- if getattr ( sys , 'frozen' , False ) :
1545
+ if is_frozen :
1536
1546
curr_command_list = record_commnad_list [record_nr ] = ['record.exe' , 'load' ,record .file_path ]
1537
1547
else :
1538
1548
curr_command_list = record_commnad_list [record_nr ] = ['python' ,'src\\ record.py' , 'load' ,record .file_path ]
1539
1549
else :
1540
- if getattr ( sys , 'frozen' , False ) :
1550
+ if is_frozen :
1541
1551
curr_command_list = record_commnad_list [record_nr ] = ['./record' , 'load' ,record .file_path ]
1542
1552
else :
1543
1553
curr_command_list = record_commnad_list [record_nr ] = ['python3' ,'./src/record.py' , 'load' ,record .file_path ]
@@ -1628,8 +1638,8 @@ def threaded_run(record_nr,commands_list,results_list,progress_list,info_list,pr
1628
1638
else :
1629
1639
info_list [record_nr ].append (line .strip ())
1630
1640
except Exception as e :
1631
- print ('threaded_run work error:' , e , line )
1632
- info_list [record_nr ].append (f'threaded_run work error: { e } line: { line } ' )
1641
+ print (f 'threaded_run work error:{ e } line: { line } ' )
1642
+ info_list [record_nr ].append (f'threaded_run work error:{ e } line:{ line } ' )
1633
1643
else :
1634
1644
if subprocess_poll () is not None :
1635
1645
break
0 commit comments