tridge/MAVProxy — pull request #80 by geeksville (2014-08-11 23:26:22+00:00)
Title: Make wxPython optional for basic mavproxy operations.

Hi Tridge,

I also needed to cope with non wxPython platforms and when I pulled from master to rebase before sending in a PR I noticed you recently fixed a similar problem. This PR actually changes your approach of detecting non wxPython platforms from a "CYGWIN" check to a more cross platform check of 'can I import the wx package'. My platform (which I'll describe more fully in skype ;-)) doesn't yet have enough goo so that wxpython will compile, but it _is_ linux.

---

A previous change was checking for "CYGWIN" in platform.system() which
is a fine fix but insufficient for my platform. My platform is not cygwin
(it is a very stripped down linux) but still can't run wxPython. So
as a cleaner way for checking for this problem I added has_wxpython to
mp_util. This bool will be True on platforms where wxPython could be
found.

I also fixed an error in idle callbacks for these platforms:

Without this change on platforms without wxPython the following
failures would occur, because self.menu_added... would not be initialized
in the constructor. My fix flips the order of comparisons so we
check for the console or map module _first_ and short-circuit out before
noticing that self.menu_added... is empty.

AttributeError: 'RallyModule' object has no attribute 'menu_added_console'
Traceback (most recent call last):
File "/home/kevinh/development/drone/MAVProxy/MAVProxy/mavproxy.py", line 862, in periodic_tasks
m.idle_task()
File "/home/kevinh/development/drone/MAVProxy/MAVProxy/modules/mavproxy_fence.py", line 52, in idle_task
if not self.menu_added_console and self.module('console') is not None:
AttributeError: 'FenceModule' object has no attribute 'menu_added_console'
Traceback (most recent call last):
File "/home/kevinh/development/drone/MAVProxy/MAVProxy/mavproxy.py", line 862, in periodic_tasks
m.idle_task()
File "/home/kevinh/development/drone/MAVProxy/MAVProxy/modules/mavproxy_rally.py", line 47, in idle_task
if not self.menu_added_console and self.module('console') is not None:
AttributeError: 'RallyModule' object has no attribute 'menu_added_console'
Traceback (most recent call last):
File "/home/kevinh/development/drone/MAVProxy/MAVProxy/mavproxy.py", line 862, in periodic_tasks
m.idle_task()
File "/home/kevinh/development/drone/MAVProxy/MAVProxy/modules/mavproxy_fence.py", line 52, in idle_task
if not self.menu_added_console and self.module('console') is not None:
AttributeError: 'FenceModule' object has no attribute 'menu_added_console'