MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / _run_gsettings_command

Function _run_gsettings_command

launch_camoufox.py:627–653  ·  view source on GitHub ↗

Helper function to run gsettings command and return cleaned string output.

(command_parts: list[str])

Source from the content-addressed store, hash-verified

625 """
626
627 def _run_gsettings_command(command_parts: list[str]) -> str | None:
628 """Helper function to run gsettings command and return cleaned string output."""
629 try:
630 process_result = subprocess.run(
631 command_parts,
632 capture_output=True,
633 text=True,
634 check=False, # Do not raise CalledProcessError for non-zero exit codes
635 timeout=1, # Timeout for the subprocess call
636 )
637 if process_result.returncode == 0:
638 value = process_result.stdout.strip()
639 if value.startswith("'") and value.endswith(
640 "'"
641 ): # Remove surrounding single quotes
642 value = value[1:-1]
643
644 # If after stripping quotes, value is empty, or it's a gsettings "empty" representation
645 if not value or value == "''" or value == "@as []" or value == "[]":
646 return None
647 return value
648 else:
649 return None
650 except subprocess.TimeoutExpired:
651 return None
652 except Exception: # Broad exception as per pseudocode
653 return None
654
655 proxy_mode = _run_gsettings_command(
656 ["gsettings", "get", "org.gnome.system.proxy", "mode"]

Callers 1

get_proxy_from_gsettingsFunction · 0.70

Calls 1

runMethod · 0.45

Tested by

no test coverage detected