4848
4949try :
5050 import indigo # noqa
51- import pydevd
51+ import pydevd # noqa
5252except ImportError :
5353 ...
5454
6565__license__ = Dave .__license__
6666__build__ = Dave .__build__
6767__title__ = "Matplotlib Plugin for Indigo"
68- __version__ = "2022.1.6 "
68+ __version__ = "2022.1.7 "
6969
7070
7171# =============================================================================
@@ -114,16 +114,16 @@ def __init__(self, plugin_id="", plugin_display_name="", plugin_version="", plug
114114 self .plugin_file_handler .setLevel (10 )
115115
116116 # ============================= Remote Debug Hook =============================
117- # try:
118- # pydevd.settrace(
119- # 'localhost',
120- # port=5678,
121- # stdoutToServer=True,
122- # stderrToServer=True,
123- # suspend=False
124- # )
125- # except Exception:
126- # ...
117+ try :
118+ pydevd .settrace (
119+ 'localhost' ,
120+ port = 5678 ,
121+ stdoutToServer = True ,
122+ stderrToServer = True ,
123+ suspend = False
124+ )
125+ except Exception :
126+ ...
127127
128128 self .pluginIsInitializing = False
129129
@@ -614,10 +614,10 @@ def runConcurrentThread(self): # noqa
614614
615615 while True :
616616 if not self .pluginIsShuttingDown :
617- self .refresh_the_charts_queue ()
618- self .csv_refresh ()
619- self .charts_refresh ()
620- self .sleep (1 )
617+ self .refresh_the_charts_queue () # check to see if anything is in the queue.
618+ self .csv_refresh () # iterate plugin devices to see if any need updating.
619+ self .charts_refresh () # refresh plugin devices that need updating.
620+ self .sleep (10 )
621621
622622 # =============================================================================
623623 @staticmethod
@@ -722,7 +722,7 @@ def validatePrefsConfigUi(self, values_dict=None): # noqa
722722 try :
723723 if values_dict [key ] != self .pluginPrefs [key ]:
724724 config_changed = True
725- changed_keys += f"{ key } " , f"Old: { self .pluginPrefs [key ]} " , f"New: { values_dict [key ]} " ,
725+ changed_keys += ( f"{ key } " , f"Old: { self .pluginPrefs [key ]} " , f"New: { values_dict [key ]} " ) ,
726726
727727 # Missing keys will be config dialog format props like labels and separators
728728 except KeyError :
@@ -2238,7 +2238,7 @@ def convert_to_native(obj):
22382238 path_to_file = 'chart_multiline.py'
22392239
22402240 except OSError as err :
2241- if "Argument list too long" in err :
2241+ if "Argument list too long" in str ( err ) :
22422242 self .logger .critical ("Text source too long." )
22432243
22442244 # ============================== Polar Charts ==============================
@@ -2924,7 +2924,7 @@ def csv_refresh_device_action(
29242924 :param bool caller_waiting_for_result:
29252925 :return:
29262926 """
2927- dev = indigo .devices [int (plugin_action .PROPS ['targetDevice' ])]
2927+ dev = indigo .devices [int (plugin_action .props ['targetDevice' ])]
29282928
29292929 if dev .enabled :
29302930
@@ -2956,11 +2956,11 @@ def csv_refresh_source_action(
29562956 :param bool caller_waiting_for_result:
29572957 :return:
29582958 """
2959- dev_id = int (plugin_action .PROPS ['targetDevice' ])
2959+ dev_id = int (plugin_action .props ['targetDevice' ])
29602960 dev = indigo .devices [dev_id ]
29612961
29622962 if dev .enabled :
2963- target_source = plugin_action .PROPS ['targetSource' ]
2963+ target_source = plugin_action .props ['targetSource' ]
29642964 temp_dict = ast .literal_eval (dev .pluginProps ['columnDict' ])
29652965 payload = {target_source : temp_dict [target_source ]}
29662966
@@ -3095,17 +3095,21 @@ def get_csv_source_list(fltr="", values_dict=None, type_id="", target_id=0): #
30953095 :param int target_id:
30963096 :return:
30973097 """
3098- if not values_dict :
3099- result = []
3098+ try :
3099+ if not values_dict :
3100+ result = []
31003101
3101- # Once user selects a device ( see get_csv_device_list() ), populate the dropdown menu.
3102- else :
3103- target_device = int (values_dict [ 'targetDevice' ] )
3104- dev = indigo .devices [target_device ]
3105- dev_dict = ast .literal_eval (dev .pluginProps ['columnDict' ])
3106- result = [(k , dev_dict [k ][0 ]) for k in dev_dict ]
3102+ # Once user selects a device ( see get_csv_device_list() ), populate the dropdown menu.
3103+ else :
3104+ target_device = int (values_dict . get ( 'targetDevice' , 0 ) )
3105+ dev = indigo .devices [target_device ]
3106+ dev_dict = ast .literal_eval (dev .pluginProps ['columnDict' ])
3107+ result = [(k , dev_dict [k ][0 ]) for k in dev_dict ]
31073108
3108- return result
3109+ return result
3110+
3111+ except KeyError :
3112+ return []
31093113
31103114 # =============================================================================
31113115 @staticmethod
@@ -3282,7 +3286,8 @@ def generatorDeviceList(self, fltr="", values_dict=None, type_id="", target_id=0
32823286 return self .Fogbert .deviceList ()
32833287
32843288 # =============================================================================
3285- def generatorPrecisionList (self , fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
3289+ @staticmethod
3290+ def generatorPrecisionList (fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
32863291 """
32873292 Returns a list of value precision options for pulldown menus.
32883293
@@ -3300,7 +3305,8 @@ def generatorPrecisionList(self, fltr="", values_dict=None, type_id="", target_i
33003305 return precision
33013306
33023307 # =============================================================================
3303- def generatorLineStyleDefaultNoneList (self , fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
3308+ @staticmethod
3309+ def generatorLineStyleDefaultNoneList (fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
33043310 """
33053311 Returns a list of Matplotlib line styles for pulldown menus.
33063312
@@ -3320,8 +3326,8 @@ def generatorLineStyleDefaultNoneList(self, fltr="", values_dict=None, type_id="
33203326 return line_styles
33213327
33223328 # =============================================================================
3323- def generatorLineStyleDefaultSolidList (
3324- self , fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
3329+ @ staticmethod
3330+ def generatorLineStyleDefaultSolidList ( fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
33253331 """
33263332 Returns a list of Matplotlib line styles for pulldown menus.
33273333
@@ -3341,7 +3347,8 @@ def generatorLineStyleDefaultSolidList(
33413347 return line_styles
33423348
33433349 # =============================================================================
3344- def generatorMarkerList (self , fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
3350+ @staticmethod
3351+ def generatorMarkerList (fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
33453352 """
33463353 Returns a list of Matplotlib Markers for pulldown menus.
33473354
@@ -3554,7 +3561,8 @@ def getFontList(self, fltr="", values_dict=None, type_id="", target_id=0): # no
35543561 return sorted (font_menu )
35553562
35563563 # =============================================================================
3557- def getRefreshList (self , fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
3564+ @staticmethod
3565+ def getRefreshList (fltr = "" , values_dict = None , type_id = "" , target_id = 0 ): # noqa
35583566 """
35593567
35603568 :param str fltr:
@@ -3638,7 +3646,7 @@ def plotActionApi(self, plugin_action=None, dev=None, caller_waiting_for_result=
36383646 :param indigo.Device dev:
36393647 :param bool caller_waiting_for_result:
36403648 """
3641- self .logger .info (f"Scripting payload: { dict (plugin_action .PROPS )} " )
3649+ self .logger .info (f"Scripting payload: { dict (plugin_action .props )} " )
36423650
36433651 # TODO: take a look at broadcast messages and whether this is something else that can be made to work in this
36443652 # neighborhood.
@@ -3684,11 +3692,11 @@ def plotActionApi(self, plugin_action=None, dev=None, caller_waiting_for_result=
36843692 bk_color = self .pluginPrefs .get ('backgroundColor' , '#000000' )
36853693
36863694 # ============================= Unpack Payload ==============================
3687- x_values = plugin_action .PROPS ['x_values' ]
3688- y_values = plugin_action .PROPS ['y_values' ]
3689- kwargs = plugin_action .PROPS ['kwargs' ]
3690- path_name = plugin_action .PROPS ['path' ]
3691- file_name = plugin_action .PROPS ['filename' ]
3695+ x_values = plugin_action .props ['x_values' ]
3696+ y_values = plugin_action .props ['y_values' ]
3697+ kwargs = plugin_action .props ['kwargs' ]
3698+ path_name = plugin_action .props ['path' ]
3699+ file_name = plugin_action .props ['filename' ]
36923700
36933701 try :
36943702 fig = plt .figure (1 , figsize = (width / dpi , height / dpi ))
@@ -3988,7 +3996,7 @@ def themeApplyAction(self, plugin_action=None): # noqa
39883996 :param indigo.PluginAction plugin_action:
39893997 """
39903998 full_path = f"{ indigo .server .getInstallFolderPath ()} /Preferences/Plugins/matplotlib plugin themes.json"
3991- selected_theme = plugin_action .PROPS ['targetTheme' ]
3999+ selected_theme = plugin_action .props ['targetTheme' ]
39924000
39934001 # ============================== Get the Theme ==============================
39944002 with open (full_path , 'r' , encoding = 'utf-8' ) as f :
0 commit comments