11import logging
22import time
3+ import sys
34from dataclasses import asdict
45from glob import glob
56from pathlib import PurePath
@@ -145,21 +146,24 @@ def find_files(path: str) -> List[str]:
145146 for file_name in patterns :
146147 pattern = Core .to_case_insensitive_regex (patterns [file_name ]["pattern" ])
147148 file_path = f"{ path } /**/{ pattern } "
148- log .debug (f"Globbing { file_path } " )
149+ # log.debug(f"Globbing {file_path}")
149150 glob_start = time .time ()
150151 glob_files = glob (file_path , recursive = True )
151152 for glob_file in glob_files :
152153 if glob_file not in files :
153154 files .add (glob_file )
154155 glob_end = time .time ()
155156 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")
157158
158159 log .debug ("Finished Find Files" )
159160 end_time = time .time ()
160161 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 )} " )
163167 return list (files )
164168
165169 @staticmethod
@@ -449,7 +453,6 @@ def create_new_diff(
449453 files = self .find_files (path )
450454 files_for_sending = self .load_files_for_sending (files , path )
451455
452- log .debug (f"files: { files } found at path { path } " )
453456 if not files :
454457 return Diff (id = "no_diff_id" )
455458
@@ -461,18 +464,27 @@ def create_new_diff(
461464 head_full_scan_id = None
462465 has_head_scan = False
463466
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 )
474479
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 )
476488
477489 diff = self .create_diff_report (added_packages , removed_packages )
478490
0 commit comments