code: def _scan_lightning_connections(app_name_or_id):
      if not os.path.exists(_LIGHTNING_CONNECTION):
          return None
  
      for ppid in os.listdir(_LIGHTNING_CONNECTION):
          try:
              psutil.Process(int(ppid))
          except (psutil.NoSuchProcess, ValueError):
              continue
  
          connection_path = os.path.join(
              _LIGHTNING_CONNECTION, str(ppid)
          )
  
          connected_file = os.path.join(connection_path, "connect.txt")
          curr_app_name, curr_app_id = _read_connected_file(
              connected_file
          )
  
          if not curr_app_name:
              continue
  
          if app_name_or_id in (curr_app_name, curr_app_id):
              return connection_path
  
      return None
  
imports: import json
  import os
  import shutil
  import sys
  from subprocess import Popen
  from typing import List, Optional, Tuple
  import click
  import psutil
  from lightning_utilities.core.imports import package_available
  from rich.progress import Progress
  from lightning.app.utilities.cli_helpers import _get_app_display_name, _LightningAppOpenAPIRetriever
  from lightning.app.utilities.cloud import _get_project
  from lightning.app.utilities.enum import OpenAPITags
  from lightning.app.utilities.log import get_logfile
  from lightning.app.utilities.network import LightningClient
label_desc: Use image node_id 12 for calling a global function with example usage: _scan_lightning_connections(app_name_or_id) and returns: None, None, connection_path