Skip to content

Commit

Permalink
Merge pull request #14 from PortsMaster/dev
Browse files Browse the repository at this point in the history
Added hardware info for rgb30, also reduced debugging info as standard.
  • Loading branch information
kloptops authored Oct 2, 2023
2 parents 2bc5dd4 + 5b8f430 commit 2d1b1e4
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 37 deletions.
45 changes: 29 additions & 16 deletions PortMaster/pugwash
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/usr/bin/env python3

## -- BEGIN PORTMASTER INFO --
PORTMASTER_VERSION = '8.4.13'
PORTMASTER_VERSION = '8.4.14'
PORTMASTER_RELEASE_CHANNEL = 'beta'
## -- END PORTMASTER INFO --

PORTMASTER_RELEASE_CHANNELS = {
'beta': 'https://github.com/PortsMaster/PortMaster-GUI/releases/latest/download/',
'stable': 'https://github.com/PortsMaster/PortMaster-Releases/releases/latest/download/',
}

PORTMASTER_UPDATE_FREQUENCY = (60 * 60 * 1)
__builtins__.PORTMASTER_DEBUG = False ## This adds a lot of extra info

import contextlib
import ctypes
Expand Down Expand Up @@ -474,10 +476,10 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):
version = sdl2.SDL_version()
sdl2.SDL_GetVersion(version)

logger.debug(f"SDL DLL: {sdl2.dll.get_dll_file()}, {nice_version(version)}")
logger.debug(f"TTF DLL: {sdl2.sdlttf.get_dll_file()}, {nice_version(sdl2.sdlttf.TTF_Linked_Version()[0])}")
logger.debug(f"IMG DLL: {sdl2.sdlimage.get_dll_file()}, {nice_version(sdl2.sdlimage.IMG_Linked_Version()[0])}")
logger.debug(f"MIX DLL: {sdl2.sdlmixer.get_dll_file()}, {nice_version(sdl2.sdlmixer.Mix_Linked_Version()[0])}")
logger.info(f"SDL DLL: {sdl2.dll.get_dll_file()}, {nice_version(version)}")
logger.info(f"TTF DLL: {sdl2.sdlttf.get_dll_file()}, {nice_version(sdl2.sdlttf.TTF_Linked_Version()[0])}")
logger.info(f"IMG DLL: {sdl2.sdlimage.get_dll_file()}, {nice_version(sdl2.sdlimage.IMG_Linked_Version()[0])}")
logger.info(f"MIX DLL: {sdl2.sdlmixer.get_dll_file()}, {nice_version(sdl2.sdlmixer.Mix_Linked_Version()[0])}")

# Load controller.
count = sdl2.SDL_NumJoysticks()
Expand All @@ -487,8 +489,8 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):
if is_game_controller == sdl2.SDL_TRUE:
pad = sdl2.SDL_GameControllerOpen(index)
if pad is not None:
logger.debug(f"Opened GameController {index}: {sdl2.SDL_GameControllerName(pad)}")
logger.debug(f" {sdl2.SDL_GameControllerMapping(pad)}")
logger.info(f"Opened GameController {index}: {sdl2.SDL_GameControllerName(pad)}")
logger.info(f" {sdl2.SDL_GameControllerMapping(pad)}")

# Define window dimensions
self.display_width = 640
Expand Down Expand Up @@ -520,6 +522,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):
# 'rg503'
# 'rg351v'
# 'rg353v'
'rgb30'
# 'ogs'
# 'ogu'
# 'x55'
Expand All @@ -534,7 +537,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):

if capabilities['device'] == 'default':
device = harbourmaster.find_device_by_resolution((self.display_width, self.display_height))
logger.debug(f"FOUND: {device}")
logger.info(f"FOUND: {device}")
if device != 'default':
capabilities = harbourmaster.device_info(device)

Expand All @@ -543,7 +546,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):

capabilities['capabilities'].append(CURRENT_LANG)

logger.debug(capabilities)
logger.info(capabilities)

# Create the window
if harbourmaster.HM_TESTING:
Expand Down Expand Up @@ -683,7 +686,8 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):
sdl2.SDL_Delay(30)

