Skip to content

lastquake command fails if there's no numerical value to the earthquake location in USGS feed #19

@dziban303

Description

@dziban303

label_km_to_miles = lambda s: re.sub(r'[0-9.]+\s?km', '%s (%smi)' % (re.compile(r'([0-9.]+)\s?km').match(s).group(0), km_to_miles(re.compile(r'([0-9.]+)\s?km').match(s).group(1))), s)

'lastquake' command throws exception if the latest significant earthquake in the USGS feed doesn't include a distance in the 'place' field.

Latest quake shows: {"mag":6.3,"place":"Southern East Pacific Rise","time":1542323341050

Note lack of "303km from Dzibania"-style distance measurement.

Regex should be amended to handle a lack of km to convert.

Exception is
2018-11-16 23:52:30,005 ERROR 'NoneType' object has no attribute 'group' Traceback (most recent call last): File "/mnt/c/linux/dziwx/pywx/modules/base.py", line 88, in run context = self.context(msg) File "/mnt/c/linux/dziwx/pywx/modules/earthquake.py", line 90, in context return self.quake_context(earthquakes[0]) File "/mnt/c/linux/dziwx/pywx/modules/earthquake.py", line 52, in quake_context 'region': label_km_to_miles(eqp['place']), File "/mnt/c/linux/dziwx/pywx/modules/earthquake.py", line 20, in <lambda> label_km_to_miles = lambda s: re.sub(r'[0-9.]+\s?km', '%s (%smi)' % (re.compile(r'([0-9.]+)\s?km').match(s).group(0), km_to_miles(re.compile(r'([0-9.]+)\s?km').match(s).group(1))), s) AttributeError: 'NoneType' object has no attribute 'group'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions