Load OS Ubuntu examples batch 2
This commit is contained in:
@@ -4,7 +4,7 @@ from .chrome import get_default_search_engine, get_cookie_data, get_bookmarks, g
|
||||
from .file import get_cloud_file, get_vm_file, get_cache_file
|
||||
from .general import get_vm_command_line
|
||||
from .impress import get_audio_in_slide
|
||||
from .info import get_vm_screen_size, get_vm_window_size, get_vm_wallpaper
|
||||
from .info import get_vm_screen_size, get_vm_window_size, get_vm_wallpaper, get_list_directory
|
||||
from .misc import get_rule, get_accessibility_tree
|
||||
from .replay import get_replay
|
||||
from .vlc import get_vlc_playing_info, get_vlc_config
|
||||
|
||||
@@ -18,3 +18,7 @@ def get_vm_wallpaper(env, config: dict) -> Union[str, bytes]:
|
||||
f.write(content)
|
||||
|
||||
return _path
|
||||
|
||||
|
||||
def get_list_directory(env, config: dict) -> dict:
|
||||
return env.controller.get_vm_directory_tree(config["path"])
|
||||
|
||||
@@ -25,4 +25,4 @@ from .vlc import is_vlc_playing, is_vlc_recordings_folder, is_vlc_fullscreen, co
|
||||
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
|
||||
from .os import check_gnome_favorite_apps
|
||||
from .os import check_gnome_favorite_apps, is_utc_0, check_text_enlarged, check_moved_jpgs
|
||||
|
||||
@@ -17,54 +17,43 @@ def check_gnome_favorite_apps(apps_str: str, rule):
|
||||
return 0
|
||||
|
||||
|
||||
# TODO: log in to the system before running this
|
||||
def is_logout_successful():
|
||||
try:
|
||||
subprocess.run(["whoami"])
|
||||
return 0 # Task not successful
|
||||
except subprocess.CalledProcessError:
|
||||
return 1 # Task successful
|
||||
def is_utc_0(timedatectl_output):
|
||||
"""
|
||||
Format as:
|
||||
Local time: Thu 2024-01-25 12:56:06 WET
|
||||
Universal time: Thu 2024-01-25 12:56:06 UTC
|
||||
RTC time: Thu 2024-01-25 12:56:05
|
||||
Time zone: Atlantic/Faroe (WET, +0000)
|
||||
System clock synchronized: yes
|
||||
NTP service: inactive
|
||||
RTC in local TZ: no
|
||||
"""
|
||||
|
||||
utc_line = timedatectl_output.split("\n")[3]
|
||||
|
||||
if utc_line.endswith("+0000)"):
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def is_battery_percentage_displayed():
|
||||
# GNOME schema and key for the setting
|
||||
schema = "org.gnome.desktop.interface"
|
||||
key = "show-battery-percentage"
|
||||
|
||||
try:
|
||||
# use gsettings to get the current setting
|
||||
result = subprocess.run(['gsettings', 'get', schema, key], capture_output=True, text=True)
|
||||
# examine the output is 'true'
|
||||
if result.stdout.strip() == 'true':
|
||||
return 1.
|
||||
else:
|
||||
return 0.
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return 0.
|
||||
def check_text_enlarged(scaling_factor_str):
|
||||
scaling_factor = float(scaling_factor_str)
|
||||
if scaling_factor > 1.0:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def check_auto_lock_settings():
|
||||
# The schema and keys for the GNOME desktop lock settings
|
||||
schema = "org.gnome.desktop.screensaver"
|
||||
lock_enabled_key = "lock-enabled"
|
||||
lock_delay_key = "lock-delay"
|
||||
def check_moved_jpgs(directory_list, rule):
|
||||
|
||||
try:
|
||||
# Check if the screen lock is enabled
|
||||
lock_enabled = subprocess.run(['gsettings', 'get', schema, lock_enabled_key], capture_output=True, text=True)
|
||||
is_lock_enabled = lock_enabled.stdout.strip() == 'true'
|
||||
expected_jpgs = rule["expected"]
|
||||
moved_jpgs = [node['name'] for node in directory_list['children']]
|
||||
|
||||
# Check the delay before the screen is locked
|
||||
lock_delay = subprocess.run(['gsettings', 'get', schema, lock_delay_key], capture_output=True, text=True)
|
||||
# Extract the numerical value from the output
|
||||
delay_seconds = lock_delay
|
||||
if len(moved_jpgs) != len(expected_jpgs):
|
||||
return 0
|
||||
|
||||
# Print the results
|
||||
if is_lock_enabled:
|
||||
return 1.
|
||||
else:
|
||||
return 0.
|
||||
|
||||
except Exception as e:
|
||||
return 0.
|
||||
if set(moved_jpgs) == set(expected_jpgs):
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user