asib / polar-flow-export

Tool for exporting training sessions from Polar Flow.
10 stars 5 forks source link

Error on writing #3

Closed BarbaraDi closed 1 year ago

BarbaraDi commented 2 years ago

Hello, Thank you for your script. When trying to execute, I get an error on the writing part:

TypeError: a bytes-like object is required, not 'str'

What did I do wrong? :-)

asib commented 2 years ago

Might be a Python 3 vs 2 issue.

Can you provide the full traceback?

filipsPL commented 1 year ago

The same here:

Traceback (most recent call last):
  File "/home/user/polar-flow-export/polar-export.py", line 67, in <module>
    run(driver, username, password, month, year, output_dir)
  File "/home/user/polar-flow-export/polar-export.py", line 56, in run
    export_exercise(driver, ex_id, output_dir)
  File "/home/user/polar-flow-export/polar-export.py", line 47, in export_exercise
    outfile.write(tcx_data)
TypeError: a bytes-like object is required, not 'str'

Python 3.11.3

filipsPL commented 1 year ago

And the solution is to change:

outfile = open(os.path.join(output_dir, filename), 'wb')

to

outfile = open(os.path.join(output_dir, filename), 'w')

asib commented 1 year ago

Fixed in #2.