mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2026-02-11 03:05:47 +01:00
Added additional tests for cd32 module
Also, new command was added to utils - run_command which is an generalized subprocess.call function. Requirements is now added with module six, which was needed to detect string-like objects in sane way.
This commit is contained in:
@@ -10,7 +10,6 @@ name.
|
||||
"""
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
@@ -151,11 +150,7 @@ class CD32(object):
|
||||
"""execute game in provided directory"""
|
||||
curdir = os.path.abspath('.')
|
||||
os.chdir(self.dir)
|
||||
try:
|
||||
subprocess.call(['fs-uae'] + fs_uae_options)
|
||||
except subprocess.CalledProcessError:
|
||||
sys.stderr.write('Warning: fs-uae returned non 0 exit code\n')
|
||||
|
||||
utils.run_command(['fs-uae'] + fs_uae_options)
|
||||
os.chdir(curdir)
|
||||
return True
|
||||
|
||||
@@ -170,11 +165,10 @@ class CD32(object):
|
||||
if os.path.exists(self.save_filename):
|
||||
os.unlink(self.save_filename)
|
||||
|
||||
try:
|
||||
subprocess.call(['7z', 'a', self.save_filename,
|
||||
os.path.join(self.dir, 'fs-uae-save')])
|
||||
except subprocess.CalledProcessError:
|
||||
sys.stderr.write('Warning: archiving save state failed\n')
|
||||
code = utils.run_command(['7z', 'a', self.save_filename,
|
||||
os.path.join(self.dir, 'fs-uae-save')])
|
||||
if code != 0:
|
||||
sys.stderr.write('Error: archiving save state failed\n')
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -188,12 +182,7 @@ class CD32(object):
|
||||
|
||||
curdir = os.path.abspath('.')
|
||||
os.chdir(self.dir)
|
||||
try:
|
||||
subprocess.call(['7z', 'x', self.save_filename])
|
||||
except subprocess.CalledProcessError:
|
||||
sys.stderr.write('Warning: extracting archive with save state '
|
||||
'failed\n')
|
||||
|
||||
utils.run_command(['7z', 'x', self.save_filename])
|
||||
os.chdir(curdir)
|
||||
return True
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ Misc utilities
|
||||
"""
|
||||
from distutils import spawn
|
||||
import os
|
||||
import six
|
||||
import subprocess
|
||||
import sys
|
||||
try:
|
||||
@@ -105,6 +106,24 @@ def extract_archive(arch_name, show_gui_message, message_text):
|
||||
return True
|
||||
|
||||
|
||||
def run_command(cmd):
|
||||
"""
|
||||
Run provided command. Return true if command execution returns zero exit
|
||||
code, false otherwise. If cmd is a string, there would be an attempt to
|
||||
split it up for subprocess call method.
|
||||
"""
|
||||
|
||||
if isinstance(six.text_type(cmd), six.string_types):
|
||||
cmd = cmd.split()
|
||||
|
||||
code = subprocess.call(cmd)
|
||||
if code != 0:
|
||||
sys.stderr.write('Command `{0}` returned non 0 exit '
|
||||
'code\n'.format(cmd[0]))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def merge_all_options(configuration, commandline):
|
||||
"""
|
||||
Merge dictionaries with wrapper options into one. Commandline options
|
||||
|
||||
Reference in New Issue
Block a user