-
Notifications
You must be signed in to change notification settings - Fork 4
/
garmin_auth.py
30 lines (26 loc) · 997 Bytes
/
garmin_auth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
import os
import sys
import getpass
import garth
if getattr(sys, 'frozen', False):
# If we're running as a py installer bundle
SCRIPT_DIR = os.path.dirname(sys.executable)
else:
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
domain = input("Garmin domain [garmin.com]: ") or 'garmin.com'
username = input("Username (e-mail): ")
if not sys.stdin.isatty(): # This terminal cannot support input without displaying text
print(f'*WARNING* The current shell ({os.name}) cannot support hidden text entry.')
print(f'Your password entry WILL BE VISIBLE.')
print(f'If you are running a bash shell under windows, try executing this program via winpty:')
print(f'>winpty python {sys.argv[0]}')
password = input("Password (will be shown): ")
else:
password = getpass.getpass("Password: ")
garth.configure(domain=domain)
try:
garth.login(username, password)
garth.save('%s/garth' % SCRIPT_DIR)
except Exception as e:
print(e)