@@ -126,17 +126,21 @@ def caretaker(signal_file):
126
126
sys_stdout_flush = sys .stdout .flush
127
127
lines_non_stop = 0
128
128
129
+ json_dumps_loc = json_dumps
130
+ stdout_data_queue_loc = stdout_data_queue
131
+ path_exists_loc = path_exists
132
+
129
133
def flush_last_data_not_printed (flush ):
130
134
nonlocal last_data_not_printed
131
135
if last_data_not_printed :
132
- print (json_dumps (last_data_not_printed ),flush = flush )
136
+ print (json_dumps_loc (last_data_not_printed ),flush = flush )
133
137
last_data_not_printed = None
134
138
135
139
while True :
136
140
now = perf_counter ()
137
141
now_grater_than_next_time_print = bool (now > next_time_print )
138
142
139
- if stdout_data_queue :
143
+ if stdout_data_queue_loc :
140
144
data ,always = stdout_data_queue_get ()
141
145
142
146
if data == True :
@@ -146,7 +150,7 @@ def flush_last_data_not_printed(flush):
146
150
flush_last_data_not_printed (False )
147
151
148
152
if always or now_grater_than_next_time_print :
149
- print (json_dumps (data ),flush = True )
153
+ print (json_dumps_loc (data ),flush = True )
150
154
next_time_print = now + print_min_time_period
151
155
lines_non_stop += 1
152
156
last_data_not_printed = None
@@ -163,7 +167,7 @@ def flush_last_data_not_printed(flush):
163
167
164
168
if now > next_signal_file_check :
165
169
next_signal_file_check = now + signal_file_check_period
166
- if path_exists (signal_file ):
170
+ if path_exists_loc (signal_file ):
167
171
try :
168
172
with open (signal_file ,'r' ) as sf :
169
173
got_int = int (sf .read ().strip ())
@@ -174,7 +178,7 @@ def flush_last_data_not_printed(flush):
174
178
except Exception as pe :
175
179
print_info (f'check_abort error:{ pe } ' )
176
180
177
- sleep (0.01 )
181
+ sleep (0.001 )
178
182
179
183
sys .exit (0 ) #thread
180
184
@@ -265,20 +269,20 @@ def proper_exit(code):
265
269
cd_glob = bool (find_cd_search_kind == 'glob' )
266
270
cd_fuzzy = bool (find_cd_search_kind == 'fuzzy' )
267
271
cd_error = bool (find_cd_search_kind == 'error' )
272
+ cd_empty = bool (find_cd_search_kind == 'empty' )
273
+ cd_aborted = bool (find_cd_search_kind == 'aborted' )
268
274
cd_without = bool (find_cd_search_kind == 'without' )
269
275
cd_ok = bool (find_cd_search_kind == 'any' )
270
276
271
277
if cd_regexp :
272
278
custom_data_needed = True
273
- cd_search_kind = 'regexp'
274
279
if res := test_regexp (cd_expr ):
275
280
proper_exit (res )
276
281
re_obj_cd = re_compile (cd_expr , MULTILINE | DOTALL )
277
282
cd_func_to_call = lambda x : re_obj_cd .match (x )
278
283
279
284
elif cd_glob :
280
285
custom_data_needed = True
281
- cd_search_kind = 'glob'
282
286
if cd_case_sens :
283
287
re_obj_cd = re_compile (translate (cd_expr ), MULTILINE | DOTALL )
284
288
cd_func_to_call = lambda x : re_obj_cd .match (x )
@@ -287,19 +291,17 @@ def proper_exit(code):
287
291
cd_func_to_call = lambda x : re_obj_cd .match (x )
288
292
elif cd_fuzzy :
289
293
custom_data_needed = True
290
- cd_search_kind = 'fuzzy'
291
294
cd_func_to_call = lambda x : bool (SequenceMatcher (None ,cd_expr , x ).ratio ()> cd_fuzzy_threshold )
292
295
elif cd_without :
293
- cd_search_kind = 'without'
296
+ cd_func_to_call = None
297
+ elif cd_empty :
294
298
cd_func_to_call = None
295
299
elif cd_error :
296
- cd_search_kind = 'error'
297
300
cd_func_to_call = None
298
301
elif cd_ok :
299
- cd_search_kind = 'any'
300
302
cd_func_to_call = None
301
303
else :
302
- cd_search_kind = 'dont'
304
+ # cd_search_kind='dont'
303
305
cd_func_to_call = None
304
306
305
307
#####################################################################
@@ -319,7 +321,7 @@ def proper_exit(code):
319
321
size_min ,size_max ,
320
322
t_min ,t_max ,
321
323
name_search_kind ,name_func_to_call ,
322
- cd_search_kind ,cd_func_to_call ,
324
+ find_cd_search_kind ,cd_func_to_call ,
323
325
print_info )
324
326
except Exception as fe :
325
327
print_info (f'find_items error:{ fe } ' )
@@ -334,32 +336,32 @@ def proper_exit(code):
334
336
with open (sep .join ([comm_dir ,SCAN_DAT_FILE ]),"rb" ) as f :
335
337
create_list = loads (ZstdDecompressor ().decompress (f .read ()))
336
338
337
- label ,path_to_scan ,check_dev ,cde_list = create_list
339
+ label ,path_to_scan ,check_dev ,compression_level , threads , cde_list = create_list
338
340
except Exception as e :
339
341
print_info (f'create error:{ e } ' )
340
342
proper_exit (2 )
341
343
else :
342
344
new_record = LibrerRecord (label = label ,scan_path = path_to_scan )
343
345
344
346
try :
345
- print_func ([ 'stage' ,0 ] ,True )
347
+ print_func (( 'stage' ,0 ) ,True )
346
348
new_record .scan (print_func ,abort_list ,tuple (cde_list ),check_dev )
347
349
except Exception as fe :
348
350
print_info (f'scan error:{ fe } ' )
349
351
else :
350
352
if not abort_list [0 ]:
351
353
if cde_list :
352
354
try :
353
- print_func ([ 'stage' ,1 ] ,True )
354
- new_record .extract_customdata (print_func ,abort_list )
355
+ print_func (( 'stage' ,1 ) ,True )
356
+ new_record .extract_customdata (print_func ,abort_list , threads = threads )
355
357
except Exception as cde :
356
358
print_info (f'cde error:{ cde } ' )
357
359
358
- print_func ([ 'stage' ,2 ] ,True )
360
+ print_func (( 'stage' ,2 ) ,True )
359
361
new_record .pack_data (print_func )
360
- print_func ([ 'stage' ,3 ] ,True )
361
- new_record .save (print_func ,file_path = args .file ,compression_level = 9 )
362
- print_func ([ 'stage' ,4 ] ,True )
362
+ print_func (( 'stage' ,3 ) ,True )
363
+ new_record .save (print_func ,file_path = args .file ,compression_level = compression_level )
364
+ print_func (( 'stage' ,4 ) ,True )
363
365
364
366
#####################################################################
365
367
else :
0 commit comments