mirror of
https://github.com/gryf/fs-uae-wrapper.git
synced 2026-02-02 22:25:47 +01:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 75d2cff96c | |||
| 114984cbee | |||
| b015e443eb | |||
| 874213aef9 | |||
| 1559591417 |
@@ -2,7 +2,10 @@ language: python
|
||||
env:
|
||||
- TOXENV=py27
|
||||
- TOXENV=py27-flake8
|
||||
- TOXENV=py34
|
||||
- TOXENV=py34-flake8
|
||||
- TOXENV=py3
|
||||
- TOXENV=py3-flake8
|
||||
install: pip install tox
|
||||
script: tox
|
||||
before_install:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get install -y python-tk python3-tk
|
||||
|
||||
@@ -25,7 +25,7 @@ preferably in a archive file vs a bunch of files.
|
||||
Requirements
|
||||
============
|
||||
|
||||
- Python (2 or 3)
|
||||
- Python 3
|
||||
- `fs-uae`_ (obviously :)
|
||||
|
||||
Fs-uae-wrapper supports several types of archives:
|
||||
|
||||
@@ -219,7 +219,11 @@ class Base(object):
|
||||
changed_options[key] = abspath
|
||||
continue
|
||||
|
||||
changed_options[key] = os.path.abspath(val)
|
||||
_val = os.path.abspath(val)
|
||||
if os.path.exists(_val):
|
||||
changed_options[key] = _val
|
||||
else:
|
||||
changed_options[key] = val
|
||||
|
||||
self.fsuae_options.update(changed_options)
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Simple class for executing fs-uae with specified parameters. This is a
|
||||
failsafe class for running fs-uae.
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
"""
|
||||
Misc utilities
|
||||
"""
|
||||
from distutils import spawn
|
||||
import configparser
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
try:
|
||||
import configparser
|
||||
except ImportError:
|
||||
import ConfigParser as configparser
|
||||
|
||||
from fs_uae_wrapper import message
|
||||
from fs_uae_wrapper import file_archive
|
||||
@@ -46,7 +43,7 @@ class CmdOption(dict):
|
||||
|
||||
def get_config_options(conf):
|
||||
"""Read config file and return options as a dict"""
|
||||
parser = configparser.SafeConfigParser()
|
||||
parser = configparser.ConfigParser()
|
||||
try:
|
||||
parser.read(conf)
|
||||
except configparser.ParsingError:
|
||||
@@ -144,6 +141,7 @@ def interpolate_variables(string, config_path, base=None):
|
||||
- $BASE
|
||||
"""
|
||||
|
||||
_string = string
|
||||
if '$CONFIG' in string:
|
||||
conf_path = os.path.dirname(os.path.abspath(config_path))
|
||||
string = os.path.abspath(string.replace('$CONFIG', conf_path))
|
||||
@@ -152,10 +150,10 @@ def interpolate_variables(string, config_path, base=None):
|
||||
string = string.replace('$HOME', os.path.expandvars('$HOME'))
|
||||
|
||||
if '$EXE' in string:
|
||||
string = string.replace('$EXE', spawn.find_executable('fs-uae'))
|
||||
string = string.replace('$EXE', shutil.which('fs-uae'))
|
||||
|
||||
if '$APP' in string:
|
||||
string = string.replace('$APP', spawn.find_executable('fs-uae'))
|
||||
string = string.replace('$APP', shutil.which('fs-uae'))
|
||||
|
||||
if '$DOCUMENTS' in string:
|
||||
xdg_docs = os.getenv('XDG_DOCUMENTS_DIR',
|
||||
@@ -166,7 +164,9 @@ def interpolate_variables(string, config_path, base=None):
|
||||
if '$BASE' in string:
|
||||
string = string.replace('$BASE', base)
|
||||
|
||||
return string
|
||||
if os.path.exists(string):
|
||||
return string
|
||||
return _string
|
||||
|
||||
|
||||
def get_config(conf_file):
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Wrapper for FS-UAE to perform some actions before and or after running the
|
||||
emulator, if appropriate option is enabled.
|
||||
@@ -119,7 +118,3 @@ def run():
|
||||
|
||||
if not exit_code:
|
||||
sys.exit(4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Run CD32 games using fsuae
|
||||
"""
|
||||
|
||||
from fs_uae_wrapper import wrapper
|
||||
|
||||
|
||||
def main():
|
||||
"""run wrapper"""
|
||||
wrapper.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
36
setup.cfg
Normal file
36
setup.cfg
Normal file
@@ -0,0 +1,36 @@
|
||||
[metadata]
|
||||
name = fs-uae-wrapper
|
||||
summary = Automate archives and state for fs-uae
|
||||
description_file = README.rst
|
||||
author = Roman Dobosz
|
||||
author_email = gryf73@gmail.com
|
||||
url = https://github.com/gryf/fs-uea-wrapper
|
||||
license = BSD
|
||||
keywords = uae, fs-uae, amiga, emulator, wrapper
|
||||
version = 0.8.2
|
||||
classifier =
|
||||
Development Status :: 5 - Production/Stable
|
||||
Environment :: Console
|
||||
Intended Audience :: End Users/Desktop
|
||||
License :: OSI Approved :: BSD License
|
||||
Operating System :: OS Independent
|
||||
Programming Language :: Python :: 3
|
||||
Programming Language :: Python :: 3.8
|
||||
Programming Language :: Python :: 3.9
|
||||
Programming Language :: Python :: 3.10
|
||||
Topic :: System :: Emulators
|
||||
Topic :: Games/Entertainment
|
||||
|
||||
[install]
|
||||
record = install.log
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
fs-uae-wrapper = fs_uae_wrapper.wrapper:run
|
||||
|
||||
[files]
|
||||
packages =
|
||||
fs_uae_wrapper
|
||||
|
||||
[bdist_wheel]
|
||||
universal = 1
|
||||
30
setup.py
30
setup.py
@@ -1,31 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Setup for the fs-uae-wrapper
|
||||
"""
|
||||
from setuptools import setup
|
||||
import setuptools
|
||||
|
||||
|
||||
setup(name='fs-uae-wrapper',
|
||||
packages=['fs_uae_wrapper'],
|
||||
version='0.8.1',
|
||||
description='Automate archives and state for fs-uae',
|
||||
author='Roman Dobosz',
|
||||
author_email='gryf73@gmail.com',
|
||||
url='https://github.com/gryf/fs-uea-wrapper',
|
||||
download_url='https://github.com/gryf/fs-uae-wrapper/archive/master.zip',
|
||||
keywords=['uae', 'fs-uae', 'amiga', 'emulator', 'wrapper'],
|
||||
scripts=['script/fs-uae-wrapper'],
|
||||
classifiers=['Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Development Status :: 4 - Beta',
|
||||
'Environment :: Console',
|
||||
'Intended Audience :: End Users/Desktop',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Operating System :: OS Independent',
|
||||
'Topic :: System :: Emulators',
|
||||
'Topic :: Games/Entertainment'],
|
||||
long_description=open('README.rst').read(),
|
||||
options={'test': {'verbose': False,
|
||||
'coverage': False}})
|
||||
setuptools.setup()
|
||||
|
||||
@@ -47,9 +47,11 @@ class TestBase(TestCase):
|
||||
bobj.clean()
|
||||
self.assertFalse(os.path.exists(self.dirname))
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('fs_uae_wrapper.utils.get_config')
|
||||
def test_normalize_options(self, get_config):
|
||||
def test_normalize_options(self, get_config, os_exists):
|
||||
|
||||
os_exists.return_value = True
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
get_config.return_value = {'kickstarts_dir': '/some/path'}
|
||||
@@ -92,6 +94,28 @@ class TestBase(TestCase):
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {})
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('fs_uae_wrapper.utils.get_config')
|
||||
def test_normalize_options_path_not_exists(self, get_config, os_exists):
|
||||
|
||||
os_exists.return_value = False
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
get_config.return_value = {'kickstarts_dir': '/some/path'}
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {})
|
||||
|
||||
os.chdir(self.dirname)
|
||||
get_config.return_value = {'fmv_rom': 'bar'}
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options, {'fmv_rom': 'bar'})
|
||||
|
||||
get_config.return_value = {'floppies_dir': '../some/path'}
|
||||
bobj.fsuae_options = utils.CmdOption()
|
||||
bobj._normalize_options()
|
||||
self.assertDictEqual(bobj.fsuae_options,
|
||||
{'floppies_dir': '../some/path'})
|
||||
|
||||
def test_set_assets_paths(self):
|
||||
|
||||
bobj = base.Base('Config.fs-uae', utils.CmdOption(), {})
|
||||
|
||||
@@ -234,11 +234,13 @@ class TestCmdOptions(TestCase):
|
||||
self.assertListEqual(sorted(cmd.list()),
|
||||
['--fast_memory=4096', '--fullscreen'])
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('os.getenv')
|
||||
@mock.patch('os.path.expandvars')
|
||||
@mock.patch('distutils.spawn.find_executable')
|
||||
def test_interpolate_variables(self, find_exe, expandv, getenv):
|
||||
def test_interpolate_variables(self, find_exe, expandv, getenv, os_exists):
|
||||
|
||||
os_exists.return_value = True
|
||||
itrpl = utils.interpolate_variables
|
||||
|
||||
string = '$CONFIG/../path/to/smth'
|
||||
@@ -264,3 +266,11 @@ class TestCmdOptions(TestCase):
|
||||
'$BASE')
|
||||
self.assertEqual(itrpl(string, '/home/user/Config.fs-uae', 'base'),
|
||||
'base')
|
||||
|
||||
@mock.patch('os.getenv')
|
||||
@mock.patch('os.path.expandvars')
|
||||
def test_interpolate_variables_path_not_exists(self, expandv, getenv):
|
||||
itrpl = utils.interpolate_variables
|
||||
|
||||
string = '$CONFIG/../path/to/smth'
|
||||
self.assertEqual(itrpl(string, '/home/user/Config.fs-uae'), string)
|
||||
|
||||
15
tox.ini
15
tox.ini
@@ -1,5 +1,5 @@
|
||||
[tox]
|
||||
envlist = py27,py34,py27-flake8,py34-flake8
|
||||
envlist = py3,py3-flake8
|
||||
|
||||
usedevelop = True
|
||||
|
||||
@@ -10,16 +10,7 @@ commands = py.test --cov=fs_uae_wrapper --cov-report=term-missing
|
||||
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
|
||||
[testenv:py27]
|
||||
deps = {[testenv]deps}
|
||||
mock
|
||||
|
||||
[testenv:py34-flake8]
|
||||
basepython = python3.4
|
||||
deps = flake8
|
||||
commands = flake8 {posargs}
|
||||
|
||||
[testenv:py27-flake8]
|
||||
basepython = python2.7
|
||||
[testenv:py3-flake8]
|
||||
basepython = python3
|
||||
deps = flake8
|
||||
commands = flake8 {posargs}
|
||||
|
||||
Reference in New Issue
Block a user