kjkjava / garmin-connect-export

Download a copy of your Garmin Connect data, including stats and GPX tracks.
MIT License
314 stars 134 forks source link

Problem with german Umlauts when running as cron-job #12

Closed JoGu01 closed 8 years ago

JoGu01 commented 8 years ago

Hi, i have a lot of activities that contain the character "ö". When running gcexport.py in a cron job i get the followin error:

Garmin Connect activity: [1127628337] Traceback (most recent call last): File "./gcexport.py", line 174, in print a['activity']['activityName']['value'] UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 1: ordinal not in range(128)

Is there anything i can do?

Regards, Jörg

lefty01 commented 8 years ago

does it work outside of cron? run from cmdline to check ... if that works grep your LANG env variable and use that in the cronjob... you'll need unicode (UTF-8) setting LANG inside the cronscript should work eg. something like: export LANG=en_US.UTF-8 cron does not import your "usual" environment, but you know that ;)

JoGu01 commented 8 years ago

;) Yeah i know that and it was the first thing i tried. -> second line of the script: export LANG=de_DE.UTF-8 ... And the really frustrating thing is that it is indeed working from commandline. I am absolutely out of ideas. Any others hints?

Thanks for this great script. Regards, Jörg

ebrensi commented 8 years ago

Perhaps try my fork of it: https://github.com/ebrensi/garmin-connect-export.git

Mine is both Python 2 and 3 ready and it uses unicode string literals, so it might fix your problem.
I submitted a pull request for it. check it out: https://github.com/kjkjava/garmin-connect-export/pull/14

JoGu01 commented 8 years ago

Thanks for your answer. Tried your fork and it gives a lot of debugging-infos. Unfortunately it shows the same error:

INFO:Welcome to Garmin Connect Exporter! INFO:Warning: Output directory already exists. Will skip already-downloaded files and append to the CSV file. INFO:Starting new HTTPS connection (1): sso.garmin.com DEBUG:"GET /sso/login?service=https://connect.garmin.com/post-auth/login&webhost=olaxpw-connect04&source=https://connect.garmin.com/en-US/signin&redirectAfterAccountLoginUrl=https://connect.garmin.com/post-auth/login&redirectAfterAccountCreationUrl=https://connect.garmin.com/post-auth/login&gauthHost=https://sso.garmin.com/sso&locale=en_US&id=gauth-widget&cssUrl=https://static.garmincdn.com/com.garmin.connect/ui/css/gauth-custom-v1.1-min.css&clientId=GarminConnect&rememberMeShown=true&rememberMeChecked=false&createAccountShown=true&openCreateAccount=false&usernameShown=false&displayNameShown=false&consumeServiceTicket=false&initialFocus=true&embedWidget=false&generateExtraServiceTicket=false HTTP/1.1" 200 8014 DEBUG:"POST /sso/login?service=https://connect.garmin.com/post-auth/login&webhost=olaxpw-connect04&source=https://connect.garmin.com/en-US/signin&redirectAfterAccountLoginUrl=https://connect.garmin.com/post-auth/login&redirectAfterAccountCreationUrl=https://connect.garmin.com/post-auth/login&gauthHost=https://sso.garmin.com/sso&locale=en_US&id=gauth-widget&cssUrl=https://static.garmincdn.com/com.garmin.connect/ui/css/gauth-custom-v1.1-min.css&clientId=GarminConnect&rememberMeShown=true&rememberMeChecked=false&createAccountShown=true&openCreateAccount=false&usernameShown=false&displayNameShown=false&consumeServiceTicket=false&initialFocus=true&embedWidget=false&generateExtraServiceTicket=false HTTP/1.1" 200 1987 INFO:Starting new HTTPS connection (1): connect.garmin.com ... DEBUG:"GET /modern/ HTTP/1.1" 200 3828 INFO:Starting new HTTP connection (1): connect.garmin.com DEBUG:"GET /proxy/activity-search-service-1.0/json/activities?start=0&limit=14 HTTP/1.1" 302 0 DEBUG:"GET /proxy/activity-search-service-1.0/json/activities?start=0&limit=14 HTTP/1.1" 200 16562 INFO:Garmin Connect activity: [1140387973] Düsseldorf-Marathon Staffel Abschnitt 2 So, 2016 Apr 24 11:06, 01:19:47, 13,31 Kilometer INFO:Downloading activity... DEBUG:"GET /proxy/download-service/files/activity/1140387973 HTTP/1.1" 302 0 DEBUG:"GET /proxy/download-service/files/activity/1140387973 HTTP/1.1" 200 None Traceback (most recent call last): File "./gcexport.py", line 467, in csv_file.write(csv_record) UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 15: ordinal not in range(128)

ebrensi commented 8 years ago

ok try it now. https://github.com/ebrensi/garmin-connect-export.git I tested it out in Python 2 and 3 with all file output types (tcx, gpx, "original"), with a Garmin connect activity with some European characters in the description.

JoGu01 commented 8 years ago

Hi Efrem,

the error is gone an the script is now downloading :+1: But now there is an other issue. The script outputs "INFO:Warning: Output directory already exists. Will skip already-downloaded files and append to the CSV file." which is absolutely true. The Problem is, that the existing files are NOT skipped. I can absolutely live with that, but i think ist was not intended to work this way :wink:

Thanks and Regards, Jörg

ebrensi commented 8 years ago

Jörg, gcexport.py skips files correctly now. Note that if you have the -c tag set (i.e.gcexport -c 2 ...), the files that are skipped count towards the total number of files to be retrieved, so if set it download 2 files, and you already have the latest 2 files, nothing will get downloaded.

JoGu01 commented 8 years ago

Hi Efrem, Just tested it. No more error and skipping already downloaded files. Thanks for your help :+1: Regards, Jörg