Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various clean up of old/unused code #316

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions chimera_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from chimera_app.ssh_keys import SSHKeys
from chimera_app.steamgrid.steamgrid import Steamgrid
from chimera_app.storage import StorageConfig
from chimera_app.streaming import StreamServer
from chimera_app.mangohud_config import MangoHudConfig


def merge_single_level(src1, src2):
Expand Down Expand Up @@ -37,10 +35,8 @@ def merge_single_level(src1, src2):
BANNER_DIR = context.DATA_HOME + '/chimera/images'
DATA_DIR = context.DATA_HOME + '/chimera/data'
CONTENT_DIR = context.DATA_HOME + '/chimera/content'
RECORDINGS_DIR = context.DATA_HOME + '/chimera/recordings'
SETTINGS_DIR = context.CONFIG_HOME + '/chimera'
UPLOADS_DIR = os.path.join(context.CACHE_HOME, 'chimera', 'uploads')
MANGOHUD_DIR = context.CONFIG_HOME + "/MangoHud"

SETTINGS_DEFAULT = {
"enable_remote_launch": False,
Expand All @@ -50,13 +46,6 @@ def merge_single_level(src1, src2):
"ftp_password": generate_password(12),
"ftp_port": 2121,
"keep_password": False,
"recordings_dir": RECORDINGS_DIR,
"sls_conf_file": RESOURCE_DIR + "/config/sls.conf",
"ffmpeg_inputs":
["-f x11grab -i :0",
"-f alsa -i pulse"],
"ffmpeg_vcodec": "",
"ffmpeg_acodec": ""
}