if self.timers.elapsed('updates_per_second', 1000, run_first=True):
print(f"UPS: {self.draw_counter} / {self.update_counter}")
if PORTMASTER_DEBUG:
print(f"UPS: {self.draw_counter} / {self.update_counter}")
self.update_counter = 0
self.draw_counter = 0
self.updated = True
Expand Down Expand Up @@ -857,7 +861,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):
else:
self.set_data("port_info.install_size", "")

print(f"INFO: {port_info}")
# print(f"INFO: {port_info}")

def set_theme_info(self, theme_name, theme_info):
## TODO: make this better :D
Expand Down Expand Up @@ -958,7 +962,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):

self.text_data[key] = value
self.changed_keys.add(key)
logger.debug(f"{key}: {value}")
# logger.debug(f"{key}: {value}")

def format_data(self, input_string, used_keys=None):
return self.formatter.format_string(input_string, used_keys)
Expand Down Expand Up @@ -1383,7 +1387,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):
del args[i]

else:
logger.debug(f"unknown option {args[i]}")
logger.warning(f"unknown option {args[i]}")
del args[i]

## This fixes a bug :D
Expand Down Expand Up @@ -1506,7 +1510,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):
del args[i]
continue

logger.debug(f"unknown option {args[i]}")
logger.warning(f"unknown option {args[i]}")
del args[i]

if len(args) == 0:
Expand Down Expand Up @@ -1611,7 +1615,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback):
self.fifo_commands[args[0].lower()](self, fifo_config, args[1:])

else:
logger.debug(f"fifo: unknown command {args[0]}")
logger.warning(f"fifo: unknown command {args[0]}")
done_file.write_text("DONE")

self.do_loop(no_delay=True)
Expand Down Expand Up @@ -1649,7 +1653,7 @@ def portmaster_check_update(pm, config, temp_dir):
if update_checked is None or harbourmaster.datetime_compare(update_checked) > PORTMASTER_UPDATE_FREQUENCY:
update_checked_was_none = update_checked is None
latest_version = harbourmaster.fetch_text(PORTMASTER_RELEASE_CHANNELS[release_channel] + 'version').strip()
logger.debug(f"Checking for updates: {latest_version} vs {PORTMASTER_VERSION}")
logger.info(f"Checking for updates: {latest_version} vs {PORTMASTER_VERSION}")

cfg_data['update_checked'] = datetime.datetime.now().isoformat()
if not cfg_file.parent.is_dir():
Expand Down Expand Up @@ -1698,6 +1702,7 @@ def portmaster_check_update(pm, config, temp_dir):
@logger.catch
def main(argv):
global LOG_FILE_HANDLE
global LOG_FILE

with make_temp_directory() as temp_dir:
argv = argv[:]
Expand Down Expand Up @@ -1740,6 +1745,14 @@ def main(argv):
logger.remove(0) # For the default handler, it's actually '0'.
logger.add(sys.stderr, level="DEBUG")

elif not PORTMASTER_DEBUG:
logger.remove(0) # For the default handler, it's actually '0'.
logger.add(sys.stderr, level="SUCCESS")

## Once we reach here we can just reduce it to INFO level.
logger.remove(LOG_FILE_HANDLE)
LOG_FILE_HANDLE = logger.add(LOG_FILE, level="INFO", backtrace=True, diagnose=True)

if config['no-log']:
logger.remove(LOG_FILE_HANDLE)
LOG_FILE_HANDLE = None
Expand Down
4 changes: 2 additions & 2 deletions PortMaster/pylibs/harbourmaster/captain.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def check_port(port_name, zip_file, extra_info=None):
port_info['name'] = name_cleaner(port_name)
port_info['items'] = items

if port_info_data != port_info:
logger.warning(f"port.json is different from what is expected:\n{json.dumps(port_info, indent=4)}")
# if port_info_data != port_info:
# logger.warning(f"port.json is different from what is expected:\n{json.dumps(port_info, indent=4)}")

if extra_info is not None:
extra_info['port_info_file'] = port_info_file
Expand Down
10 changes: 6 additions & 4 deletions PortMaster/pylibs/harbourmaster/harbour.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def load_ports(self):
with ports_files[port_name].open('wt') as fh:
json.dump(port_info, fh, indent=4)
else:
logger.debug(f"Unable to dump {str(ports_files[port_name])}: {port_info}")
logger.warning(f"Unable to dump {str(ports_files[port_name])}: {port_info}")

