-
Notifications
You must be signed in to change notification settings - Fork 1
PluginPython23
OllisGit edited this page Apr 8, 2020
·
5 revisions
If you want to move your plugin from Python2 to Pyhton 3, be aware of the following stuff:
__plugin_name__ = "Your Plugin"
__plugin_pythoncompat__ = ">=2.7,<4"
compatibility:
python: ">=2.7,<4"
- Method
.has_key
of dictionary is not available any more: https://docs.python.org/3.1/whatsnew/3.0.html#builtins - Import Py2
import utility
Py3from octoprint_DryRun import utility
import sys
is_py2 = sys.version[0] == '2'
if is_py2:
import Queue as queue
else:
import queue as queue
if (isinstance(cmd, str) == True):
command_string = cmd
else:
# needed to handle non utf-8 characters
command_string = cmd.encode('ascii', 'ignore')
#if any(filter(parameters.has_key, additional_parameters.keys())):
self._myParameters = parameters
if any(filter( self.hasKeyReplacement , additional_parameters.keys())):
...
def hasKeyReplacement(self, key1):
result = key1 in self._myParameters
return result