44__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
55__copyright__ = "Copyright (C) 2019 The OctoPrint Project - Released under terms of the AGPLv3 License"
66
7+ import datetime
8+ import re
9+
710from flask_babel import gettext
811
912from . import Check , Severity
@@ -15,8 +18,9 @@ def as_dict(cls):
1518 return dict (
1619 checks = (MarlinBugfixCheck (),),
1720 message = gettext (
18- "Your printer's firmware is a development build. It might be more unstable "
19- "than a release version and should be updated regularly."
21+ "Your printer's firmware is a {buildtype} build of {firmware} "
22+ "(build date {builddate}). It might be more unstable "
23+ "than a release version and should be kept up-to-date."
2024 ),
2125 severity = Severity .INFO ,
2226 )
@@ -26,11 +30,36 @@ class MarlinBugfixCheck(Check):
2630 """
2731 Marlin bugfix builds.
2832
29- Identified by firmware name that contains "Marlin bugfix-"
33+ Identified by firmware name that contains "Marlin bugfix-<version> (<builddate>) "
3034 """
3135
3236 name = "marlin_bugfix"
3337
38+ pattern = re .compile (
39+ r"marlin (?P<version>bugfix-[^-]*)\s\((?P<builddate>.*)\)" ,
40+ )
41+
42+ def __init__ (self ):
43+ super ().__init__ ()
44+ self .placeholders = {
45+ "firmware" : "Marlin" ,
46+ "version" : "unknown" ,
47+ "builddate" : "unknown" ,
48+ "buildtype" : "development" ,
49+ }
50+
3451 def m115 (self , name , data ):
35- self ._triggered = name and "marlin bugfix-" in name .lower ()
52+ match = self .pattern .match (name .lower ())
53+ if match :
54+ self .placeholders ["version" ] = match .group ("version" )
55+ self .placeholders ["builddate" ] = match .group ("builddate" )
56+
57+ try :
58+ self .placeholders ["builddate" ] = datetime .datetime .strptime (
59+ match .group ("builddate" ), "%b %d %Y %H:%M:%S"
60+ ).strftime ("%Y%m%d" )
61+ except Exception :
62+ pass
63+
64+ self ._triggered = name and match
3665 self ._active = False
0 commit comments