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

Avoid crash when timestamp decoding fails #4

Merged
merged 1 commit into from
Oct 18, 2020
Merged

Avoid crash when timestamp decoding fails #4

merged 1 commit into from
Oct 18, 2020

Conversation

jfessard
Copy link
Contributor

Timestamp sometimes comes back as None, and the parsing would fail,
crashing the script.
I've run this diff for a continuous week, without any script crashes and
no data going missing for more than a minute (I have my Grafana alerts
set up).

This addresses #3

Timestamp sometimes comes back as `None`, and the parsing would fail,
crashing the script.
I've run this diff for a continuous week, without any script crashes and
no data going missing for more than a minute (I have my Grafana alerts
set up).
@abaker abaker merged commit 479c093 into abaker:master Oct 18, 2020
@abaker
Copy link
Owner

abaker commented Oct 18, 2020

Sorry I hadn't gotten a chance to look into your issue before. Thanks for the PR!

@jfessard
Copy link
Contributor Author

No worries, I figured since I had it fixed locally, might as well submit a PR!
Does the docker container get updated automatically, or it has to be rebuilt? Thanks!

@abaker
Copy link
Owner

abaker commented Oct 19, 2020

Yup, auto build here

@jfessard
Copy link
Contributor Author

jfessard commented Oct 19, 2020

Hmm, I have pulled image: bakerba/emu2influx:latest but I am still seeing the same crash (running on a intel NUC, so it should pick up amd64)

Traceback (most recent call last):
  File "emu2influx.py", line 127, in <module>
</Command>
    main(client=emu(args.serial_port), db=influx)
  File "emu2influx.py", line 65, in main
    timestamp = get_timestamp(instantaneous_demand)
  File "emu2influx.py", line 16, in get_timestamp
    return datetime.utcfromtimestamp(Y2K + int(obj.TimeStamp, 16)).isoformat()
TypeError: int() can't convert non-string with explicit base

that should be gone with my PR

@abaker
Copy link
Owner

abaker commented Oct 27, 2020

I'm not sure if this was because I had caching enabled on the auto-build, or if something got messed up with the multi-arch latest setup, but if you do bakerba/emu2influx:amd64-latest or armhf-latest it should get you the right version

@jfessard
Copy link
Contributor Author

jfessard commented Nov 3, 2020

*EDIT - fixed

I was using bakerba/emu2influx:latest and it was bad. with bakerba/emu2influx:amd64-latest it's all good.

Original response:

Very strange, I am pulling latest, but I still hit the crash (withing seconds of running the docker). When I run my own python script in a tmux shell, it's good indefinitely. I checked the python file inside the docker, and it doesn't have the change.

docker-compose.yml:

  emu2influx:
    image: bakerba/emu2influx:latest
    container_name: emu2influx

Crash:

    timestamp = get_timestamp(instantaneous_demand)
  File "emu2influx.py", line 16, in get_timestamp
    return datetime.utcfromtimestamp(Y2K + int(obj.TimeStamp, 16)).isoformat()
TypeError: int() can't convert non-string with explicit base

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.

None yet

2 participants