From c63fdb2e1ab8c2e7977a9c19b35acb9d42cb071e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 10 Nov 2020 16:00:14 +0100 Subject: [PATCH 001/265] =?UTF-8?q?=F0=9F=94=96=20maintenance=20is=20now?= =?UTF-8?q?=201.6.0.dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .versioneer-lookup | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.versioneer-lookup b/.versioneer-lookup index 27076be81..f3df5e4aa 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -18,14 +18,14 @@ prerelease HEAD \(detached.* -# maintenance is currently the branch for preparation of maintenance release 1.5.0 +# maintenance is currently the branch for preparation of maintenance release 1.6.0 # so are any fix/... and improve/... branches -maintenance 1.5.0 42769dad7dda3bc0c6c94e0e8ce832af9b14a565 pep440-dev -fix/.* 1.5.0 42769dad7dda3bc0c6c94e0e8ce832af9b14a565 pep440-dev -improve/.* 1.5.0 42769dad7dda3bc0c6c94e0e8ce832af9b14a565 pep440-dev +maintenance 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev +fix/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev +improve/.* 1.6.0 b7a45b79bf86339f0b28177ac1eaebb56d00ea37 pep440-dev -# staging/hotfix is the branch for preparation of the 1.4.2 hotfix release -staging/hotfix 1.4.2 3ab84ed7e4c3aaaf71fe0f184b465f25d689f929 pep440-dev +# staging/hotfix is the branch for preparation of the 1.4.3 hotfix release +staging/hotfix 1.4.3 3ab84ed7e4c3aaaf71fe0f184b465f25d689f929 pep440-dev # staging/maintenance is currently the branch for preparation of 1.5.0rc2 # so is regressionfix/... From 8fce191c558325f9e4f894330f8b1623c2f1f194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 11 Nov 2020 12:03:36 +0100 Subject: [PATCH 002/265] =?UTF-8?q?=F0=9F=A5=85=20Only=20import=20plugin?= =?UTF-8?q?=20if=20metadata=20has=20any=20control=20property?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Protects against loading things from the plugin folders that aren't actually plugins, like errant setup.py files, see for example https://community.octoprint.org/t/26143 --- src/octoprint/__init__.py | 22 ++++++++++++++++++++-- src/octoprint/plugin/core.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index de9bd4d30..d2de8d655 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -619,16 +619,34 @@ def init_pluginsystem( ) plugin_validators = [] + + def implementation_or_hook_validator(phase, plugin_info): + if phase in ("before_import", "before_load", "before_enable"): + result = plugin_info.parsed_metadata.get("has_control_properties", False) + if not result: + logger.info( + "Plugin {} declares no control properties, " + "might not even be a plugin, disabling".format(plugin_info.name) + ) + return result + return True + + plugin_validators.append(implementation_or_hook_validator) + if safe_mode: - def validator(phase, plugin_info): + def safe_mode_validator(phase, plugin_info): if phase in ("before_import", "before_load", "before_enable"): plugin_info.safe_mode_victim = not plugin_info.bundled if not plugin_info.bundled: + logger.info( + "Plugin {} is not bundled, safe mode is active, " + "disabling".format(plugin_info.name) + ) return False return True - plugin_validators.append(validator) + plugin_validators.append(safe_mode_validator) compatibility_ignored_list = settings.get(["plugins", "_forcedCompatible"]) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index b3010b1ec..3d5f35da1 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -734,6 +734,14 @@ class PluginInfo(object): """The plugin metadata parsed from the plugin ``__init__.py``'s AST.""" return self._cached_parsed_metadata + @property + def control_properties(self): + return [ + getattr(self.__class__, key) + for key in dir(self.__class__) + if key.startswith("attr_") + ] + def _parse_metadata(self): result = {} @@ -764,6 +772,10 @@ class PluginInfo(object): assignments = list( filter(lambda x: isinstance(x, ast.Assign) and x.targets, root.body) ) + function_defs = list( + filter(lambda x: isinstance(x, ast.FunctionDef) and x.name, root.body) + ) + all_relevant = assignments + function_defs def extract_target_ids(node): return list( @@ -773,6 +785,16 @@ class PluginInfo(object): ) ) + def extract_names(node): + if isinstance(node, ast.Assign): + return extract_target_ids(node) + elif isinstance(node, ast.FunctionDef): + return [ + node.name, + ] + else: + return [] + for key in ( self.__class__.attr_name, self.__class__.attr_version, @@ -811,6 +833,12 @@ class PluginInfo(object): break + for a in reversed(all_relevant): + targets = extract_names(a) + if any(map(lambda x: x in targets, self.control_properties)): + result["has_control_properties"] = True + break + except SyntaxError: self._logger.exception( "Invalid syntax in {} for plugin {}".format(path, self.key) From cca3000eb2c40e6436588a91ef7793a2954c94a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 11 Nov 2020 12:04:30 +0100 Subject: [PATCH 003/265] =?UTF-8?q?=F0=9F=94=A5=20Remove=20deprecated=20pl?= =?UTF-8?q?ugin=20control=20properties?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __plugin_init__ and __plugin_implementations__ (plural!) have been deprecated since 1.2.0.dev, time to nuke them. --- src/octoprint/plugin/core.py | 71 +----------------------------------- 1 file changed, 2 insertions(+), 69 deletions(-) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 3d5f35da1..395f6b9eb 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -207,35 +207,12 @@ class PluginInfo(object): attr_implementation = "__plugin_implementation__" """ Module attribute from which to retrieve the plugin's provided mixin implementation. """ - attr_implementations = "__plugin_implementations__" - """ - Module attribute from which to retrieve the plugin's provided implementations. - - This deprecated attribute will only be used if a plugin does not yet offer :attr:`attr_implementation`. Only the - first entry will be evaluated. - - .. deprecated:: 1.2.0-dev-694 - - Use :attr:`attr_implementation` instead. - """ - attr_helpers = "__plugin_helpers__" """ Module attribute from which to retrieve the plugin's provided helpers. """ attr_check = "__plugin_check__" """ Module attribute which to call to determine if the plugin can be loaded. """ - attr_init = "__plugin_init__" - """ - Module attribute which to call when loading the plugin. - - This deprecated attribute will only be used if a plugin does not yet offer :attr:`attr_load`. - - .. deprecated:: 1.2.0-dev-720 - - Use :attr:`attr_load` instead. - """ - attr_load = "__plugin_load__" """ Module attribute which to call when loading the plugin. """ @@ -331,54 +308,10 @@ class PluginInfo(object): ) elif phase == "before_load": - # if the plugin still uses __plugin_init__, log a deprecation warning and move it to __plugin_load__ - if hasattr(self.instance, self.__class__.attr_init): - if not hasattr(self.instance, self.__class__.attr_load): - # deprecation warning - import warnings - - warnings.warn( - "{name} uses deprecated control property __plugin_init__, use __plugin_load__ instead".format( - name=self.key - ), - DeprecationWarning, - ) - - # move it - init = getattr(self.instance, self.__class__.attr_init) - setattr(self.instance, self.__class__.attr_load, init) - - # delete __plugin_init__ - delattr(self.instance, self.__class__.attr_init) + pass elif phase == "after_load": - # if the plugin still uses __plugin_implementations__, log a deprecation warning and put the first - # item into __plugin_implementation__ - if hasattr(self.instance, self.__class__.attr_implementations): - if not hasattr(self.instance, self.__class__.attr_implementation): - # deprecation warning - import warnings - - warnings.warn( - "{name} uses deprecated control property __plugin_implementations__, use __plugin_implementation__ instead - only the first implementation of {name} will be recognized".format( - name=self.key - ), - DeprecationWarning, - ) - - # put first item into __plugin_implementation__ - implementations = getattr( - self.instance, self.__class__.attr_implementations - ) - if len(implementations) > 0: - setattr( - self.instance, - self.__class__.attr_implementation, - implementations[0], - ) - - # delete __plugin_implementations__ - delattr(self.instance, self.__class__.attr_implementations) + pass if additional_validators is not None: for validator in additional_validators: From 9a573626026edcdf31ef927335375b59c0676e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 11 Nov 2020 18:23:29 +0100 Subject: [PATCH 004/265] =?UTF-8?q?=F0=9F=A5=85=20Better=20solution=20for?= =?UTF-8?q?=20invalid=20plugin=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Should be done at plugin manager level, not externally. Ignore pyc files though as we currently can't parse their metadata (looking into that). Fix tests while at it. --- src/octoprint/__init__.py | 17 ---------- src/octoprint/plugin/core.py | 33 +++++++++++++++++-- tests/plugin/_plugins/asset_plugin.py | 14 ++++++++ tests/plugin/_plugins/deprecated_plugin.py | 21 ------------ tests/plugin/_plugins/not_a_plugin.py | 2 ++ tests/plugin/test_core.py | 38 +++++++++++++++------- 6 files changed, 74 insertions(+), 51 deletions(-) create mode 100644 tests/plugin/_plugins/asset_plugin.py delete mode 100644 tests/plugin/_plugins/deprecated_plugin.py create mode 100644 tests/plugin/_plugins/not_a_plugin.py diff --git a/src/octoprint/__init__.py b/src/octoprint/__init__.py index d2de8d655..fb2721185 100644 --- a/src/octoprint/__init__.py +++ b/src/octoprint/__init__.py @@ -620,29 +620,12 @@ def init_pluginsystem( plugin_validators = [] - def implementation_or_hook_validator(phase, plugin_info): - if phase in ("before_import", "before_load", "before_enable"): - result = plugin_info.parsed_metadata.get("has_control_properties", False) - if not result: - logger.info( - "Plugin {} declares no control properties, " - "might not even be a plugin, disabling".format(plugin_info.name) - ) - return result - return True - - plugin_validators.append(implementation_or_hook_validator) - if safe_mode: def safe_mode_validator(phase, plugin_info): if phase in ("before_import", "before_load", "before_enable"): plugin_info.safe_mode_victim = not plugin_info.bundled if not plugin_info.bundled: - logger.info( - "Plugin {} is not bundled, safe mode is active, " - "disabling".format(plugin_info.name) - ) return False return True diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 395f6b9eb..7c9f666ee 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -300,7 +300,8 @@ class PluginInfo(object): if phase == "before_import": result = ( - not self.forced_disabled + self.looks_like_plugin + and not self.forced_disabled and not self.blacklisted and not self.incompatible and not self.invalid_syntax @@ -675,6 +676,32 @@ class PluginInfo(object): if key.startswith("attr_") ] + @property + def looks_like_plugin(self): + """ + Returns whether the plugin actually looks like a plugin (has control properties) or not. + + Note that compiled (.pyc) plugins for now will return True here as well, since we + currently cannot easily parse metadata from them. + """ + return ( + self.parsed_metadata.get("has_control_properties", False) or self.is_compiled + ) + + @property + def is_compiled(self): + path = self.location + if not path: + return False + + if os.path.isdir(path): + path = os.path.join(self.location, "__init__.py") + + if not os.path.isfile(path): + return False + + return path.endswith(".pyc") + def _parse_metadata(self): result = {} @@ -1366,7 +1393,8 @@ class PluginManager(object): for name, plugin in added.items(): try: if ( - not plugin.blacklisted + plugin.looks_like_plugin + and not plugin.blacklisted and not plugin.forced_disabled and not plugin.incompatible ): @@ -1392,6 +1420,7 @@ class PluginManager(object): try: if ( plugin.loaded + and plugin.looks_like_plugin and not plugin.forced_disabled and not plugin.incompatible ): diff --git a/tests/plugin/_plugins/asset_plugin.py b/tests/plugin/_plugins/asset_plugin.py new file mode 100644 index 000000000..5936acc4e --- /dev/null +++ b/tests/plugin/_plugins/asset_plugin.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function, unicode_literals + +import octoprint.plugin + + +class TestAssetPlugin(octoprint.plugin.AssetPlugin): + pass + + +__plugin_name__ = "Asset Plugin" +__plugin_description__ = "Test asset plugin" +__plugin_implementation__ = TestAssetPlugin() +__plugin_pythoncompat__ = ">=2.7,<4" diff --git a/tests/plugin/_plugins/deprecated_plugin.py b/tests/plugin/_plugins/deprecated_plugin.py deleted file mode 100644 index 26b7610de..000000000 --- a/tests/plugin/_plugins/deprecated_plugin.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals - -import octoprint.plugin - - -class TestDeprecatedAssetPlugin(octoprint.plugin.AssetPlugin): - pass - - -class TestSecondaryDeprecatedAssetPlugin(octoprint.plugin.AssetPlugin): - pass - - -__plugin_name__ = "Deprecated Plugin" -__plugin_description__ = "Test deprecated plugin" -__plugin_implementations__ = [ - TestDeprecatedAssetPlugin(), - TestSecondaryDeprecatedAssetPlugin(), -] -__plugin_pythoncompat__ = ">=2.7,<4" diff --git a/tests/plugin/_plugins/not_a_plugin.py b/tests/plugin/_plugins/not_a_plugin.py new file mode 100644 index 000000000..c58e04714 --- /dev/null +++ b/tests/plugin/_plugins/not_a_plugin.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +print("I'm not a plugin") diff --git a/tests/plugin/test_core.py b/tests/plugin/test_core.py index 89c8954bf..4b1fdd826 100644 --- a/tests/plugin/test_core.py +++ b/tests/plugin/test_core.py @@ -68,6 +68,18 @@ class PluginTestCase(unittest.TestCase): os.path.dirname(os.path.realpath(__file__)), "_plugins" ) + # prepare compiled files + import py_compile + + py_compile.compile( + os.path.join(self.plugin_folder, "asset_plugin.py"), + os.path.join(self.plugin_folder, "asset_plugin_2.pyc"), + ) + py_compile.compile( + os.path.join(self.plugin_folder, "not_a_plugin.py"), + os.path.join(self.plugin_folder, "not_a_plugin_either.pyc"), + ) + plugin_folders = [self.plugin_folder] plugin_bases = [octoprint.plugin.OctoPrintPlugin] plugin_entry_points = None @@ -92,9 +104,10 @@ class PluginTestCase(unittest.TestCase): assert "__plugin_implementation__" in str(w[-1].message) def test_plugin_loading(self): - self.assertEqual(7, len(self.plugin_manager.enabled_plugins)) + self.assertEqual(9, len(self.plugin_manager.enabled_plugins)) + self.assertEqual(10, len(self.plugin_manager.plugins)) self.assertEqual(2, len(self.plugin_manager.plugin_hooks)) - self.assertEqual(4, len(self.plugin_manager.plugin_implementations)) + self.assertEqual(5, len(self.plugin_manager.plugin_implementations)) self.assertEqual(3, len(self.plugin_manager.plugin_implementations_by_type)) # hook_plugin @@ -137,13 +150,13 @@ class PluginTestCase(unittest.TestCase): ), ) - # TestDeprecatedAssetPlugin, NOT TestSecondaryDeprecatedAssetPlugin + # TestAssetPlugin self.assertTrue( octoprint.plugin.AssetPlugin in self.plugin_manager.plugin_implementations_by_type ) self.assertEqual( - 1, + 2, len( self.plugin_manager.plugin_implementations_by_type[ octoprint.plugin.AssetPlugin @@ -167,7 +180,7 @@ class PluginTestCase(unittest.TestCase): ) all_implementations = self.plugin_manager.plugin_implementations - self.assertEqual(4, len(all_implementations)) + self.assertEqual(5, len(all_implementations)) for name, impl in all_implementations.items(): self.assertTrue(name in self.plugin_manager.enabled_plugins) plugin = self.plugin_manager.enabled_plugins[name] @@ -258,7 +271,8 @@ class PluginTestCase(unittest.TestCase): octoprint.plugin.AssetPlugin ) self.assertListEqual( - ["deprecated_plugin"], list(map(lambda x: x._identifier, implementations)) + ["asset_plugin", "asset_plugin_2"], + list(map(lambda x: x._identifier, implementations)), ) def test_get_filtered_implementations(self): @@ -305,12 +319,14 @@ class PluginTestCase(unittest.TestCase): client1.on_plugin_message.assert_called_once_with(plugin, data, permissions=None) client2.on_plugin_message.assert_called_once_with(plugin, data, permissions=None) - def test_validate_plugin(self): - self.assertTrue("deprecated_plugin" in self.plugin_manager.enabled_plugins) + def test_broken_plugin(self): + for key in ("not_a_plugin",): + self.assertTrue(key in self.plugin_manager.plugins) - plugin = self.plugin_manager.enabled_plugins["deprecated_plugin"] - self.assertTrue(hasattr(plugin.instance, plugin.__class__.attr_implementation)) - self.assertFalse(hasattr(plugin.instance, plugin.__class__.attr_implementations)) + plugin = self.plugin_manager.plugins[key] + self.assertFalse(plugin.looks_like_plugin) + self.assertFalse(plugin.loaded) + self.assertFalse(plugin.enabled) @ddt.data( ( From a4b44a8b0fa684134c879acda9ae7985cc300e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 12 Nov 2020 10:11:49 +0100 Subject: [PATCH 005/265] =?UTF-8?q?=F0=9F=A5=85=20Do=20not=20support=20pyc?= =?UTF-8?q?=20plugins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pyc file alone should really never happen anyhow in our plugin setup, and they would not load under Py3 anyhow as we can't parse the compatibility information right now. Simply removing their support altogether as it should not have been utilized anywhere anyhow as far as I am aware, and never was officially documented as supported to boot. --- src/octoprint/plugin/core.py | 32 +++++--------------------------- tests/plugin/test_core.py | 23 +++++++++++------------ 2 files changed, 16 insertions(+), 39 deletions(-) diff --git a/src/octoprint/plugin/core.py b/src/octoprint/plugin/core.py index 7c9f666ee..c7ce091a6 100644 --- a/src/octoprint/plugin/core.py +++ b/src/octoprint/plugin/core.py @@ -665,7 +665,7 @@ class PluginInfo(object): @property def parsed_metadata(self): - """The plugin metadata parsed from the plugin ``__init__.py``'s AST.""" + """The plugin metadata parsed from the plugin's AST.""" return self._cached_parsed_metadata @property @@ -680,27 +680,8 @@ class PluginInfo(object): def looks_like_plugin(self): """ Returns whether the plugin actually looks like a plugin (has control properties) or not. - - Note that compiled (.pyc) plugins for now will return True here as well, since we - currently cannot easily parse metadata from them. """ - return ( - self.parsed_metadata.get("has_control_properties", False) or self.is_compiled - ) - - @property - def is_compiled(self): - path = self.location - if not path: - return False - - if os.path.isdir(path): - path = os.path.join(self.location, "__init__.py") - - if not os.path.isfile(path): - return False - - return path.endswith(".pyc") + return self.parsed_metadata.get("has_control_properties", False) def _parse_metadata(self): result = {} @@ -1003,11 +984,8 @@ class PluginManager(object): try: if entry.is_dir(): init_py = os.path.join(entry.path, "__init__.py") - init_pyc = os.path.join(entry.path, "__init__.pyc") - if not os.path.isfile(init_py) and not os.path.isfile( - init_pyc - ): + if not os.path.isfile(init_py): # neither does exist, we ignore this continue @@ -1015,8 +993,8 @@ class PluginManager(object): elif entry.is_file(): key, ext = os.path.splitext(entry.name) - if ext not in (".py", ".pyc") or key.startswith("__"): - # neither py nor pyc, or starts with __ (like __init__), we ignore this + if ext not in (".py",) or key.startswith("__"): + # not py, or starts with __ (like __init__), we ignore this continue else: diff --git a/tests/plugin/test_core.py b/tests/plugin/test_core.py index 4b1fdd826..f58fe2f97 100644 --- a/tests/plugin/test_core.py +++ b/tests/plugin/test_core.py @@ -104,10 +104,10 @@ class PluginTestCase(unittest.TestCase): assert "__plugin_implementation__" in str(w[-1].message) def test_plugin_loading(self): - self.assertEqual(9, len(self.plugin_manager.enabled_plugins)) - self.assertEqual(10, len(self.plugin_manager.plugins)) + self.assertEqual(7, len(self.plugin_manager.enabled_plugins)) + self.assertEqual(8, len(self.plugin_manager.plugins)) self.assertEqual(2, len(self.plugin_manager.plugin_hooks)) - self.assertEqual(5, len(self.plugin_manager.plugin_implementations)) + self.assertEqual(4, len(self.plugin_manager.plugin_implementations)) self.assertEqual(3, len(self.plugin_manager.plugin_implementations_by_type)) # hook_plugin @@ -156,7 +156,7 @@ class PluginTestCase(unittest.TestCase): in self.plugin_manager.plugin_implementations_by_type ) self.assertEqual( - 2, + 1, len( self.plugin_manager.plugin_implementations_by_type[ octoprint.plugin.AssetPlugin @@ -180,7 +180,7 @@ class PluginTestCase(unittest.TestCase): ) all_implementations = self.plugin_manager.plugin_implementations - self.assertEqual(5, len(all_implementations)) + self.assertEqual(4, len(all_implementations)) for name, impl in all_implementations.items(): self.assertTrue(name in self.plugin_manager.enabled_plugins) plugin = self.plugin_manager.enabled_plugins[name] @@ -271,7 +271,7 @@ class PluginTestCase(unittest.TestCase): octoprint.plugin.AssetPlugin ) self.assertListEqual( - ["asset_plugin", "asset_plugin_2"], + ["asset_plugin"], list(map(lambda x: x._identifier, implementations)), ) @@ -320,13 +320,12 @@ class PluginTestCase(unittest.TestCase): client2.on_plugin_message.assert_called_once_with(plugin, data, permissions=None) def test_broken_plugin(self): - for key in ("not_a_plugin",): - self.assertTrue(key in self.plugin_manager.plugins) + self.assertTrue("not_a_plugin" in self.plugin_manager.plugins) - plugin = self.plugin_manager.plugins[key] - self.assertFalse(plugin.looks_like_plugin) - self.assertFalse(plugin.loaded) - self.assertFalse(plugin.enabled) + plugin = self.plugin_manager.plugins["not_a_plugin"] + self.assertFalse(plugin.looks_like_plugin) + self.assertFalse(plugin.loaded) + self.assertFalse(plugin.enabled) @ddt.data( ( From 3e9b4ccf3ddec309474da41faf35d00475c3ba11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 12 Nov 2020 10:22:20 +0100 Subject: [PATCH 006/265] =?UTF-8?q?=F0=9F=9A=B8=20PMGR:=20Log=20deletion?= =?UTF-8?q?=20of=20pyc=20files=20as=20well?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/octoprint/plugins/pluginmanager/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index d730aa2b1..b545ed677 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -1057,6 +1057,9 @@ class PluginManagerPlugin( if full_path.endswith(".py"): pyc_file = "{full_path}c".format(**locals()) if os.path.isfile(pyc_file): + self._log_stdout( + "Deleting plugin from {file}".format(file=pyc_file) + ) os.remove(pyc_file) else: From 9c2f50a620e89157a9332cf92ab880b7f8435f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 13 Nov 2020 10:58:27 +0100 Subject: [PATCH 007/265] =?UTF-8?q?=E2=99=BB=20Properties=20for=20min/max?= =?UTF-8?q?=20on=20CountedEvent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cc @chendo --- src/octoprint/util/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index f28f1bff5..288335046 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -1654,6 +1654,24 @@ class CountedEvent(object): self._internal_set(value) + @property + def min(self): + return self._min + + @min.setter + def min(self, val): + with self._mutex: + self._min = val + + @property + def max(self): + return self._max + + @max.setter + def max(self, val): + with self._mutex: + self._max = val + @property def is_set(self): return self._event.is_set From b4e5fd0299eb19f9a87f2e2fb5d136086fec40ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 13 Nov 2020 10:58:55 +0100 Subject: [PATCH 008/265] =?UTF-8?q?=E2=99=BB=20Make=20last=20lines=20buffe?= =?UTF-8?q?r=20size=20configurable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cc @chendo --- src/octoprint/settings.py | 1 + src/octoprint/util/comm.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/octoprint/settings.py b/src/octoprint/settings.py index e39e011e2..a09916eb3 100644 --- a/src/octoprint/settings.py +++ b/src/octoprint/settings.py @@ -133,6 +133,7 @@ default_settings = { "disconnectOnErrors": True, "ignoreErrorsFromFirmware": False, "terminalLogSize": 20, + "lastLineBufferSize": 50, "logResends": True, "supportResendsWithoutOk": "detect", "logPositionOnPause": True, diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index c20a52524..a491d9c17 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -590,7 +590,8 @@ class MachineCom(object): ), } - self._lastLines = deque([], 50) + last_line_count = settings().getInt(["serial", "lastLineBufferSize"]) + self._lastLines = deque([], last_line_count) self._lastCommError = None self._lastResendNumber = None self._currentResendCount = 0 From 316c830eaa347d460854b4484fc9f239e2fd6010 Mon Sep 17 00:00:00 2001 From: jneilliii Date: Sun, 15 Nov 2020 11:20:41 -0500 Subject: [PATCH 009/265] changes the backup filename to be based on appearance > name setting, if configured --- src/octoprint/plugins/backup/__init__.py | 21 +- .../static/js/lib/jquery/jquery-ui.js | 17746 +++++++++++++++- 2 files changed, 17757 insertions(+), 10 deletions(-) diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 2b2b3bf94..47b621c35 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -54,15 +54,9 @@ from octoprint.settings import valid_boolean_trues UNKNOWN_PLUGINS_FILE = "unknown_plugins_from_restore.json" -BACKUP_FILE_PREFIX = "octoprint-backup" - BACKUP_DATE_TIME_FMT = "%Y%m%d-%H%M%S" -def build_backup_filename(): - return "{}-{}.zip".format(BACKUP_FILE_PREFIX, time.strftime(BACKUP_DATE_TIME_FMT)) - - class BackupPlugin( octoprint.plugin.SettingsPlugin, octoprint.plugin.TemplatePlugin, @@ -129,6 +123,17 @@ class BackupPlugin( {"type": "wizard", "name": gettext("Restore Backup?")}, ] + ##~~ Utility Methods + + def build_backup_filename(self): + if self._settings.global_get(["appearance", "name"]) == "": + backup_prefix = "octoprint" + else: + backup_prefix = self._settings.global_get(["appearance", "name"]) + return "{}-backup-{}.zip".format( + backup_prefix, time.strftime(BACKUP_DATE_TIME_FMT) + ) + ##~~ BlueprintPlugin @octoprint.plugin.BlueprintPlugin.route("/", methods=["GET"]) @@ -174,7 +179,7 @@ class BackupPlugin( @no_firstrun_access @Permissions.PLUGIN_BACKUP_ACCESS.require(403) def create_backup(self): - backup_file = build_backup_filename() + backup_file = self.build_backup_filename() data = flask.request.json exclude = data.get("exclude", []) @@ -490,7 +495,7 @@ class BackupPlugin( if path is not None: datafolder, backup_file = os.path.split(os.path.abspath(path)) else: - backup_file = build_backup_filename() + backup_file = self.build_backup_filename() datafolder = os.path.join(settings.getBaseFolder("data"), "backup") if not os.path.isdir(datafolder): diff --git a/src/octoprint/static/js/lib/jquery/jquery-ui.js b/src/octoprint/static/js/lib/jquery/jquery-ui.js index 290aeb7dc..f3271eed5 100644 --- a/src/octoprint/static/js/lib/jquery/jquery-ui.js +++ b/src/octoprint/static/js/lib/jquery/jquery-ui.js @@ -1,6 +1,6 @@ -/*! jQuery UI - v1.12.1 - 2020-11-03 +/*! jQuery UI - v1.12.1 - 2020-11-07 * http://jqueryui.com -* Includes: widget.js, widgets/mouse.js +* Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/selectable.js, widgets/sortable.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/selectmenu.js, widgets/slider.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js * Copyright jQuery Foundation and other contributors; Licensed MIT */ (function( factory ) { @@ -743,6 +743,982 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { var widget = $.widget; +/*! + * jQuery UI Position 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * http://api.jqueryui.com/position/ + */ + +//>>label: Position +//>>group: Core +//>>description: Positions elements relative to other elements. +//>>docs: http://api.jqueryui.com/position/ +//>>demos: http://jqueryui.com/position/ + + +( function() { +var cachedScrollbarWidth, + max = Math.max, + abs = Math.abs, + rhorizontal = /left|center|right/, + rvertical = /top|center|bottom/, + roffset = /[\+\-]\d+(\.[\d]+)?%?/, + rposition = /^\w+/, + rpercent = /%$/, + _position = $.fn.position; + +function getOffsets( offsets, width, height ) { + return [ + parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ), + parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 ) + ]; +} + +function parseCss( element, property ) { + return parseInt( $.css( element, property ), 10 ) || 0; +} + +function getDimensions( elem ) { + var raw = elem[ 0 ]; + if ( raw.nodeType === 9 ) { + return { + width: elem.width(), + height: elem.height(), + offset: { top: 0, left: 0 } + }; + } + if ( $.isWindow( raw ) ) { + return { + width: elem.width(), + height: elem.height(), + offset: { top: elem.scrollTop(), left: elem.scrollLeft() } + }; + } + if ( raw.preventDefault ) { + return { + width: 0, + height: 0, + offset: { top: raw.pageY, left: raw.pageX } + }; + } + return { + width: elem.outerWidth(), + height: elem.outerHeight(), + offset: elem.offset() + }; +} + +$.position = { + scrollbarWidth: function() { + if ( cachedScrollbarWidth !== undefined ) { + return cachedScrollbarWidth; + } + var w1, w2, + div = $( "
" + + "
" ), + innerDiv = div.children()[ 0 ]; + + $( "body" ).append( div ); + w1 = innerDiv.offsetWidth; + div.css( "overflow", "scroll" ); + + w2 = innerDiv.offsetWidth; + + if ( w1 === w2 ) { + w2 = div[ 0 ].clientWidth; + } + + div.remove(); + + return ( cachedScrollbarWidth = w1 - w2 ); + }, + getScrollInfo: function( within ) { + var overflowX = within.isWindow || within.isDocument ? "" : + within.element.css( "overflow-x" ), + overflowY = within.isWindow || within.isDocument ? "" : + within.element.css( "overflow-y" ), + hasOverflowX = overflowX === "scroll" || + ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ), + hasOverflowY = overflowY === "scroll" || + ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight ); + return { + width: hasOverflowY ? $.position.scrollbarWidth() : 0, + height: hasOverflowX ? $.position.scrollbarWidth() : 0 + }; + }, + getWithinInfo: function( element ) { + var withinElement = $( element || window ), + isWindow = $.isWindow( withinElement[ 0 ] ), + isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9, + hasOffset = !isWindow && !isDocument; + return { + element: withinElement, + isWindow: isWindow, + isDocument: isDocument, + offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 }, + scrollLeft: withinElement.scrollLeft(), + scrollTop: withinElement.scrollTop(), + width: withinElement.outerWidth(), + height: withinElement.outerHeight() + }; + } +}; + +$.fn.position = function( options ) { + if ( !options || !options.of ) { + return _position.apply( this, arguments ); + } + + // Make a copy, we don't want to modify arguments + options = $.extend( {}, options ); + + var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions, + target = $( options.of ), + within = $.position.getWithinInfo( options.within ), + scrollInfo = $.position.getScrollInfo( within ), + collision = ( options.collision || "flip" ).split( " " ), + offsets = {}; + + dimensions = getDimensions( target ); + if ( target[ 0 ].preventDefault ) { + + // Force left top to allow flipping + options.at = "left top"; + } + targetWidth = dimensions.width; + targetHeight = dimensions.height; + targetOffset = dimensions.offset; + + // Clone to reuse original targetOffset later + basePosition = $.extend( {}, targetOffset ); + + // Force my and at to have valid horizontal and vertical positions + // if a value is missing or invalid, it will be converted to center + $.each( [ "my", "at" ], function() { + var pos = ( options[ this ] || "" ).split( " " ), + horizontalOffset, + verticalOffset; + + if ( pos.length === 1 ) { + pos = rhorizontal.test( pos[ 0 ] ) ? + pos.concat( [ "center" ] ) : + rvertical.test( pos[ 0 ] ) ? + [ "center" ].concat( pos ) : + [ "center", "center" ]; + } + pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center"; + pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center"; + + // Calculate offsets + horizontalOffset = roffset.exec( pos[ 0 ] ); + verticalOffset = roffset.exec( pos[ 1 ] ); + offsets[ this ] = [ + horizontalOffset ? horizontalOffset[ 0 ] : 0, + verticalOffset ? verticalOffset[ 0 ] : 0 + ]; + + // Reduce to just the positions without the offsets + options[ this ] = [ + rposition.exec( pos[ 0 ] )[ 0 ], + rposition.exec( pos[ 1 ] )[ 0 ] + ]; + } ); + + // Normalize collision option + if ( collision.length === 1 ) { + collision[ 1 ] = collision[ 0 ]; + } + + if ( options.at[ 0 ] === "right" ) { + basePosition.left += targetWidth; + } else if ( options.at[ 0 ] === "center" ) { + basePosition.left += targetWidth / 2; + } + + if ( options.at[ 1 ] === "bottom" ) { + basePosition.top += targetHeight; + } else if ( options.at[ 1 ] === "center" ) { + basePosition.top += targetHeight / 2; + } + + atOffset = getOffsets( offsets.at, targetWidth, targetHeight ); + basePosition.left += atOffset[ 0 ]; + basePosition.top += atOffset[ 1 ]; + + return this.each( function() { + var collisionPosition, using, + elem = $( this ), + elemWidth = elem.outerWidth(), + elemHeight = elem.outerHeight(), + marginLeft = parseCss( this, "marginLeft" ), + marginTop = parseCss( this, "marginTop" ), + collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + + scrollInfo.width, + collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + + scrollInfo.height, + position = $.extend( {}, basePosition ), + myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ); + + if ( options.my[ 0 ] === "right" ) { + position.left -= elemWidth; + } else if ( options.my[ 0 ] === "center" ) { + position.left -= elemWidth / 2; + } + + if ( options.my[ 1 ] === "bottom" ) { + position.top -= elemHeight; + } else if ( options.my[ 1 ] === "center" ) { + position.top -= elemHeight / 2; + } + + position.left += myOffset[ 0 ]; + position.top += myOffset[ 1 ]; + + collisionPosition = { + marginLeft: marginLeft, + marginTop: marginTop + }; + + $.each( [ "left", "top" ], function( i, dir ) { + if ( $.ui.position[ collision[ i ] ] ) { + $.ui.position[ collision[ i ] ][ dir ]( position, { + targetWidth: targetWidth, + targetHeight: targetHeight, + elemWidth: elemWidth, + elemHeight: elemHeight, + collisionPosition: collisionPosition, + collisionWidth: collisionWidth, + collisionHeight: collisionHeight, + offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], + my: options.my, + at: options.at, + within: within, + elem: elem + } ); + } + } ); + + if ( options.using ) { + + // Adds feedback as second argument to using callback, if present + using = function( props ) { + var left = targetOffset.left - position.left, + right = left + targetWidth - elemWidth, + top = targetOffset.top - position.top, + bottom = top + targetHeight - elemHeight, + feedback = { + target: { + element: target, + left: targetOffset.left, + top: targetOffset.top, + width: targetWidth, + height: targetHeight + }, + element: { + element: elem, + left: position.left, + top: position.top, + width: elemWidth, + height: elemHeight + }, + horizontal: right < 0 ? "left" : left > 0 ? "right" : "center", + vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle" + }; + if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) { + feedback.horizontal = "center"; + } + if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) { + feedback.vertical = "middle"; + } + if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) { + feedback.important = "horizontal"; + } else { + feedback.important = "vertical"; + } + options.using.call( this, props, feedback ); + }; + } + + elem.offset( $.extend( position, { using: using } ) ); + } ); +}; + +$.ui.position = { + fit: { + left: function( position, data ) { + var within = data.within, + withinOffset = within.isWindow ? within.scrollLeft : within.offset.left, + outerWidth = within.width, + collisionPosLeft = position.left - data.collisionPosition.marginLeft, + overLeft = withinOffset - collisionPosLeft, + overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset, + newOverRight; + + // Element is wider than within + if ( data.collisionWidth > outerWidth ) { + + // Element is initially over the left side of within + if ( overLeft > 0 && overRight <= 0 ) { + newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - + withinOffset; + position.left += overLeft - newOverRight; + + // Element is initially over right side of within + } else if ( overRight > 0 && overLeft <= 0 ) { + position.left = withinOffset; + + // Element is initially over both left and right sides of within + } else { + if ( overLeft > overRight ) { + position.left = withinOffset + outerWidth - data.collisionWidth; + } else { + position.left = withinOffset; + } + } + + // Too far left -> align with left edge + } else if ( overLeft > 0 ) { + position.left += overLeft; + + // Too far right -> align with right edge + } else if ( overRight > 0 ) { + position.left -= overRight; + + // Adjust based on position and margin + } else { + position.left = max( position.left - collisionPosLeft, position.left ); + } + }, + top: function( position, data ) { + var within = data.within, + withinOffset = within.isWindow ? within.scrollTop : within.offset.top, + outerHeight = data.within.height, + collisionPosTop = position.top - data.collisionPosition.marginTop, + overTop = withinOffset - collisionPosTop, + overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset, + newOverBottom; + + // Element is taller than within + if ( data.collisionHeight > outerHeight ) { + + // Element is initially over the top of within + if ( overTop > 0 && overBottom <= 0 ) { + newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - + withinOffset; + position.top += overTop - newOverBottom; + + // Element is initially over bottom of within + } else if ( overBottom > 0 && overTop <= 0 ) { + position.top = withinOffset; + + // Element is initially over both top and bottom of within + } else { + if ( overTop > overBottom ) { + position.top = withinOffset + outerHeight - data.collisionHeight; + } else { + position.top = withinOffset; + } + } + + // Too far up -> align with top + } else if ( overTop > 0 ) { + position.top += overTop; + + // Too far down -> align with bottom edge + } else if ( overBottom > 0 ) { + position.top -= overBottom; + + // Adjust based on position and margin + } else { + position.top = max( position.top - collisionPosTop, position.top ); + } + } + }, + flip: { + left: function( position, data ) { + var within = data.within, + withinOffset = within.offset.left + within.scrollLeft, + outerWidth = within.width, + offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left, + collisionPosLeft = position.left - data.collisionPosition.marginLeft, + overLeft = collisionPosLeft - offsetLeft, + overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft, + myOffset = data.my[ 0 ] === "left" ? + -data.elemWidth : + data.my[ 0 ] === "right" ? + data.elemWidth : + 0, + atOffset = data.at[ 0 ] === "left" ? + data.targetWidth : + data.at[ 0 ] === "right" ? + -data.targetWidth : + 0, + offset = -2 * data.offset[ 0 ], + newOverRight, + newOverLeft; + + if ( overLeft < 0 ) { + newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - + outerWidth - withinOffset; + if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { + position.left += myOffset + atOffset + offset; + } + } else if ( overRight > 0 ) { + newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + + atOffset + offset - offsetLeft; + if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { + position.left += myOffset + atOffset + offset; + } + } + }, + top: function( position, data ) { + var within = data.within, + withinOffset = within.offset.top + within.scrollTop, + outerHeight = within.height, + offsetTop = within.isWindow ? within.scrollTop : within.offset.top, + collisionPosTop = position.top - data.collisionPosition.marginTop, + overTop = collisionPosTop - offsetTop, + overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop, + top = data.my[ 1 ] === "top", + myOffset = top ? + -data.elemHeight : + data.my[ 1 ] === "bottom" ? + data.elemHeight : + 0, + atOffset = data.at[ 1 ] === "top" ? + data.targetHeight : + data.at[ 1 ] === "bottom" ? + -data.targetHeight : + 0, + offset = -2 * data.offset[ 1 ], + newOverTop, + newOverBottom; + if ( overTop < 0 ) { + newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - + outerHeight - withinOffset; + if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) { + position.top += myOffset + atOffset + offset; + } + } else if ( overBottom > 0 ) { + newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + + offset - offsetTop; + if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) { + position.top += myOffset + atOffset + offset; + } + } + } + }, + flipfit: { + left: function() { + $.ui.position.flip.left.apply( this, arguments ); + $.ui.position.fit.left.apply( this, arguments ); + }, + top: function() { + $.ui.position.flip.top.apply( this, arguments ); + $.ui.position.fit.top.apply( this, arguments ); + } + } +}; + +} )(); + +var position = $.ui.position; + + +/*! + * jQuery UI :data 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: :data Selector +//>>group: Core +//>>description: Selects elements which have data stored under the specified key. +//>>docs: http://api.jqueryui.com/data-selector/ + + +var data = $.extend( $.expr[ ":" ], { + data: $.expr.createPseudo ? + $.expr.createPseudo( function( dataName ) { + return function( elem ) { + return !!$.data( elem, dataName ); + }; + } ) : + + // Support: jQuery <1.8 + function( elem, i, match ) { + return !!$.data( elem, match[ 3 ] ); + } +} ); + +/*! + * jQuery UI Disable Selection 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: disableSelection +//>>group: Core +//>>description: Disable selection of text content within the set of matched elements. +//>>docs: http://api.jqueryui.com/disableSelection/ + +// This file is deprecated + + +var disableSelection = $.fn.extend( { + disableSelection: ( function() { + var eventType = "onselectstart" in document.createElement( "div" ) ? + "selectstart" : + "mousedown"; + + return function() { + return this.on( eventType + ".ui-disableSelection", function( event ) { + event.preventDefault(); + } ); + }; + } )(), + + enableSelection: function() { + return this.off( ".ui-disableSelection" ); + } +} ); + + +/*! + * jQuery UI Focusable 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: :focusable Selector +//>>group: Core +//>>description: Selects elements which can be focused. +//>>docs: http://api.jqueryui.com/focusable-selector/ + + + +// Selectors +$.ui.focusable = function( element, hasTabindex ) { + var map, mapName, img, focusableIfVisible, fieldset, + nodeName = element.nodeName.toLowerCase(); + + if ( "area" === nodeName ) { + map = element.parentNode; + mapName = map.name; + if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { + return false; + } + img = $( "img[usemap='#" + mapName + "']" ); + return img.length > 0 && img.is( ":visible" ); + } + + if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) { + focusableIfVisible = !element.disabled; + + if ( focusableIfVisible ) { + + // Form controls within a disabled fieldset are disabled. + // However, controls within the fieldset's legend do not get disabled. + // Since controls generally aren't placed inside legends, we skip + // this portion of the check. + fieldset = $( element ).closest( "fieldset" )[ 0 ]; + if ( fieldset ) { + focusableIfVisible = !fieldset.disabled; + } + } + } else if ( "a" === nodeName ) { + focusableIfVisible = element.href || hasTabindex; + } else { + focusableIfVisible = hasTabindex; + } + + return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) ); +}; + +// Support: IE 8 only +// IE 8 doesn't resolve inherit to visible/hidden for computed values +function visible( element ) { + var visibility = element.css( "visibility" ); + while ( visibility === "inherit" ) { + element = element.parent(); + visibility = element.css( "visibility" ); + } + return visibility !== "hidden"; +} + +$.extend( $.expr[ ":" ], { + focusable: function( element ) { + return $.ui.focusable( element, $.attr( element, "tabindex" ) != null ); + } +} ); + +var focusable = $.ui.focusable; + + + + +// Support: IE8 Only +// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop +// with a string, so we need to find the proper form. +var form = $.fn.form = function() { + return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form ); +}; + + +/*! + * jQuery UI Form Reset Mixin 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: Form Reset Mixin +//>>group: Core +//>>description: Refresh input widgets when their form is reset +//>>docs: http://api.jqueryui.com/form-reset-mixin/ + + + +var formResetMixin = $.ui.formResetMixin = { + _formResetHandler: function() { + var form = $( this ); + + // Wait for the form reset to actually happen before refreshing + setTimeout( function() { + var instances = form.data( "ui-form-reset-instances" ); + $.each( instances, function() { + this.refresh(); + } ); + } ); + }, + + _bindFormResetHandler: function() { + this.form = this.element.form(); + if ( !this.form.length ) { + return; + } + + var instances = this.form.data( "ui-form-reset-instances" ) || []; + if ( !instances.length ) { + + // We don't use _on() here because we use a single event handler per form + this.form.on( "reset.ui-form-reset", this._formResetHandler ); + } + instances.push( this ); + this.form.data( "ui-form-reset-instances", instances ); + }, + + _unbindFormResetHandler: function() { + if ( !this.form.length ) { + return; + } + + var instances = this.form.data( "ui-form-reset-instances" ); + instances.splice( $.inArray( this, instances ), 1 ); + if ( instances.length ) { + this.form.data( "ui-form-reset-instances", instances ); + } else { + this.form + .removeData( "ui-form-reset-instances" ) + .off( "reset.ui-form-reset" ); + } + } +}; + + +/*! + * jQuery UI Support for jQuery core 1.7.x 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + */ + +//>>label: jQuery 1.7 Support +//>>group: Core +//>>description: Support version 1.7.x of jQuery core + + + +// Support: jQuery 1.7 only +// Not a great way to check versions, but since we only support 1.7+ and only +// need to detect <1.8, this is a simple check that should suffice. Checking +// for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0 +// and we'll never reach 1.70.0 (if we do, we certainly won't be supporting +// 1.7 anymore). See #11197 for why we're not using feature detection. +if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) { + + // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight() + // Unlike jQuery Core 1.8+, these only support numeric values to set the + // dimensions in pixels + $.each( [ "Width", "Height" ], function( i, name ) { + var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], + type = name.toLowerCase(), + orig = { + innerWidth: $.fn.innerWidth, + innerHeight: $.fn.innerHeight, + outerWidth: $.fn.outerWidth, + outerHeight: $.fn.outerHeight + }; + + function reduce( elem, size, border, margin ) { + $.each( side, function() { + size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; + if ( border ) { + size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; + } + if ( margin ) { + size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; + } + } ); + return size; + } + + $.fn[ "inner" + name ] = function( size ) { + if ( size === undefined ) { + return orig[ "inner" + name ].call( this ); + } + + return this.each( function() { + $( this ).css( type, reduce( this, size ) + "px" ); + } ); + }; + + $.fn[ "outer" + name ] = function( size, margin ) { + if ( typeof size !== "number" ) { + return orig[ "outer" + name ].call( this, size ); + } + + return this.each( function() { + $( this ).css( type, reduce( this, size, true, margin ) + "px" ); + } ); + }; + } ); + + $.fn.addBack = function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter( selector ) + ); + }; +} + +; +/*! + * jQuery UI Keycode 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: Keycode +//>>group: Core +//>>description: Provide keycodes as keynames +//>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/ + + +var keycode = $.ui.keyCode = { + BACKSPACE: 8, + COMMA: 188, + DELETE: 46, + DOWN: 40, + END: 35, + ENTER: 13, + ESCAPE: 27, + HOME: 36, + LEFT: 37, + PAGE_DOWN: 34, + PAGE_UP: 33, + PERIOD: 190, + RIGHT: 39, + SPACE: 32, + TAB: 9, + UP: 38 +}; + + + + +// Internal use only +var escapeSelector = $.ui.escapeSelector = ( function() { + var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g; + return function( selector ) { + return selector.replace( selectorEscape, "\\$1" ); + }; +} )(); + + +/*! + * jQuery UI Labels 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: labels +//>>group: Core +//>>description: Find all the labels associated with a given input +//>>docs: http://api.jqueryui.com/labels/ + + + +var labels = $.fn.labels = function() { + var ancestor, selector, id, labels, ancestors; + + // Check control.labels first + if ( this[ 0 ].labels && this[ 0 ].labels.length ) { + return this.pushStack( this[ 0 ].labels ); + } + + // Support: IE <= 11, FF <= 37, Android <= 2.3 only + // Above browsers do not support control.labels. Everything below is to support them + // as well as document fragments. control.labels does not work on document fragments + labels = this.eq( 0 ).parents( "label" ); + + // Look for the label based on the id + id = this.attr( "id" ); + if ( id ) { + + // We don't search against the document in case the element + // is disconnected from the DOM + ancestor = this.eq( 0 ).parents().last(); + + // Get a full set of top level ancestors + ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() ); + + // Create a selector for the label based on the id + selector = "label[for='" + $.ui.escapeSelector( id ) + "']"; + + labels = labels.add( ancestors.find( selector ).addBack( selector ) ); + + } + + // Return whatever we have found for labels + return this.pushStack( labels ); +}; + + +/*! + * jQuery UI Scroll Parent 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: scrollParent +//>>group: Core +//>>description: Get the closest ancestor element that is scrollable. +//>>docs: http://api.jqueryui.com/scrollParent/ + + + +var scrollParent = $.fn.scrollParent = function( includeHidden ) { + var position = this.css( "position" ), + excludeStaticParent = position === "absolute", + overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/, + scrollParent = this.parents().filter( function() { + var parent = $( this ); + if ( excludeStaticParent && parent.css( "position" ) === "static" ) { + return false; + } + return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + + parent.css( "overflow-x" ) ); + } ).eq( 0 ); + + return position === "fixed" || !scrollParent.length ? + $( this[ 0 ].ownerDocument || document ) : + scrollParent; +}; + + +/*! + * jQuery UI Tabbable 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: :tabbable Selector +//>>group: Core +//>>description: Selects elements which can be tabbed to. +//>>docs: http://api.jqueryui.com/tabbable-selector/ + + + +var tabbable = $.extend( $.expr[ ":" ], { + tabbable: function( element ) { + var tabIndex = $.attr( element, "tabindex" ), + hasTabindex = tabIndex != null; + return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex ); + } +} ); + + +/*! + * jQuery UI Unique ID 1.12.1 + * http://jqueryui.com + * + * Copyright jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + */ + +//>>label: uniqueId +//>>group: Core +//>>description: Functions to generate and remove uniqueId's +//>>docs: http://api.jqueryui.com/uniqueId/ + + + +var uniqueId = $.fn.extend( { + uniqueId: ( function() { + var uuid = 0; + + return function() { + return this.each( function() { + if ( !this.id ) { + this.id = "ui-id-" + ( ++uuid ); + } + } ); + }; + } )(), + + removeUniqueId: function() { + return this.each( function() { + if ( /^ui-id-\d+$/.test( this.id ) ) { + $( this ).removeAttr( "id" ); + } + } ); + } +} ); + + // This file is deprecated @@ -961,4 +1937,16770 @@ var widgetsMouse = $.widget( "ui.mouse", { +// $.ui.plugin is deprecated. Use $.widget() extensions instead. +var plugin = $.ui.plugin = { + add: function( module, option, set ) { + var i, + proto = $.ui[ module ].prototype; + for ( i in set ) { + proto.plugins[ i ] = proto.plugins[ i ] || []; + proto.plugins[ i ].push( [ option, set[ i ] ] ); + } + }, + call: function( instance, name, args, allowDisconnected ) { + var i, + set = instance.plugins[ name ]; + + if ( !set ) { + return; + } + + if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || + instance.element[ 0 ].parentNode.nodeType === 11 ) ) { + return; + } + + for ( i = 0; i < set.length; i++ ) { + if ( instance.options[ set[ i ][ 0 ] ] ) { + set[ i ][ 1 ].apply( instance.element, args ); + } + } + } +}; + + + +var safeActiveElement = $.ui.safeActiveElement = function( document ) { + var activeElement; + + // Support: IE 9 only + // IE9 throws an "Unspecified error" accessing document.activeElement from an