-
Notifications
You must be signed in to change notification settings - Fork 40
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
[BUGFIX] contrib: yanic-import-timestamp for latest hopglass timestamp format #67
Conversation
Auch wenn keiner mehr version |
ffmap-backend nutzt datetime.datetime.now().isoformat()
Das dürfte doch Version 1 sein, oder? |
contrib/yanic-import-timestamp
Outdated
@@ -35,7 +35,7 @@ if oldnodedb['version'] == 2: | |||
for nodeid, node in newnodedb['nodes'].items(): | |||
for oldnode in oldnodedb['nodes']: | |||
if oldnode['nodeinfo']['node_id'] == nodeid: | |||
node['firstseen'] = "{}+0100".format(oldnode['firstseen']) | |||
node['firstseen'] = "{}+0100".format(oldnode['firstseen'][:-5]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? Always remove the last 5 bytes? I think a regexp replacement is better in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's not a sufficient solution for a lazy migration script I'd rather use datetime.strptime
.
107926d
to
866f89e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better but still not perfect.
(Sry)
contrib/yanic-import-timestamp
Outdated
dt = datetime.strptime(oldnode['firstseen'], v2_date_format) | ||
dts = dt.strftime(yanic_date_format) | ||
if node['firstseen'] != dts: | ||
node['firstseen'] = dt.strftime(yanic_date_format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warum nicht dts
wie in version 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unvollständig refactored …
contrib/yanic-import-timestamp
Outdated
for nodeid, node in newnodedb['nodes'].items(): | ||
for oldnode in oldnodedb['nodes']: | ||
if oldnode['nodeinfo']['node_id'] == nodeid: | ||
node['firstseen'] = "{}+0100".format(oldnode['firstseen']) | ||
count+=1 | ||
dt = datetime.strptime(oldnode['firstseen'], v2_date_format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would not be so easy 😢
The ffmap-backend could also generate v2.
See here: https://github.com/ffnord/ffmap-backend/blob/respondd/lib/nodes.py#L53-L55
We need a try, if it is a timestamp with timezone.
Maybe something like if 'Z' in old
and if '+' in old
else with v1 form
and a try at the end with dt is over 0
and error handling (maybe a function for both v1 and v2)
Also some additional refactoring and more verbosity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bin mir nocht ganz sicher, ob bei v1_datezone_format
nicht lieber doch die Zeitzone +1 nicht +0 genommen werden sollte. Doch ein Stunde Abweichung inzweifelsfall fällt nun wirklich nicht ins Gewicht.
Vielen Dank für die Überarbeitung.
https://docs.python.org/3/library/datetime.html#datetime.datetime.now
|
No description provided.