From 77204f6b464dc5cbb3705d0ca0d3145d2e397455 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 3 Apr 2013 00:05:55 +0200 Subject: [PATCH 1/5] main: Fix flake8 warnings --- mopidy/__main__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mopidy/__main__.py b/mopidy/__main__.py index 1c0a8515..2a427f02 100644 --- a/mopidy/__main__.py +++ b/mopidy/__main__.py @@ -41,8 +41,7 @@ from mopidy.audio import Audio from mopidy.config import default_config, config_schemas from mopidy.core import Core from mopidy.utils import ( - config as config_utils, deps, log, path, process, - settings as settings_utils, versioning) + config as config_utils, deps, log, path, process, versioning) logger = logging.getLogger('mopidy.main') @@ -60,7 +59,8 @@ def main(): try: # TODO: we need a two stage logging setup as we want logging for # extension loading and config loading. - log.setup_logging(None, options.verbosity_level, options.save_debug_log) + log.setup_logging( + None, options.verbosity_level, options.save_debug_log) extensions = load_extensions() raw_config = load_config(config_files, config_overrides, extensions) extensions = filter_enabled_extensions(raw_config, extensions) From c00a49ebe1ac1d1e26b7f6ab855eabf27163acde Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 3 Apr 2013 00:07:14 +0200 Subject: [PATCH 2/5] main: Remove sys.path modification --- mopidy/__main__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mopidy/__main__.py b/mopidy/__main__.py index 2a427f02..3c312ba0 100644 --- a/mopidy/__main__.py +++ b/mopidy/__main__.py @@ -30,12 +30,6 @@ mopidy_args = [arg for arg in sys.argv[1:] if not is_gst_arg(arg)] sys.argv[1:] = gstreamer_args -# Add ../ to the path so we can run Mopidy from a Git checkout without -# installing it on the system. -sys.path.insert( - 0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))) - - from mopidy import exceptions, settings from mopidy.audio import Audio from mopidy.config import default_config, config_schemas From 6c4ec7e0c2a2f5459d092dcd6683150e08ae77c4 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 3 Apr 2013 00:10:23 +0200 Subject: [PATCH 3/5] main: Remove support for --gst-* and --help-gst Use GStreamer's environment variables instead, e.g. GST_DEBUG=3. --- mopidy/__main__.py | 20 ++++---------------- tests/help_test.py | 8 -------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/mopidy/__main__.py b/mopidy/__main__.py index 3c312ba0..f6b3127b 100644 --- a/mopidy/__main__.py +++ b/mopidy/__main__.py @@ -16,18 +16,10 @@ import pkg_resources import pykka.debug -# Extract any non-GStreamer arguments, and leave the GStreamer arguments for -# processing by GStreamer. This needs to be done before GStreamer is imported, -# so that GStreamer doesn't hijack e.g. ``--help``. -# NOTE This naive fix does not support values like ``bar`` in -# ``--gst-foo bar``. Use equals to pass values, like ``--gst-foo=bar``. - -def is_gst_arg(argument): - return argument.startswith('--gst') or argument == '--help-gst' - -gstreamer_args = [arg for arg in sys.argv[1:] if is_gst_arg(arg)] -mopidy_args = [arg for arg in sys.argv[1:] if not is_gst_arg(arg)] -sys.argv[1:] = gstreamer_args +# Extract any command line arguments. This needs to be done before GStreamer is +# imported, so that GStreamer doesn't hijack e.g. ``--help``. +mopidy_args = sys.argv[1:] +sys.argv[1:] = [] from mopidy import exceptions, settings @@ -101,10 +93,6 @@ def parse_options(): # NOTE First argument to add_option must be bytestrings on Python < 2.6.2 # See https://github.com/mopidy/mopidy/issues/302 for details - parser.add_option( - b'--help-gst', - action='store_true', dest='help_gst', - help='show GStreamer help options') parser.add_option( b'-i', '--interactive', action='store_true', dest='interactive', diff --git a/tests/help_test.py b/tests/help_test.py index 15c51d2a..4a852804 100644 --- a/tests/help_test.py +++ b/tests/help_test.py @@ -17,7 +17,6 @@ class HelpTest(unittest.TestCase): output = process.communicate()[0] self.assertIn('--version', output) self.assertIn('--help', output) - self.assertIn('--help-gst', output) self.assertIn('--interactive', output) self.assertIn('--quiet', output) self.assertIn('--verbose', output) @@ -25,10 +24,3 @@ class HelpTest(unittest.TestCase): self.assertIn('--show-config', output) self.assertIn('--config', output) self.assertIn('--option', output) - - def test_help_gst_has_gstreamer_options(self): - mopidy_dir = os.path.dirname(mopidy.__file__) - args = [sys.executable, mopidy_dir, '--help-gst'] - process = subprocess.Popen(args, stdout=subprocess.PIPE) - output = process.communicate()[0] - self.assertIn('--gst-version', output) From f9fb30c76ca4ba6573d12c7a138ed33ac46a5d34 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 3 Apr 2013 00:16:37 +0200 Subject: [PATCH 4/5] main/settings: Remove --interactive support --- mopidy/__main__.py | 10 +++------- mopidy/utils/settings.py | 9 +-------- tests/help_test.py | 1 - tests/utils/settings_test.py | 14 -------------- 4 files changed, 4 insertions(+), 30 deletions(-) diff --git a/mopidy/__main__.py b/mopidy/__main__.py index f6b3127b..6c1eb2ad 100644 --- a/mopidy/__main__.py +++ b/mopidy/__main__.py @@ -52,7 +52,7 @@ def main(): extensions = filter_enabled_extensions(raw_config, extensions) config = validate_config(raw_config, extensions) check_old_folders() - setup_settings(options.interactive) + setup_settings() audio = setup_audio(config) backends = setup_backends(config, extensions, audio) core = setup_core(audio, backends) @@ -93,10 +93,6 @@ def parse_options(): # NOTE First argument to add_option must be bytestrings on Python < 2.6.2 # See https://github.com/mopidy/mopidy/issues/302 for details - parser.add_option( - b'-i', '--interactive', - action='store_true', dest='interactive', - help='ask interactively for required settings which are missing') parser.add_option( b'-q', '--quiet', action='store_const', const=0, dest='verbosity_level', @@ -298,12 +294,12 @@ def validate_config(raw_config, extensions): return config -def setup_settings(interactive): +def setup_settings(): path.get_or_create_folder(path.SETTINGS_PATH) path.get_or_create_folder(path.DATA_PATH) path.get_or_create_file(path.SETTINGS_FILE) try: - settings.validate(interactive) + settings.validate() except exceptions.SettingsError as ex: logger.error(ex.message) sys.exit(1) diff --git a/mopidy/utils/settings.py b/mopidy/utils/settings.py index b61476f5..5916ee24 100644 --- a/mopidy/utils/settings.py +++ b/mopidy/utils/settings.py @@ -70,20 +70,13 @@ class SettingsProxy(object): else: super(SettingsProxy, self).__setattr__(attr, value) - def validate(self, interactive): - if interactive: - self._read_missing_settings_from_stdin(self.current, self.runtime) + def validate(self): if self.get_errors(): logger.error( 'Settings validation errors: %s', formatting.indent(self.get_errors_as_string())) raise exceptions.SettingsError('Settings validation failed.') - def _read_missing_settings_from_stdin(self, current, runtime): - for setting, value in sorted(current.iteritems()): - if isinstance(value, basestring) and len(value) == 0: - runtime[setting] = self._read_from_stdin(setting + ': ') - def _read_from_stdin(self, prompt): if '_PASSWORD' in prompt: return ( diff --git a/tests/help_test.py b/tests/help_test.py index 4a852804..b1ba9d64 100644 --- a/tests/help_test.py +++ b/tests/help_test.py @@ -17,7 +17,6 @@ class HelpTest(unittest.TestCase): output = process.communicate()[0] self.assertIn('--version', output) self.assertIn('--help', output) - self.assertIn('--interactive', output) self.assertIn('--quiet', output) self.assertIn('--verbose', output) self.assertIn('--save-debug-log', output) diff --git a/tests/utils/settings_test.py b/tests/utils/settings_test.py index 787337d2..3b1e67b0 100644 --- a/tests/utils/settings_test.py +++ b/tests/utils/settings_test.py @@ -150,20 +150,6 @@ class SettingsProxyTest(unittest.TestCase): self.settings.TEST_PATH = None self.assertEqual(self.settings.TEST_PATH, None) - def test_interactive_input_of_missing_defaults(self): - self.settings.default['TEST'] = '' - interactive_input = 'input' - self.settings._read_from_stdin = lambda _: interactive_input - self.settings.validate(interactive=True) - self.assertEqual(interactive_input, self.settings.TEST) - - def test_interactive_input_not_needed_when_setting_is_set_locally(self): - self.settings.default['TEST'] = '' - self.settings.local['TEST'] = 'test' - self.settings._read_from_stdin = lambda _: self.fail( - 'Should not read from stdin') - self.settings.validate(interactive=True) - class DidYouMeanTest(unittest.TestCase): def testSuggestoins(self): From 99f26dd41cc0810c207b6838e0ad19ee34004c34 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 3 Apr 2013 00:39:57 +0200 Subject: [PATCH 5/5] Revert "main: Remove sys.path modification" This reverts commit c00a49ebe1ac1d1e26b7f6ab855eabf27163acde. --- mopidy/__main__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mopidy/__main__.py b/mopidy/__main__.py index 6c1eb2ad..a5613d33 100644 --- a/mopidy/__main__.py +++ b/mopidy/__main__.py @@ -22,6 +22,12 @@ mopidy_args = sys.argv[1:] sys.argv[1:] = [] +# Add ../ to the path so we can run Mopidy from a Git checkout without +# installing it on the system. +sys.path.insert( + 0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))) + + from mopidy import exceptions, settings from mopidy.audio import Audio from mopidy.config import default_config, config_schemas