SESSION_OPTIONS = {
Expand All @@ -77,10 +66,6 @@ def merge_single_level(src1, src2):

STEAMGRID_HANDLER = Steamgrid("423ef7be0f4b9f8cfa1a471149c5b72c")

STREAMING_HANDLER = StreamServer(SETTINGS_HANDLER)

MANGOHUD_HANDLER = MangoHudConfig(MANGOHUD_DIR)

STORAGE_HANDLER = StorageConfig()

PLATFORMS_DEFAULT = {
Expand Down
61 changes: 0 additions & 61 deletions chimera_app/mangohud_config.py

This file was deleted.

186 changes: 1 addition & 185 deletions chimera_app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
from chimera_app.config import UPLOADS_DIR
from chimera_app.config import SESSION_OPTIONS
from chimera_app.config import STORAGE_HANDLER
from chimera_app.config import STREAMING_HANDLER
from chimera_app.config import MANGOHUD_HANDLER
from chimera_app.compat_tools import OFFICIAL_COMPAT_TOOLS
from chimera_app.compat_tools import OfficialCompatTool
from chimera_app.utils import sanitize
Expand Down Expand Up @@ -643,12 +641,6 @@ def settings_update():
redirect('/system')


@route('/system/reset_mangohud', method='POST')
@authenticate
def mangohud_reset():
MANGOHUD_HANDLER.reset_config()
redirect('/system')


@route('/actions/steam/restart')
@authenticate
Expand All @@ -659,174 +651,15 @@ def steam_restart():
redirect('/actions')


@route('/emulators/yuzu')
@authenticate
def emulators_yuzu():
try:
subprocess.Popen(["/usr/bin/yuzu"])
finally:
redirect('/emulators')


@route('/actions/steam/overlay')
@authenticate
def steam_overlay():
try:
subprocess.call(["xdotool", "key", "shift+Tab"])
finally:
redirect('/actions')


@route('/actions/mangohud')
@authenticate
def mangohud():
key = MANGOHUD_HANDLER.get_toggle_hud_key()
try:
subprocess.call(["xdotool", "key", key])
subprocess.call(["mangohudctl", "toggle", "no_display"])
finally:
redirect('/actions')


@route('/streaming')
@authenticate
def streaming_control():
is_recording = STREAMING_HANDLER.is_recording()
return template('streaming_control.tpl',
recording=is_recording)


@route('/streaming/config')
@authenticate
def streaming_config():
current_inputs = SETTINGS_HANDLER.get_setting("ffmpeg_inputs")
current_vcodecs = SETTINGS_HANDLER.get_setting("ffmpeg_vcodec")
current_acodecs = SETTINGS_HANDLER.get_setting("ffmpeg_acodec")
if type(current_inputs) is not list and current_inputs:
current_inputs = [current_inputs]
if type(current_vcodecs) is not list and current_vcodecs:
current_vcodecs = [current_vcodecs]
if type(current_acodecs) is not list and current_acodecs:
current_acodecs = [current_acodecs]
return template('streaming_config.tpl',
inputs=current_inputs,
vcodecs=current_vcodecs,
acodecs=current_acodecs)


@route('/streaming/add_input', method='POST')
@authenticate
def streaming_add_input():
current_input = SETTINGS_HANDLER.get_setting("ffmpeg_inputs")
new_input = request.forms.get('new_input')
if type(current_input) is list:
current_input.append(new_input)
elif type(current_input) is str:
if current_input.strip():
current_input = [current_input].append(new_input)
else:
current_input = new_input
SETTINGS_HANDLER.set_setting("ffmpeg_inputs", current_input)
redirect('/streaming/config')


@route('/streaming/remove_input/<input_id:int>', method='POST')
@authenticate
def streaming_remove_input(input_id):
current_input = SETTINGS_HANDLER.get_setting("ffmpeg_inputs")
if type(current_input) is list:
del current_input[input_id]
else:
current_input = ''
SETTINGS_HANDLER.set_setting("ffmpeg_inputs", current_input)
redirect('/streaming/config')


@route('/streaming/add_vcodec', method='POST')
@authenticate
def streaming_add_vcodec():
current_vcodec = SETTINGS_HANDLER.get_setting("ffmpeg_vcodec")
new_vcodec = request.forms.get('new_vcodec')
if type(current_vcodec) is list:
current_vcodec.append(new_vcodec)
elif type(current_vcodec) is str:
if current_vcodec.strip():
current_vcodec = [current_vcodec].append(new_vcodec)
else:
current_vcodec = new_vcodec

SETTINGS_HANDLER.set_setting("ffmpeg_vcodec", current_vcodec)
redirect('/streaming/config')


@route('/streaming/remove_vcodec/<vcodec_id:int>', method='POST')
@authenticate
def streaming_remove_vcodec(vcodec_id):
current_vcodec = SETTINGS_HANDLER.get_setting("ffmpeg_vcodec")
if type(current_vcodec) is list:
del current_vcodec[vcodec_id]
else:
current_vcodec = ''
SETTINGS_HANDLER.set_setting("ffmpeg_vcodec", current_vcodec)
redirect('/streaming/config')


@route('/streaming/add_acodec', method='POST')
@authenticate
def streaming_add_acodec():
current_acodec = SETTINGS_HANDLER.get_setting("ffmpeg_acodec")
new_acodec = request.forms.get('new_acodec')
if type(current_acodec) is list:
current_acodec.append(new_acodec)
elif type(current_acodec) is str:
if current_acodec.strip():
current_acodec = [current_acodec].append(new_acodec)
else:
current_acodec = new_acodec
SETTINGS_HANDLER.set_setting("ffmpeg_acodec", current_acodec)
redirect('/streaming/config')


@route('/streaming/remove_acodec/<acodec_id:int>', method='POST')
@authenticate
def streaming_remove_acodec(acodec_id):
current_acodec = SETTINGS_HANDLER.get_setting("ffmpeg_acodec")
if type(current_acodec) is list:
del current_acodec[acodec_id]
else:
current_acodec = ''
SETTINGS_HANDLER.set_setting("ffmpeg_acodec", current_acodec)
redirect('/streaming/config')


@route('/record/start')
@authenticate
def record_start():
STREAMING_HANDLER.record_screen()
return template('success.tpl')


@route('/record/stop')
@authenticate
def record_stop():
STREAMING_HANDLER.stop_record()
return template('success.tpl')


@route('/system/mangohud/save_config', method='POST')
@authenticate
def mangohud_save_config():
new_content = request.forms.get('new_content')
MANGOHUD_HANDLER.save_config(new_content)
redirect('/system')


@route('/system/mangohud/edit_config')
@authenticate
def mangohud_edit():
current_content = MANGOHUD_HANDLER.get_current_config()
return template('mangohud_edit.tpl', file_content=current_content)


def retroarch_cmd(msg):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(bytes(msg, "utf-8"), ('127.0.0.1', 55355))
Expand All @@ -850,23 +683,6 @@ def retro_save_state():
redirect('/actions')


@route('/virtual_keyboard')
@authenticate
def virtual_keyboard():
return template('virtual_keyboard.tpl')


@route('/virtual_keyboard/string', method='POST')
@authenticate
def virtual_keyboard_string():
string = request.forms.get('str')
string_without_controlcharacters = "".join(c for c in string if unicodedata.category(c) != "Cc")
try:
subprocess.call(["xdotool", "type", "--", string_without_controlcharacters])
finally:
redirect('/virtual_keyboard')


@route('/actions/reboot')
@authenticate
def reboot_system():
Expand Down
57 changes: 0 additions & 57 deletions chimera_app/streaming.py

This file was deleted.

Loading
Loading