99
1010from typing import Dict
1111import json
12+ import os
1213import requests
1314
1415from . import API
1516
1617
18+ def _is_debug_enabled ():
19+ """Check if KCI_DEBUG environment variable is set to enable verbose logging."""
20+ return os .environ .get ('KCI_DEBUG' , '' ).lower () in ('1' , 'true' , 'yes' )
21+
22+
23+ def _debug_print (message ):
24+ """Print message only if KCI_DEBUG is enabled."""
25+ if _is_debug_enabled ():
26+ print (message )
27+
28+
1729def merge (primary : dict , secondary : dict ):
1830 """Deep merges dicts a and b, returning a new dict containing
1931 dictionary a updated with the contents of dictionary b.
@@ -480,13 +492,13 @@ def create_job_node(self, job_config, input_node,
480492 job_node ['platform_filter' ] = platform_filter
481493
482494 if self ._is_job_filtered (job_node ):
483- print (f"Not creating node due to job filter. Job { job_config .name } "
484- f"not found in jobfilter for node { input_node ['id' ]} " )
495+ _debug_print (f"Not creating node due to job filter. Job { job_config .name } "
496+ f"not found in jobfilter for node { input_node ['id' ]} " )
485497 return None
486498
487499 if not self .should_create_node (job_config .rules , job_node ):
488- print (f"Not creating node due to job rules for { job_config .name } "
489- f"evaluating node { input_node ['id' ]} " )
500+ _debug_print (f"Not creating node due to job rules for { job_config .name } "
501+ f"evaluating node { input_node ['id' ]} " )
490502 return None
491503 # Test-specific fields inherited from parent node (kbuild or
492504 # job) if available
@@ -503,21 +515,21 @@ def create_job_node(self, job_config, input_node,
503515 if runtime :
504516 job_node ['data' ]['runtime' ] = runtime .config .name
505517 if not self .should_create_node (runtime .config .rules , job_node ):
506- print (f"Not creating node { input_node ['id' ]} due to runtime rules "
507- f"for { runtime .config .name } " )
518+ _debug_print (f"Not creating node { input_node ['id' ]} due to runtime rules "
519+ f"for { runtime .config .name } " )
508520 return None
509521 # Filter by platform if it is test job only
510522 if platform :
511523 # if platform_filter not null, verify if platform.name exist in platform_filter
512524 if platform_filter and platform .name not in platform_filter \
513525 and job_config .kind == 'job' :
514- print (f"Filtered: Platform { platform .name } not found in platform_filter "
515- f"for node { input_node ['id' ]} " )
526+ _debug_print (f"Filtered: Platform { platform .name } not found in platform_filter "
527+ f"for node { input_node ['id' ]} " )
516528 return None
517529 job_node ['data' ]['platform' ] = platform .name
518530 if not self .should_create_node (platform .rules , job_node ):
519- print (f"Not creating node { input_node ['id' ]} due to platform rules "
520- f"for { platform .name } " )
531+ _debug_print (f"Not creating node { input_node ['id' ]} due to platform rules "
532+ f"for { platform .name } " )
521533 return None
522534 # Process potential f-strings in node's data with platform attributes
523535 # krev is used for ChromeOS config version mapping
0 commit comments