Merge branch 'main' into zdy
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
from .file import get_cloud_file, get_vm_file, get_cache_file
|
||||
from .misc import get_rule
|
||||
from .vlc import get_vlc_playing_info
|
||||
|
||||
@@ -3,6 +3,7 @@ from typing import Dict
|
||||
import os
|
||||
import requests
|
||||
|
||||
|
||||
def get_cloud_file(env, config: Dict[str, str]) -> str:
|
||||
"""
|
||||
Config:
|
||||
@@ -25,6 +26,7 @@ def get_cloud_file(env, config: Dict[str, str]) -> str:
|
||||
|
||||
return _path
|
||||
|
||||
|
||||
def get_vm_file(env, config: Dict[str, str]) -> str:
|
||||
"""
|
||||
Config:
|
||||
|
||||
20
desktop_env/evaluators/getters/vlc.py
Normal file
20
desktop_env/evaluators/getters/vlc.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
from typing import Dict
|
||||
|
||||
|
||||
def get_vlc_playing_info(env, config: Dict[str, str]):
|
||||
"""
|
||||
Gets the current playing information from VLC's HTTP interface.
|
||||
"""
|
||||
_path = os.path.join(env.cache_dir, config["dest"])
|
||||
|
||||
host = env.vm_ip
|
||||
port = 8080
|
||||
password = 'password'
|
||||
|
||||
content = env.controller.get_vlc_status(host, port, password)
|
||||
print("content: ", content)
|
||||
with open(_path, "wb") as f:
|
||||
f.write(content)
|
||||
|
||||
return _path
|
||||
@@ -5,4 +5,5 @@ from .docs import compare_font_names, compare_subscript_contains, has_page_numbe
|
||||
from .docs import is_first_line_centered, check_file_exists, compare_contains_image
|
||||
from .pdf import check_pdf_pages
|
||||
from .libreoffice import check_libre_locale
|
||||
#from .vlc import is_vlc_playing
|
||||
from .general import check_csv
|
||||
|
||||
22
desktop_env/evaluators/metrics/gimp.py
Normal file
22
desktop_env/evaluators/metrics/gimp.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os
|
||||
|
||||
|
||||
def get_gimp_export_path():
|
||||
# Path to GIMP's configuration file. This example assumes GIMP version 2.10.
|
||||
# You need to adjust the path according to the GIMP version and user's file system.
|
||||
gimp_config_file = os.path.expanduser("~/.config/GIMP/2.10/gimprc")
|
||||
|
||||
try:
|
||||
# Open and read the configuration file
|
||||
with open(gimp_config_file, 'r') as file:
|
||||
for line in file:
|
||||
# Search for the default export path setting
|
||||
if "default-export-path" in line:
|
||||
# Extract the current path from the line (assuming it's enclosed in quotes)
|
||||
current_path = line.split('"')[1]
|
||||
# Compare the current path with the expected path
|
||||
return current_path
|
||||
except FileNotFoundError:
|
||||
# Handle the case where the configuration file is not found
|
||||
print("GIMP configuration file not found")
|
||||
return False
|
||||
@@ -1,14 +1,14 @@
|
||||
import os
|
||||
import platform
|
||||
import requests
|
||||
from xml.etree import ElementTree
|
||||
import pygetwindow as gw
|
||||
import pyautogui
|
||||
from typing import Dict
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger("desktopenv.metrics.vlc")
|
||||
|
||||
def read_vlc_config(setting_name):
|
||||
def get_vlc_config(setting_name):
|
||||
"""
|
||||
Reads the VLC configuration file to check for a specific setting.
|
||||
|
||||
@@ -41,24 +41,22 @@ def read_vlc_config(setting_name):
|
||||
return None
|
||||
|
||||
|
||||
def get_vlc_playing_info(host='localhost', port=8080, password='password'):
|
||||
def is_vlc_playing(actual: str, rule: Dict[str, str]) -> float:
|
||||
"""
|
||||
Gets the current playing information from VLC's HTTP interface.
|
||||
Checks if VLC is currently playing a file.
|
||||
"""
|
||||
url = f'http://{host}:{port}/requests/status.xml'
|
||||
try:
|
||||
response = requests.get(url, auth=('', password))
|
||||
if response.status_code == 200:
|
||||
tree = ElementTree.fromstring(response.content)
|
||||
status = tree.find('state').text
|
||||
if status == 'playing':
|
||||
file_info = tree.find('information/category[@name="meta"]/info[@name="filename"]').text
|
||||
return status, file_info
|
||||
return status, None
|
||||
except Exception as e:
|
||||
logger.error(f"Error: {e}")
|
||||
with open(actual, 'rb') as file:
|
||||
actual_status = file.read().decode('utf-8')
|
||||
|
||||
return None, None
|
||||
tree = ElementTree.fromstring(actual_status)
|
||||
status = tree.find('state').text
|
||||
if status == 'playing':
|
||||
file_info = tree.find('information/category[@name="meta"]/info[@name="filename"]').text
|
||||
print("file_info: ", file_info)
|
||||
if file_info:
|
||||
return 1 if file_info.endswith(rule['expected']) else 0
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def is_vlc_fullscreen():
|
||||
@@ -86,5 +84,3 @@ def is_vlc_fullscreen():
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user