geomagpy / magpy

MagPy (or GeomagPy) is a Python package for analysing and displaying geomagnetic data.
BSD 3-Clause "New" or "Revised" License
49 stars 27 forks source link

GUI: when failing to load DI data the program freezes #32

Closed leonro closed 8 years ago

mojca commented 8 years ago

I'm already unable to open the sheet (I didn't yet come as far as entering the data).

This is the error being thrown.

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/magpy/gui/magpy_gui.py", line 3474, in onInputSheet
    self.dilayout['scalevalue'] = self.options['scalevalue']
KeyError: 'scalevalue'

According to the code elsewhere in that file, something like the following seemed to help:

-        self.dilayout['scalevalue'] = self.options['scalevalue']
-        self.dilayout['double'] = self.options['double']
-        self.dilayout['order'] = self.options['order'].split(',')
+        self.dilayout['scalevalue'] = self.options.get('scalevalue', True)
+        self.dilayout['double'] = self.options.get('scalevalue', True)
+        self.dilayout['order'] = self.options.get('order', "MU,MD,EU,WU,ED,WD,NU,SD,ND,SU").split(',')

but that is pure guesswork. The input datasheet at least opens though.

mojca commented 8 years ago

Then again ... I experienced the following error:

Traceback (most recent call last):
  File "/Users/Data/Mojca/LGA/software/geomagpy/magpy-git/magpy/gui/magpy_gui.py", line 1934, in OnOptionsDI
    dlg = OptionsDIDialog(None, title='Options: DI Analysis parameters', options=self.options)
  File "/Users/Data/Mojca/LGA/software/geomagpy/magpy-git/magpy/gui/dialogclasses.py", line 699, in __init__
    self.createControls()
  File "/Users/Data/Mojca/LGA/software/geomagpy/magpy-git/magpy/gui/dialogclasses.py", line 724, in createControls
    self.diexpDTextCtrl = wx.TextCtrl(self, value=self.options.get('diexpD',''),size=(160,30))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/_controls.py", line 2019, in __init__
    _controls_.TextCtrl_swiginit(self,_controls_.new_TextCtrl(*args, **kwargs))
TypeError: String or Unicode type required

so I'm not quite sure if the above fix is ok or not.

leonro commented 8 years ago

The basic problem is that magpyini has changed and the new parameters are either not accessible or not in the appropriate format. This might happen always if new options are added in any future version. Solution: add a version info to magpyini and replace magpyini with a new default one in case that the magpy version has changed.

leonro commented 8 years ago

Finished with 6a3d4ab11080af05f7b77b923108c07d41945300. Closing #32