ffnord / mesh-announce

Discussion at #mesh-announce:irc.hackint.org and (separately) at
https://matrix.to/#/!MjLIHcALOcENXZWQlH:irc.hackint.org/$1547640760901FmKaD:matrix.eclabs.de
13 stars 45 forks source link

nodeinfo: add more nodeinfo #63

Closed herbetom closed 3 years ago

herbetom commented 3 years ago

The following things can now be controlled domain specific:

Hostname, Hardware-Model, Contact Information, VPN, Latitude and Longitude

resolves #65

AiyionPrime commented 3 years ago

Ah, I get it -.-' TypeError: float() argument must be a string or a number, not 'NoneType'

herbetom commented 3 years ago

yeah, i would appreciate a saver and non error throwing suggestion for the conversion

Otherwise this should be okay.

AiyionPrime commented 3 years ago

What default values would you like self.longitude and self.latitude to have?

AiyionPrime commented 3 years ago

None?

herbetom commented 3 years ago

The Node should have no location if nothing is configured (like it is currently with mesh-announce or gluon Nodes). I don't know about the best approach to get to this result.

AiyionPrime commented 3 years ago

I'd go with either

try:
    self.longitude = float(parser.get(name, 'Longitude', fallback=None))
except TypeError:
    self.longitude = None
try:
    self.latitude = float(parser.get(name, 'Latitude', fallback=None))
except TypeError:
    self.latitude = None

Which follows your default in your example config; https://github.com/Freifunk-Rhein-Neckar/mesh-announce/blob/d0739c1b1f614e98f8c03512cd7d96c031017898/respondd.conf.example#L33 https://github.com/Freifunk-Rhein-Neckar/mesh-announce/blob/d0739c1b1f614e98f8c03512cd7d96c031017898/respondd.conf.example#L36

Or this:

try:
    self.longitude = float(parser.get(name, 'Longitude', fallback=None))
except TypeError:
    pass
try:
    self.latitude = float(parser.get(name, 'Latitude', fallback=None))
except TypeError:
    pass

Which I understood is the behavior described in your last comment? Gotta go for today, thanks so far!

herbetom commented 3 years ago

I choose the first approach. The other didn't work (or had much noise about the missing Var).

@TobleMiner What do you think? Could this be merged?

AiyionPrime commented 3 years ago

Tested without the last force push; broken, if no coordinates were provided. Tested with latest FP, works very well without them.

sn07 now runs with both #64 and #63 merged into master.

~eg. https://hannover.freifunk.net/karte/#/en/map/88e640ba7014~

~Without the hostname config parameter working it would identify as h2879555.stratoserver.net.~

edit: Testing is done, reverted back to master.

AiyionPrime commented 3 years ago

One possible enhancemnt I just came across is configparsers getfloatmethod: https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.getfloat

herbetom commented 3 years ago

I did another Force Push to implement it with the getfloat method mentioned by @AiyionPrime

I like that approach much more then catching exceptions and it seems to do exactly what is needed. :+1: