1
1
import logging
2
2
import time
3
+ import sys
3
4
from dataclasses import asdict
4
5
from glob import glob
5
6
from pathlib import PurePath
@@ -145,21 +146,24 @@ def find_files(path: str) -> List[str]:
145
146
for file_name in patterns :
146
147
pattern = Core .to_case_insensitive_regex (patterns [file_name ]["pattern" ])
147
148
file_path = f"{ path } /**/{ pattern } "
148
- log .debug (f"Globbing { file_path } " )
149
+ # log.debug(f"Globbing {file_path}")
149
150
glob_start = time .time ()
150
151
glob_files = glob (file_path , recursive = True )
151
152
for glob_file in glob_files :
152
153
if glob_file not in files :
153
154
files .add (glob_file )
154
155
glob_end = time .time ()
155
156
glob_total_time = glob_end - glob_start
156
- log .debug (f"Glob for pattern { file_path } took { glob_total_time :.2f} seconds" )
157
+ # log.debug(f"Glob for pattern {file_path} took {glob_total_time:.2f} seconds")
157
158
158
159
log .debug ("Finished Find Files" )
159
160
end_time = time .time ()
160
161
total_time = end_time - start_time
161
- log .info (f"Found { len (files )} in { total_time :.2f} seconds" )
162
- log .debug (f"Files found: { list (files )} " )
162
+ files_list = list (files )
163
+ if len (files_list ) > 5 :
164
+ log .debug (f"{ len (files_list )} Files found ({ total_time :.2f} s): { ', ' .join (files_list [:5 ])} , ..." )
165
+ else :
166
+ log .debug (f"{ len (files_list )} Files found ({ total_time :.2f} s): { ', ' .join (files_list )} " )
163
167
return list (files )
164
168
165
169
@staticmethod
@@ -449,7 +453,6 @@ def create_new_diff(
449
453
files = self .find_files (path )
450
454
files_for_sending = self .load_files_for_sending (files , path )
451
455
452
- log .debug (f"files: { files } found at path { path } " )
453
456
if not files :
454
457
return Diff (id = "no_diff_id" )
455
458
@@ -461,18 +464,27 @@ def create_new_diff(
461
464
head_full_scan_id = None
462
465
has_head_scan = False
463
466
464
- # Create new scan
465
- new_scan_start = time .time ()
466
- new_full_scan = self .create_full_scan (files_for_sending , params , has_head_scan )
467
- new_scan_end = time .time ()
468
- log .info (f"Total time to create new full scan: { new_scan_end - new_scan_start :.2f} " )
469
-
470
-
471
- # head_full_scan = None
472
- # if head_full_scan_id:
473
- # head_full_scan = self.get_full_scan(head_full_scan_id)
467
+ # Create new scan
468
+ try :
469
+ new_scan_start = time .time ()
470
+ new_full_scan = self .create_full_scan (files_for_sending , params , has_head_scan )
471
+ new_scan_end = time .time ()
472
+ log .info (f"Total time to create new full scan: { new_scan_end - new_scan_start :.2f} " )
473
+ except APIFailure as e :
474
+ log .error (f"API Error: { e } " )
475
+ sys .exit (1 )
476
+ except Exception as e :
477
+ log .error (f"Unexpected error while creating new scan: { e } " )
478
+ sys .exit (1 )
474
479
475
- added_packages , removed_packages = self .get_added_and_removed_packages (head_full_scan_id , new_full_scan )
480
+ try :
481
+ added_packages , removed_packages = self .get_added_and_removed_packages (head_full_scan_id , new_full_scan )
482
+ except APIFailure as e :
483
+ log .error (f"API Error: { e } " )
484
+ sys .exit (1 )
485
+ except Exception as e :
486
+ log .error (f"Unexpected error while comparing packages: { e } " )
487
+ sys .exit (1 )
476
488
477
489
diff = self .create_diff_report (added_packages , removed_packages )
478
490
0 commit comments