|
1 | 1 | # Published Jan 2013
|
2 |
| -# Revised Jan 2014 (to add new modules data) |
3 |
| -# Revised 2016 (to add camera support) |
4 | 2 | # Author : Philippe Larduinat, ph.larduinat@wanadoo.fr
|
5 | 3 | # Multiple contributors : see https://github.com/philippelt/netatmo-api-python
|
6 | 4 | # License : GPL V3
|
|
15 | 13 | from sys import version_info
|
16 | 14 | from os import getenv
|
17 | 15 | from os.path import expanduser, exists
|
| 16 | +import platform |
| 17 | +import warnings |
18 | 18 | import json, time
|
19 | 19 | import imghdr
|
20 | 20 | import warnings
|
|
30 | 30 | from urllib import urlencode
|
31 | 31 | import urllib2
|
32 | 32 |
|
| 33 | + |
33 | 34 | ######################## AUTHENTICATION INFORMATION ######################
|
34 | 35 |
|
35 | 36 | # To be able to have a program accessing your netatmo data, you have to register your program as
|
@@ -69,6 +70,13 @@ def getParameter(key, default):
|
69 | 70 | cred.update({k.upper():v for k,v in json.loads(f.read()).items()})
|
70 | 71 |
|
71 | 72 | # 3 : Override final value with content of env variables if defined
|
| 73 | +# Warning, for Windows user, USERNAME contains by default the windows logged user name |
| 74 | +# This usually lead to an authentication error |
| 75 | +if platform.system() == "Windows" and getenv("USERNAME", None): |
| 76 | + warnings.warn("You are running on Windows and the USERNAME env var is set. " \ |
| 77 | + "Be sure this env var contains Your Netatmo username " \ |
| 78 | + "or clear it with <SET USERNAME=> before running your program\n", RuntimeWarning, stacklevel=3) |
| 79 | + |
72 | 80 | _CLIENT_ID = getParameter("CLIENT_ID", cred)
|
73 | 81 | _CLIENT_SECRET = getParameter("CLIENT_SECRET", cred)
|
74 | 82 | _USERNAME = getParameter("USERNAME", cred)
|
|
0 commit comments