def port_info_attrs(self, port_info):
runtime_fix = {
Expand Down Expand Up @@ -963,7 +963,7 @@ def _install_theme(self, download_file):
"""
Installs a theme file.
"""
logger.debug(f"Installing theme: {download_file.name}")
logger.info(f"Installing theme: {download_file.name}")

if not self.themes_dir.is_dir():
self.themes_dir.mkdir(0o755)
Expand Down Expand Up @@ -998,7 +998,7 @@ def _install_portmaster(self, download_file):
"""
Installs a new version of PortMaster
"""
logger.debug("Installing PortMaster.zip")
logger.info("Installing PortMaster.zip")
# if HM_TESTING:
# logger.error("Unable to install PortMaster.zip in testing environment.")
# return 255
Expand Down Expand Up @@ -1055,6 +1055,7 @@ def _install_port(self, download_info):

port_nice_name = download_info.get('attr', {}).get('title', download_info['name'])
port_info = {}
logger.info(f"Installing {port_nice_name}")

try:
extra_info = {}
Expand Down Expand Up @@ -1146,7 +1147,7 @@ def _install_port(self, download_info):
self.callback.message(_("Installation failed, removing files..."))

for undo_file in undo_data[::-1]:
logger.debug(f"Removing {undo_file.relative_to(self.ports_dir)}")
logger.info(f"Removing {undo_file.relative_to(self.ports_dir)}")
self.callback.message(f"- {str(undo_file.relative_to(self.ports_dir))}")

if undo_file.is_file():
Expand Down Expand Up @@ -1209,6 +1210,7 @@ def check_runtime(self, runtime, port_name=None, in_install=False):
'Unverified': _('Unverified'),
'Broken': _('Broken'),
}
logger.info(f"Installing {runtime_name}")

if self.config['offline']:
cprint(f"Unable to download {runtime} when offline")
Expand Down
14 changes: 9 additions & 5 deletions PortMaster/pylibs/harbourmaster/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'rgb10max': {'resolution': ( 854, 480), 'analogsticks': 2, 'cpu': 'rk3326', 'capabilities': []},
'rgb10s': {'resolution': ( 480, 320), 'analogsticks': 1, 'cpu': 'rk3326', 'capabilities': []},
'rgb20s': {'resolution': ( 640, 480), 'analogsticks': 2, 'cpu': 'rk3326', 'capabilities': []},
'rgb30': {'resolution': ( 720, 720), 'analogsticks': 2, 'cpu': 'rk3566', 'capabilities': ['power']},
'rk2023': {'resolution': ( 640, 480), 'analogsticks': 2, 'cpu': 'rk3566', 'capabilities': ['power']},
'rk2020': {'resolution': ( 480, 320), 'analogsticks': 1, 'cpu': 'rk3326', 'capabilities': []},

Expand All @@ -65,6 +66,7 @@
## From PortMaster.sh from JELOS, all devices except x55 and rg10max3 have opengl
('jelos', 'x55'): {'capabilities': []},
('jelos', 'rgb10max3'): {'capabilities': []},
('jelos', 'rgb30'): {'capabilities': []},
('jelos', HW_ANY): {'capabilities': ['opengl']},
}

Expand Down Expand Up @@ -94,12 +96,13 @@ def nice_device_to_device(raw_device):

