forked from PrintMakerLab/mks-wifi-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
61 lines (52 loc) · 2.24 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright (c) 2021
# MKS Plugin is released under the terms of the AGPLv3 or higher.
import os, json
from . import MKSOutputDevicePlugin
from . import MachineConfig
from UM.i18n import i18nCatalog
from UM.Version import Version
from UM.Application import Application
from UM.Logger import Logger
catalog = i18nCatalog("cura")
def getMetaData():
return {}
# \param app The application that the plug-in needs to register with.
def register(app):
if match_version():
return {
"output_device": MKSOutputDevicePlugin.MKSOutputDevicePlugin(),
"machine_action": MachineConfig.MachineConfig()
}
else:
Logger.log("w", "Plugin not loaded because of a version mismatch")
return {}
def match_version():
cura_version = Application.getInstance().getVersion()
if cura_version == "master":
Logger.log("d", "Running Cura from source. Skipping version check")
return True
if cura_version == "Arachne_engine_alpha":
Logger.log("d", "Running Cura Arachne_engine_alpha. Skipping version check")
return True
if cura_version == "Arachne_engine_beta":
Logger.log("d", "Running Cura Arachne_engine_beta. Skipping version check")
return True
if cura_version == "Arachne_engine_beta_2":
Logger.log("d", "Running Cura Arachne_engine_beta_2. Skipping version check")
return True
cura_version = Version(cura_version)
cura_version = Version([cura_version.getMajor(), cura_version.getMinor()])
# Get version information from plugin.json
plugin_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "plugin.json")
try:
with open(plugin_file_path, encoding="utf-8") as plugin_file:
plugin_info = json.load(plugin_file)
minimum_cura_version = Version(plugin_info["minimum_cura_version"])
except Exception as e:
Logger.log("w", "Could not get version information for the plugin: "+str(e))
return False
if cura_version >= minimum_cura_version:
return True
else:
Logger.log("d", "This version of MKS WiFi Plugin is not compatible with current version of Cura (%s). Please check for an update." % (Application.getInstance().getVersion()))
return False