mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2025-12-28 01:12:33 +01:00
Removed bloated class and replace it with pure functions in 'plain' module
This commit is contained in:
@@ -8,33 +8,20 @@ import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
class Plain(object):
|
||||
"""Class for run fs-uae"""
|
||||
|
||||
def run(self, conf_file, fs_uae_options):
|
||||
"""
|
||||
Run the emulation.
|
||||
conf_file is a path to the configuration,
|
||||
fs_uae_options is a list contains tokenized options to be passed to
|
||||
fs-uae
|
||||
"""
|
||||
try:
|
||||
subprocess.call(['fs-uae'] + [conf_file] + fs_uae_options)
|
||||
except subprocess.CalledProcessError:
|
||||
sys.stderr.write('Warning: fs-uae returned non 0 exit code\n')
|
||||
return False
|
||||
return True
|
||||
|
||||
def clean(self):
|
||||
"""In this class, do nothing on exit"""
|
||||
return
|
||||
|
||||
|
||||
def run(config_file, fs_uae_options, _, unused):
|
||||
"""Run fs-uae with provided config file and options"""
|
||||
|
||||
runner = Plain()
|
||||
def run_plain(conf_file, fs_uae_options):
|
||||
"""
|
||||
Run the emulation.
|
||||
conf_file is a path to the configuration,
|
||||
fs_uae_options is an dict-like object which contains commandline options to
|
||||
be passed to fs-uae
|
||||
"""
|
||||
try:
|
||||
return runner.run(config_file, fs_uae_options)
|
||||
finally:
|
||||
runner.clean()
|
||||
subprocess.call(['fs-uae'] + [conf_file] + fs_uae_options.list())
|
||||
except subprocess.CalledProcessError:
|
||||
sys.stderr.write('Warning: fs-uae returned non 0 exit code\n')
|
||||
return True
|
||||
|
||||
|
||||
def run(config_file, fs_uae_options, _):
|
||||
"""Run fs-uae with provided config file and options"""
|
||||
return run_plain(config_file, fs_uae_options)
|
||||
|
||||
Reference in New Issue
Block a user