Finish VLC v2 loading
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from .chrome import is_expected_tabs, is_expected_bookmarks, compare_pdfs, is_cookie_deleted, is_shortcut_on_desktop
|
||||
from .chrome import is_expected_tabs, is_expected_bookmarks, compare_pdfs, is_cookie_deleted, is_shortcut_on_desktop, check_font_size, \
|
||||
check_enabled_experiments, check_history_deleted
|
||||
from .docs import compare_font_names, compare_subscript_contains, has_page_numbers_in_footers, compare_docx_lines
|
||||
from .docs import find_default_font, contains_page_break, compare_docx_files, compare_docx_tables, compare_line_spacing, \
|
||||
compare_insert_equation, compare_highlighted_text
|
||||
@@ -17,6 +18,6 @@ from .pdf import check_pdf_pages
|
||||
from .table import compare_table
|
||||
from .thunderbird import check_thunderbird_prefs, check_thunderbird_filter
|
||||
from .vlc import is_vlc_playing, is_vlc_recordings_folder, is_vlc_fullscreen, compare_images, compare_audios, \
|
||||
compare_videos
|
||||
from .thunderbird import check_thunderbird_prefs, check_thunderbird_filter
|
||||
compare_videos, check_qt_bgcone, check_one_instance_when_started_from_file,check_qt_minimal_view, check_qt_max_volume, \
|
||||
check_qt_slider_colours, check_global_key_play_pause
|
||||
from .vscode import compare_text_file, compare_config, compare_answer, is_extension_installed, check_json_settings, check_json_keybindings
|
||||
|
||||
@@ -53,7 +53,7 @@ def is_vlc_recordings_folder(actual_config_path: str, rule: Dict[str, str]) -> f
|
||||
expected_recording_file_path = rule['recording_file_path']
|
||||
|
||||
try:
|
||||
for line in config_file:
|
||||
for line in config_file.split("\n"):
|
||||
# Skip comments and empty lines
|
||||
if line.startswith('#') or not line.strip():
|
||||
continue
|
||||
@@ -216,3 +216,195 @@ def are_audio_files_similar(mp3_file_path, mp4_file_path):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def check_qt_bgcone(actual_config_path, rule):
|
||||
with open(actual_config_path, 'rb') as file:
|
||||
config_file = file.read().decode('utf-8')
|
||||
|
||||
expected_qt_bgcone = rule['expected_qt_bgcone']
|
||||
if isinstance(expected_qt_bgcone, int):
|
||||
expected_qt_bgcone = str(expected_qt_bgcone)
|
||||
|
||||
try:
|
||||
# The default value of qt_bgcone is 1, which means it is enabled
|
||||
qt_bgcone = "1"
|
||||
for line in config_file.split("\n"):
|
||||
# Check if the line contains the recording path setting
|
||||
if 'qt-bgcone=' in line:
|
||||
# Extract the value of the recording path and remove surrounding whitespace
|
||||
qt_bgcone = line.split('=')[-1].strip()
|
||||
# The configuration key was not found in the file
|
||||
|
||||
if qt_bgcone == expected_qt_bgcone:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except FileNotFoundError:
|
||||
logger.error("VLC configuration file not found.")
|
||||
return 0
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return 0
|
||||
|
||||
|
||||
def check_qt_max_volume(actual_config_path, rule):
|
||||
with open(actual_config_path, 'rb') as file:
|
||||
config_file = file.read().decode('utf-8')
|
||||
|
||||
expected_qt_max_volume = rule['expected_qt_max_volume']
|
||||
if isinstance(expected_qt_max_volume, int):
|
||||
expected_qt_max_volume = str(expected_qt_max_volume)
|
||||
|
||||
try:
|
||||
qt_max_volume = "125"
|
||||
for line in config_file.split("\n"):
|
||||
if 'qt-max-volume=' in line:
|
||||
qt_max_volume = line.split('=')[-1].strip()
|
||||
# The configuration key was not found in the file
|
||||
|
||||
if qt_max_volume == expected_qt_max_volume:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except FileNotFoundError:
|
||||
logger.error("VLC configuration file not found.")
|
||||
return 0
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return 0
|
||||
|
||||
|
||||
def check_qt_minimal_view(actual_config_path, rule):
|
||||
with open(actual_config_path, 'rb') as file:
|
||||
config_file = file.read().decode('utf-8')
|
||||
|
||||
expected_qt_minimal_view = rule['expected_qt_minimal_view']
|
||||
if isinstance(expected_qt_minimal_view, int):
|
||||
expected_qt_minimal_view = str(expected_qt_minimal_view)
|
||||
|
||||
try:
|
||||
qt_minimal_view = "0"
|
||||
for line in config_file.split("\n"):
|
||||
if 'qt-minimal-view=' in line:
|
||||
qt_minimal_view = line.split('=')[-1].strip()
|
||||
|
||||
if qt_minimal_view == expected_qt_minimal_view:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except FileNotFoundError:
|
||||
logger.error("VLC configuration file not found.")
|
||||
return 0
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return 0
|
||||
|
||||
|
||||
def check_qt_slider_colours(actual_config_path, rule):
|
||||
with open(actual_config_path, 'rb') as file:
|
||||
config_file = file.read().decode('utf-8')
|
||||
|
||||
try:
|
||||
qt_slider_colours = "153;210;153;20;210;20;255;199;15;245;39;29"
|
||||
for line in config_file.split("\n"):
|
||||
if 'qt-slider-colours' in line:
|
||||
qt_slider_colours = line.split('=')[-1].strip()
|
||||
# The configuration key was not found in the file
|
||||
|
||||
if rule['type'] == 'match':
|
||||
expected_qt_slider_colours = rule['expected_qt_slider_colours']
|
||||
if qt_slider_colours == expected_qt_slider_colours:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
elif rule['type'] == 'blackish':
|
||||
def is_color_blackish(rgb_values, threshold=100):
|
||||
# decide if the color is blackish
|
||||
return all(value < threshold for value in rgb_values)
|
||||
|
||||
def parse_qt_slider_colours(colours_string):
|
||||
# parse the string of colours into a list of RGB tuples
|
||||
values = [int(x) for x in colours_string.split(';')]
|
||||
colors = list(zip(values[0::3], values[1::3], values[2::3]))
|
||||
return colors
|
||||
|
||||
colors = parse_qt_slider_colours(qt_slider_colours)
|
||||
|
||||
# check if all colors are blackish
|
||||
for color in colors:
|
||||
if is_color_blackish(color):
|
||||
pass
|
||||
else:
|
||||
return 0
|
||||
return 1
|
||||
|
||||
except FileNotFoundError:
|
||||
logger.error("VLC configuration file not found.")
|
||||
return 0
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return 0
|
||||
|
||||
|
||||
def check_global_key_play_pause(actual_config_path, rule):
|
||||
"""
|
||||
# Play/Pause (str)
|
||||
#global-key-play-pause=
|
||||
|
||||
# Play/Pause (str)
|
||||
#key-play-pause=Space
|
||||
"""
|
||||
with open(actual_config_path, 'rb') as file:
|
||||
config_file = file.read().decode('utf-8')
|
||||
|
||||
expected_global_key_play_pause = rule['expected_global_key_play_pause']
|
||||
|
||||
if isinstance(expected_global_key_play_pause, int):
|
||||
expected_global_key_play_pause = str(expected_global_key_play_pause)
|
||||
|
||||
try:
|
||||
global_key_play_pause = "0"
|
||||
for line in config_file.split("\n"):
|
||||
# Check if the line contains the recording path setting
|
||||
if 'global-key-play-pause=' in line:
|
||||
global_key_play_pause = "0" if line.split('=')[-1].strip() == "" else "1"
|
||||
|
||||
if global_key_play_pause == expected_global_key_play_pause:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except FileNotFoundError:
|
||||
logger.error("VLC configuration file not found.")
|
||||
return 0
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return 0
|
||||
|
||||
|
||||
def check_one_instance_when_started_from_file(actual_config_path, rule):
|
||||
with open(actual_config_path, 'rb') as file:
|
||||
config_file = file.read().decode('utf-8')
|
||||
|
||||
expected_one_instance_when_started_from_file = rule['expected_one_instance_when_started_from_file']
|
||||
|
||||
if isinstance(expected_one_instance_when_started_from_file, int):
|
||||
expected_one_instance_when_started_from_file = str(expected_one_instance_when_started_from_file)
|
||||
|
||||
try:
|
||||
one_instance_when_started_from_file = "1"
|
||||
for line in config_file.split("\n"):
|
||||
# Check if the line contains the recording path setting
|
||||
if 'one-instance-when-started-from-file=' in line:
|
||||
one_instance_when_started_from_file = line.split('=')[-1].strip()
|
||||
|
||||
if one_instance_when_started_from_file == expected_one_instance_when_started_from_file:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except FileNotFoundError:
|
||||
logger.error("VLC configuration file not found.")
|
||||
return 0
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user