10 ms·
Indeed, which is why in ShutIt I used some tricks with the prompt to determine whether a command was finished, and then (optional, but defaulting) checks on exi
by zwischenzug 10y ago
Indeed, which is why in ShutIt I used some tricks with the prompt to determine whether a command was finished, and then (optional, but defaulting) checks on exit codes to determine success/failure. It seems to work pretty well, and no need to specify what it expected.
It results in code like this:
https://github.com/ianmiell/shutit-chef-env/blob/master/shutit_chef_env.py#L83-L88 https://github.com/ianmiell/shutit-chef-env/blob/master/shut...
which sets up a chef server.
- wyldfire 10y agoAside: the bare except clause used here [1] is a bad habit. You should try to avoid it. Python raises things like NameError and TypeError for simple design problems like mistyping variable names. It's extremely rare that you can handle errors like that. Your "except:" would attempt to handle and effectively mask bugs like this. [1] https://github.com/ianmiell/shutit-chef-env/blob/master/shutit_chef_env.py#L56 https://github.com/ianmiell/shutit-chef-env/blob/master/shut...
- zwischenzug 10y agoThanks for the tip. Laziness is a sin and a virtue.