pattern_to_device = (
('Hardkernel ODROID-GO-Ultra', 'ogu'),
('ODROID-GO Advance*', 'oga'),
('ODROID-GO Super*', 'ogs'),
('ODROID-GO Advance*', 'oga'),
('ODROID-GO Super*', 'ogs'),

('Powkiddy RGB10 MAX 3', 'rgb10max3'),
('Powkiddy RK2023', 'rk2023'),
('Powkiddy x55', 'x55'),
('Powkiddy RGB30', 'rgb30'),
('Powkiddy RK2023', 'rk2023'),
('Powkiddy x55', 'x55'),

('Anbernic RG351MP*', 'rg351mp'),
('Anbernic RG351V*', 'rg351v'),
Expand Down Expand Up @@ -286,7 +289,8 @@ def device_info(override_device=None, override_resolution=None):
if "hires" not in info['capabilities']:
info['capabilities'].append("hires")

info['capabilities'].append("wide")
if info['resolution'][0] > info['resolution'][1]:
info['capabilities'].append("wide")

logger.debug(f"DEVICE INFO: {info}")
__root_info = info
Expand Down
6 changes: 3 additions & 3 deletions PortMaster/pylibs/harbourmaster/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def portmaster_install(self):
logger.debug(f"{self.__class__.__name__}: PortMaster Install")

def set_gcd_mode(self, mode=None):
logger.debug(f"{self.__class__.__name__}: Set GCD Mode {mode}")
logger.info(f"{self.__class__.__name__}: Set GCD Mode {mode}")

def get_gcd_modes(self):
return tuple()
Expand All @@ -95,7 +95,7 @@ def set_gcd_mode(self, gcd_mode=None):
'xbox': self.hm.tools_dir / "PortMaster" / ".Backup" / "donottouch_x.txt",
}

logger.debug(f"{self.__class__.__name__}: Set GCD Mode: {gcd_mode}")
logger.info(f"{self.__class__.__name__}: Set GCD Mode: {gcd_mode}")

if gcd_mode:
if gcd_mode not in mode_files:
Expand Down Expand Up @@ -167,7 +167,7 @@ def portmaster_install(self):
PM_DIR = HM_TOOLS_DIR / "PortMaster"

if hash_file(BROKEN_MAPPER) == BROKEN_MAPPER_MD5:
logger.debug("Replacing broken mapper.txt if it is still there.")
logger.info("Replacing broken mapper.txt if it is still there.")
FIXED_MAPPER = PM_DIR / ".Backup" / "mapper.txt"
shutil.copy(FIXED_MAPPER, BROKEN_MAPPER)

Expand Down
6 changes: 3 additions & 3 deletions PortMaster/pylibs/pugscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def do_update(self, events):

self.button_activate()

print(f"Selected {selected_option}")
# print(f"Selected {selected_option}")

if selected_option == 'update-ports':
self.gui.do_update_ports()
Expand Down Expand Up @@ -601,7 +601,7 @@ def do_update(self, events):
self.gui.do_loop()

for runtime_file in runtimes:
logger.debug(f"removing {runtime_file}")
logger.info(f"removing {runtime_file}")
self.gui.message(f"- {runtime_file}")
runtime_file.unlink()
self.gui.do_loop()
Expand Down Expand Up @@ -898,7 +898,7 @@ def do_update(self, events):

self.button_activate()

print(f"Selected {selected_option} -> {selected_parameter}")
# print(f"Selected {selected_option} -> {selected_parameter}")

if selected_option == 'back':
self.gui.pop_scene()
Expand Down
6 changes: 3 additions & 3 deletions PortMaster/pylibs/pugtheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def theme_apply(gui, section_data, base_data, elements):
continue

if element_name not in elements:
logger.debug(f"Error: Unknown element {element_name}")
logger.warning(f"Error: Unknown element {element_name}")
continue

new_data[region_name] = theme_merge(base_data, theme_merge(elements[element_name], region_data))
Expand All @@ -120,7 +120,7 @@ def theme_apply(gui, section_data, base_data, elements):


def theme_load(gui, theme_file, color_scheme=None):
logger.debug(f"Loading theme {theme_file}")
logger.info(f"Loading theme {theme_file}")

with open(theme_file, 'r') as fh:
theme_data = json.load(fh)
Expand Down Expand Up @@ -375,7 +375,7 @@ def _update(self):
logger.debug(f"images_md5={images_md5}, self.images_md5={self._images_md5}")
images_zip = harbourmaster.download(self.hm.temp_dir / "images.zip", images_url_zip, images_md5, callback=self.hm.callback)
if images_zip is None:
logger.debug(f"Unable to download {images_url_zip}")
logger.warning(f"Unable to download {images_url_zip}")
return

images_to_delete = [
Expand Down
2 changes: 1 addition & 1 deletion PortMaster/pylibs/pySDL2gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def add_path(self, path):
else:
raise GUIValueError(f"Invalid {path!r}")

print(path)
# print(path)
if not path.is_dir():
return

Expand Down

0 comments on commit 2d1b1e4

Please sign in to comment.