Advertisement
Ri0n

VideoMode.py

Mar 4th, 2024
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. # Set a specific video mode
  2. def changeMode(videomode):
  3.     if checkModeExists(videomode):
  4.         cmd = ["batocera-resolution", "setMode", videomode]
  5.         max_tries = 2  # maximum number of tries to set the mode
  6.         for i in range(max_tries):
  7.             try:
  8.                 result = subprocess.run(cmd, capture_output=True, text=True, check=True)
  9.                 eslog.debug(result.stdout.strip())
  10.                 return
  11.             except subprocess.CalledProcessError as e:
  12.                 eslog.error(f"Error setting video mode: {e.stderr}")
  13.                 if i == max_tries - 1:
  14.                     raise
  15.                 time.sleep(1)
  16.  
  17. def changeMode_cvt(videomode):
  18.     if checkModeExists(videomode):
  19.         cmd = ["batocera-resolution", "setMode_CVT", videomode]
  20.         max_tries = 2  # maximum number of tries to set the mode
  21.         for i in range(max_tries):
  22.             try:
  23.                 result = subprocess.run(cmd, capture_output=True, text=True, check=True)
  24.                 eslog.debug(result.stdout.strip())
  25.                 return
  26.             except subprocess.CalledProcessError as e:
  27.                 eslog.error(f"Error setting video mode: {e.stderr}")
  28.                 if i == max_tries - 1:
  29.                     raise
  30.                 time.sleep(1)
Tags: VideoMode.py
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement