exceptions in configuration_manager.py

13 views
Skip to first unread message

Tom Enos

unread,
Jun 26, 2015, 3:33:15 AM6/26/15
to lightsh...@googlegroups.com
I'm working in master configuration_manager.py and in particular the sms function.

I want do get rid of a few warning I get from my ide about the exceptions being to broad, (I think it's right by the way) as it might hide other faults and error that should be caught else where.  

I have 4 warnings
the first is at
        # Commands
        _SMS_CONFIG
['commands'] = _as_list(_SMS_CONFIG['commands'])
       
for cmd in _SMS_CONFIG['commands']:
           
try:
                _SMS_CONFIG
[cmd + '_aliases'] = _as_list(_SMS_CONFIG[cmd + '_aliases'])
           
except:
                _SMS_CONFIG
[cmd + '_aliases'] = []

except: what?
All I can think of is _as_list has an error which should be caught and handled in _as_list or SMS_CONFIG[cmd + '_aliases'] is a KeyError.  Can anybody think of any other error that applies (testing for every situation is not an easy thing)? I know that Todd and Christ have the most experience with this, so maybe you guys remember why you used a try/except blocks.  Second and third are the same thing for the most part.

The fourth is related to thorttle_group_definitions (or thorttlegroupdefinitions I am re factoring and don't remember the starting names).  I have not look into this one yet, but if anyone has any insight to save me alot of time, I would be most appreciative to not have to work thought this step by step and then wonder if I was right.   



Todd Giles

unread,
Jun 26, 2015, 3:18:31 PM6/26/15
to lightsh...@googlegroups.com
My recollection here was I'd run into errors parsing the user entered configuration file and so lazily caught all exceptions when I should have been catching specific ones.

Main goal anyhow is / was to make the parsing of the configuration file as forgiving as possible, and ideally output useful error messages to the user if their configuration file has issues (ideally with line # and explanation of issue).

-Todd

--
http://www.lightshowpi.org/
---
You received this message because you are subscribed to the Google Groups "LightShow Pi Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lightshowpi-d...@googlegroups.com.
To post to this group, send email to lightsh...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lightshowpi-dev/211df34b-1d26-4b2e-bdec-505a4545eb41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Todd Giles

unread,
Jun 26, 2015, 3:19:40 PM6/26/15
to lightsh...@googlegroups.com
Perhaps the easiest way to determine the exceptions we should be catching is to make some gross errors in the configuration file and attempt to parse it w/out the exception handling in place and see what exceptions are thrown. (that's how I'd likely go about it anyhow)

Tom Enos

unread,
Jun 26, 2015, 5:49:05 PM6/26/15
to lightsh...@googlegroups.com
That was my thinking too, trial and error.  I'll have to come back to this one after I get the docstrings squared away

Tom Enos

unread,
Jun 26, 2015, 5:59:44 PM6/26/15
to lightsh...@googlegroups.com
So the errors were coming from configParser?  Or you mean the way the function parses it.
configParser should just be returning strings to process, so I think it's the way _as_list is splitting it up.
But anyway I will dig deeper into it to see what real errors are.

Todd Giles

unread,
Jun 26, 2015, 6:09:55 PM6/26/15
to lightsh...@googlegroups.com
Not from config parser, as you say - it just gives strings, but from the way we are attempting to interpret said strings in the various cases.

Tom Slick

unread,
Jun 26, 2015, 6:46:04 PM6/26/15
to lightsh...@googlegroups.com
That is what I thought. Thanks for the clarification.

--
http://www.lightshowpi.org/
---
You received this message because you are subscribed to a topic in the Google Groups "LightShow Pi Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lightshowpi-dev/zG2oDn5QtJU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lightshowpi-d...@googlegroups.com.

To post to this group, send email to lightsh...@googlegroups.com.

Tom Enos

unread,
Jun 26, 2015, 10:32:06 PM6/26/15
to lightsh...@googlegroups.com
All four turn out to be KeyError:  Getting them user proof shouldn't be a big problem.  
Reply all
Reply to author
Forward
0 new messages