Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodeinfo: add more nodeinfo #63

Merged
merged 1 commit into from
Mar 21, 2021

Conversation

herbetom
Copy link
Contributor

@herbetom herbetom commented Dec 1, 2020

The following things can now be controlled domain specific:

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

resolves #65

config.py Outdated Show resolved Hide resolved
config.py Outdated Show resolved Hide resolved
herbetom added a commit to Freifunk-Rhein-Neckar/salt that referenced this pull request Dec 1, 2020
@AiyionPrime
Copy link
Contributor

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

@herbetom
Copy link
Contributor Author

herbetom commented Feb 14, 2021

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

Otherwise this should be okay.

@AiyionPrime
Copy link
Contributor

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

@AiyionPrime
Copy link
Contributor

None?

@herbetom
Copy link
Contributor Author

herbetom commented Feb 14, 2021

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
Copy link
Contributor

AiyionPrime commented Feb 14, 2021

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
Copy link
Contributor Author

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
Copy link
Contributor

AiyionPrime commented Feb 15, 2021

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
Copy link
Contributor

AiyionPrime commented Feb 16, 2021

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

@herbetom
Copy link
Contributor Author

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. 👍

The following things can now be controlled domain specific:

Hostname, Hardware-Model, Contact Information, VPN, Latitude and Longitude
Copy link
Contributor

@AiyionPrime AiyionPrime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested yesterday before last forcepush.
Iirc there were only minor changes in the config comments.
The getbool method seems to be the cleanest solution.
Looks good to me.

@TobleMiner TobleMiner merged commit acf75bd into ffnord:master Mar 21, 2021
@herbetom herbetom deleted the add_nodeinfos branch March 21, 2021 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: option to override the hostname
3 participants