Advertisement
Guest User

Untitled

a guest
Jul 16th, 2017
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.62 KB | None | 0 0
  1. # Published Jan 2013
  2. # Revised Jan 2014 (to add new modules data)
  3. # Revised 2016 (to add camera support)
  4. # Author : Philippe Larduinat, ph.larduinat@wanadoo.fr
  5. # Multiple contributors : see https://github.com/philippelt/netatmo-api-python
  6. # License : GPL V3
  7. """
  8. This API provides access to the Netatmo weather station or/and the Welcome camera
  9. This package can be used with Python2 or Python3 applications and do not
  10. require anything else than standard libraries
  11.  
  12. PythonAPI Netatmo REST data access
  13. coding=utf-8
  14. """
  15. from sys import version_info
  16. from os import getenv
  17. from os.path import expanduser, exists
  18. import json, time
  19. import imghdr
  20. import warnings
  21.  
  22. # HTTP libraries depends upon Python 2 or 3
  23. if version_info.major == 3 :
  24. import urllib.parse, urllib.request
  25. else:
  26. from urllib import urlencode
  27. import urllib2
  28.  
  29. ######################## AUTHENTICATION INFORMATION ######################
  30.  
  31. # To be able to have a program accessing your netatmo data, you have to register your program as
  32. # a Netatmo app in your Netatmo account. All you have to do is to give it a name (whatever) and you will be
  33. # returned a client_id and secret that your app has to supply to access netatmo servers.
  34.  
  35. # To ease Docker packaging of your application, you can setup your authentication parameters through env variables
  36.  
  37. # Authentication use :
  38. # 1 - Values hard coded in the library
  39. # 2 - The .netatmo.credentials file in JSON format in your home directory
  40. # 3 - Values defined in environment variables : CLIENT_ID, CLIENT_SECRET, USERNAME, PASSWORD
  41.  
  42. # Each level override values defined in the previous level. You could define CLIENT_ID and CLIENT_SECRET hard coded in the library
  43. # and username/password in .netatmo.credentials or environment variables
  44.  
  45. cred = { # You can hard code authentication information in the following lines
  46. "CLIENT_ID" : "596bddfbf96b116d788b52e1", # Your client ID from Netatmo app registration at http://dev.netatmo.com/dev/listapps
  47. "CLIENT_SECRET" : "b5rcCQzvHWebXONUurLTuK1fPu4z", # Your client app secret ' '
  48. "USERNAME" : "collin.chin@berkeley.edu", # Your netatmo account username
  49. "PASSWORD" : "^KSPMj#725sh" # Your netatmo account password
  50. }
  51.  
  52. # Other authentication setup management (optionals)
  53.  
  54. CREDENTIALS = expanduser("~/.netatmo.credentials")
  55.  
  56. def getParameter(key, default):
  57. return getenv(key, default[key])
  58.  
  59. # 2 : Override hard coded values with credentials file if any
  60. if exists(CREDENTIALS) :
  61. with open(CREDENTIALS, "r") as f:
  62. cred.update({k.upper():v for k,v in json.loads(f.read()).items()})
  63.  
  64. # 3 : Override final value with content of env variables if defined
  65. _CLIENT_ID = getParameter("CLIENT_ID", cred)
  66. _CLIENT_SECRET = getParameter("CLIENT_SECRET", cred)
  67. _USERNAME = getParameter("USERNAME", cred)
  68. _PASSWORD = getParameter("PASSWORD", cred)
  69.  
  70. #########################################################################
  71.  
  72.  
  73. # Common definitions
  74.  
  75. _BASE_URL = "https://api.netatmo.com/"
  76. _AUTH_REQ = _BASE_URL + "oauth2/token"
  77. _GETMEASURE_REQ = _BASE_URL + "api/getmeasure"
  78. _GETSTATIONDATA_REQ = _BASE_URL + "api/getstationsdata"
  79. _GETHOMEDATA_REQ = _BASE_URL + "api/gethomedata"
  80. _GETCAMERAPICTURE_REQ = _BASE_URL + "api/getcamerapicture"
  81. _GETEVENTSUNTIL_REQ = _BASE_URL + "api/geteventsuntil"
  82.  
  83.  
  84.  
  85. class NoDevice( Exception ):
  86. pass
  87.  
  88.  
  89. class ClientAuth:
  90. """
  91. Request authentication and keep access token available through token method. Renew it automatically if necessary
  92.  
  93. Args:
  94. clientId (str): Application clientId delivered by Netatmo on dev.netatmo.com
  95. clientSecret (str): Application Secret key delivered by Netatmo on dev.netatmo.com
  96. username (str)
  97. password (str)
  98. scope (Optional[str]): Default value is 'read_station'
  99. read_station: to retrieve weather station data (Getstationsdata, Getmeasure)
  100. read_camera: to retrieve Welcome data (Gethomedata, Getcamerapicture)
  101. access_camera: to access the camera, the videos and the live stream.
  102. Several value can be used at the same time, ie: 'read_station read_camera'
  103. """
  104.  
  105. def __init__(self, clientId=_CLIENT_ID,
  106. clientSecret=_CLIENT_SECRET,
  107. username=_USERNAME,
  108. password=_PASSWORD,
  109. scope="read_station read_camera access_camera read_presence access_presence"):
  110.  
  111. postParams = {
  112. "grant_type" : "password",
  113. "client_id" : clientId,
  114. "client_secret" : clientSecret,
  115. "username" : username,
  116. "password" : password,
  117. "scope" : scope
  118. }
  119. resp = postRequest(_AUTH_REQ, postParams)
  120. self._clientId = clientId
  121. self._clientSecret = clientSecret
  122. self._accessToken = resp['access_token']
  123. self.refreshToken = resp['refresh_token']
  124. self._scope = resp['scope']
  125. self.expiration = int(resp['expire_in'] + time.time())
  126.  
  127. @property
  128. def accessToken(self):
  129.  
  130. if self.expiration < time.time(): # Token should be renewed
  131. postParams = {
  132. "grant_type" : "refresh_token",
  133. "refresh_token" : self.refreshToken,
  134. "client_id" : self._clientId,
  135. "client_secret" : self._clientSecret
  136. }
  137. resp = postRequest(_AUTH_REQ, postParams)
  138. self._accessToken = resp['access_token']
  139. self.refreshToken = resp['refresh_token']
  140. self.expiration = int(resp['expire_in'] + time.time())
  141. return self._accessToken
  142.  
  143.  
  144. class User:
  145. """
  146. This class returns basic information about the user
  147.  
  148. Args:
  149. authData (ClientAuth): Authentication information with a working access Token
  150. """
  151. def __init__(self, authData):
  152. postParams = {
  153. "access_token" : authData.accessToken
  154. }
  155. resp = postRequest(_GETSTATIONDATA_REQ, postParams)
  156. self.rawData = resp['body']
  157. self.devList = self.rawData['devices']
  158. self.ownerMail = self.rawData['user']['mail']
  159.  
  160. class WeatherStationData:
  161. """
  162. List the Weather Station devices (stations and modules)
  163.  
  164. Args:
  165. authData (ClientAuth): Authentication information with a working access Token
  166. """
  167. def __init__(self, authData):
  168. self.getAuthToken = authData.accessToken
  169. postParams = {
  170. "access_token" : self.getAuthToken
  171. }
  172. resp = postRequest(_GETSTATIONDATA_REQ, postParams)
  173. self.rawData = resp['body']['devices']
  174. if not self.rawData : raise NoDevice("No weather station available")
  175. self.stations = { d['_id'] : d for d in self.rawData }
  176. self.modules = dict()
  177. for i in range(len(self.rawData)):
  178. for m in self.rawData[i]['modules']:
  179. self.modules[ m['_id'] ] = m
  180. self.default_station = list(self.stations.values())[0]['station_name']
  181.  
  182. def modulesNamesList(self, station=None):
  183. res = [m['module_name'] for m in self.modules.values()]
  184. res.append(self.stationByName(station)['module_name'])
  185. return res
  186.  
  187. def stationByName(self, station=None):
  188. if not station : station = self.default_station
  189. for i,s in self.stations.items():
  190. if s['station_name'] == station :
  191. return self.stations[i]
  192. return None
  193.  
  194. def stationById(self, sid):
  195. return None if sid not in self.stations else self.stations[sid]
  196.  
  197. def moduleByName(self, module, station=None):
  198. s = None
  199. if station :
  200. s = self.stationByName(station)
  201. if not s : return None
  202. for m in self.modules:
  203. mod = self.modules[m]
  204. if mod['module_name'] == module :
  205. return mod
  206. return None
  207.  
  208. def moduleById(self, mid, sid=None):
  209. s = self.stationById(sid) if sid else None
  210. if mid in self.modules :
  211. if s:
  212. for module in s['modules']:
  213. if module['_id'] == mid:
  214. return module
  215. else:
  216. return self.modules[mid]
  217.  
  218. def lastData(self, station=None, exclude=0):
  219. s = self.stationByName(station)
  220. if not s : return None
  221. lastD = dict()
  222. # Define oldest acceptable sensor measure event
  223. limit = (time.time() - exclude) if exclude else 0
  224. ds = s['dashboard_data']
  225. if ds['time_utc'] > limit :
  226. lastD[s['module_name']] = ds.copy()
  227. lastD[s['module_name']]['When'] = lastD[s['module_name']].pop("time_utc")
  228. lastD[s['module_name']]['wifi_status'] = s['wifi_status']
  229. for module in s["modules"]:
  230. ds = module['dashboard_data']
  231. if ds['time_utc'] > limit :
  232. # If no module_name has been setup, use _id by default
  233. if "module_name" not in module : module['module_name'] = module["_id"]
  234. lastD[module['module_name']] = ds.copy()
  235. lastD[module['module_name']]['When'] = lastD[module['module_name']].pop("time_utc")
  236. # For potential use, add battery and radio coverage information to module data if present
  237. for i in ('battery_vp', 'rf_status') :
  238. if i in module : lastD[module['module_name']][i] = module[i]
  239. return lastD
  240.  
  241. def checkNotUpdated(self, station=None, delay=3600):
  242. res = self.lastData(station)
  243. ret = []
  244. for mn,v in res.items():
  245. if time.time()-v['When'] > delay : ret.append(mn)
  246. return ret if ret else None
  247.  
  248. def checkUpdated(self, station=None, delay=3600):
  249. res = self.lastData(station)
  250. ret = []
  251. for mn,v in res.items():
  252. if time.time()-v['When'] < delay : ret.append(mn)
  253. return ret if ret else None
  254.  
  255. def getMeasure(self, device_id, scale, mtype, module_id=None, date_begin=None, date_end=None, limit=None, optimize=False, real_time=False):
  256. postParams = { "access_token" : self.getAuthToken }
  257. postParams['device_id'] = device_id
  258. if module_id : postParams['module_id'] = module_id
  259. postParams['scale'] = scale
  260. postParams['type'] = mtype
  261. if date_begin : postParams['date_begin'] = date_begin
  262. if date_end : postParams['date_end'] = date_end
  263. if limit : postParams['limit'] = limit
  264. postParams['optimize'] = "true" if optimize else "false"
  265. postParams['real_time'] = "true" if real_time else "false"
  266. return postRequest(_GETMEASURE_REQ, postParams)
  267.  
  268. def MinMaxTH(self, station=None, module=None, frame="last24"):
  269. if not station : station = self.default_station
  270. s = self.stationByName(station)
  271. if not s :
  272. s = self.stationById(station)
  273. if not s : return None
  274. if frame == "last24":
  275. end = time.time()
  276. start = end - 24*3600 # 24 hours ago
  277. elif frame == "day":
  278. start, end = todayStamps()
  279. if module and module != s['module_name']:
  280. m = self.moduleByName(module, s['station_name'])
  281. if not m :
  282. m = self.moduleById(s['_id'], module)
  283. if not m : return None
  284. # retrieve module's data
  285. resp = self.getMeasure(
  286. device_id = s['_id'],
  287. module_id = m['_id'],
  288. scale = "max",
  289. mtype = "Temperature,Humidity",
  290. date_begin = start,
  291. date_end = end)
  292. else : # retrieve station's data
  293. resp = self.getMeasure(
  294. device_id = s['_id'],
  295. scale = "max",
  296. mtype = "Temperature,Humidity",
  297. date_begin = start,
  298. date_end = end)
  299. if resp:
  300. T = [v[0] for v in resp['body'].values()]
  301. H = [v[1] for v in resp['body'].values()]
  302. return min(T), max(T), min(H), max(H)
  303. else:
  304. return None
  305.  
  306. class DeviceList(WeatherStationData):
  307. """
  308. This class is now deprecated. Use WeatherStationData directly instead
  309. """
  310. warnings.warn("The 'DeviceList' class was renamed 'WeatherStationData'",
  311. DeprecationWarning )
  312. pass
  313.  
  314. class HomeData:
  315. """
  316. List the Netatmo home informations (Homes, cameras, events, persons)
  317.  
  318. Args:
  319. authData (ClientAuth): Authentication information with a working access Token
  320. """
  321. def __init__(self, authData):
  322. self.getAuthToken = authData.accessToken
  323. postParams = {
  324. "access_token" : self.getAuthToken
  325. }
  326. resp = postRequest(_GETHOMEDATA_REQ, postParams)
  327. self.rawData = resp['body']
  328. self.homes = { d['id'] : d for d in self.rawData['homes'] }
  329. if not self.homes : raise NoDevice("No home available")
  330. self.persons = dict()
  331. self.events = dict()
  332. self.cameras = dict()
  333. self.lastEvent = dict()
  334. for i in range(len(self.rawData['homes'])):
  335. nameHome=self.rawData['homes'][i]['name']
  336. if nameHome not in self.cameras:
  337. self.cameras[nameHome]=dict()
  338. for p in self.rawData['homes'][i]['persons']:
  339. self.persons[ p['id'] ] = p
  340. for e in self.rawData['homes'][i]['events']:
  341. if e['camera_id'] not in self.events:
  342. self.events[ e['camera_id'] ] = dict()
  343. self.events[ e['camera_id'] ][ e['time'] ] = e
  344. for c in self.rawData['homes'][i]['cameras']:
  345. self.cameras[nameHome][ c['id'] ] = c
  346. for camera in self.events:
  347. self.lastEvent[camera]=self.events[camera][sorted(self.events[camera])[-1]]
  348. self.default_home = list(self.homes.values())[0]['name']
  349. if not self.cameras[self.default_home] : raise NoDevice("No camera available in default home")
  350. self.default_camera = list(self.cameras[self.default_home].values())[0]
  351.  
  352. def homeById(self, hid):
  353. return None if hid not in self.homes else self.homes[hid]
  354.  
  355. def homeByName(self, home=None):
  356. if not home: home = self.default_home
  357. for key,value in self.homes.items():
  358. if value['name'] == home:
  359. return self.homes[key]
  360.  
  361. def cameraById(self, cid):
  362. for home,cam in self.cameras.items():
  363. if cid in self.cameras[home]:
  364. return self.cameras[home][cid]
  365. return None
  366.  
  367. def cameraByName(self, camera=None, home=None):
  368. if not camera and not home:
  369. return self.default_camera
  370. elif home and camera:
  371. if home not in self.cameras:
  372. return None
  373. for cam_id in self.cameras[home]:
  374. if self.cameras[home][cam_id]['name'] == camera:
  375. return self.cameras[home][cam_id]
  376. elif not home and camera:
  377. for home, cam_ids in self.cameras.items():
  378. for cam_id in cam_ids:
  379. if self.cameras[home][cam_id]['name'] == camera:
  380. return self.cameras[home][cam_id]
  381. else:
  382. return list(self.cameras[home].values())[0]
  383. return None
  384.  
  385. def cameraUrls(self, camera=None, home=None, cid=None):
  386. """
  387. Return the vpn_url and the local_url (if available) of a given camera
  388. in order to access to its live feed
  389. """
  390. local_url = None
  391. vpn_url = None
  392. if cid:
  393. camera_data=self.cameraById(cid)
  394. else:
  395. camera_data=self.cameraByName(camera=camera, home=home)
  396. if camera_data:
  397. vpn_url = camera_data['vpn_url']
  398. resp = postRequest('{0}/command/ping'.format(camera_data['vpn_url']),dict())
  399. temp_local_url=resp['local_url']
  400. resp = postRequest('{0}/command/ping'.format(temp_local_url),dict())
  401. if temp_local_url == resp['local_url']:
  402. local_url = temp_local_url
  403. return vpn_url, local_url
  404.  
  405. def personsAtHome(self, home=None):
  406. """
  407. Return the list of known persons who are currently at home
  408. """
  409. if not home: home = self.default_home
  410. home_data = self.homeByName(home)
  411. atHome = []
  412. for p in home_data['persons']:
  413. #Only check known persons
  414. if 'pseudo' in p:
  415. if not p["out_of_sight"]:
  416. atHome.append(p['pseudo'])
  417. return atHome
  418.  
  419. def getCameraPicture(self, image_id, key):
  420. """
  421. Download a specific image (of an event or user face) from the camera
  422. """
  423. postParams = {
  424. "access_token" : self.getAuthToken,
  425. "image_id" : image_id,
  426. "key" : key
  427. }
  428. resp = postRequest(_GETCAMERAPICTURE_REQ, postParams, json_resp=False)
  429. image_type = imghdr.what('NONE.FILE',resp)
  430. return resp, image_type
  431.  
  432. def getProfileImage(self, name):
  433. """
  434. Retrieve the face of a given person
  435. """
  436. for p in self.persons:
  437. if 'pseudo' in self.persons[p]:
  438. if name == self.persons[p]['pseudo']:
  439. image_id = self.persons[p]['face']['id']
  440. key = self.persons[p]['face']['key']
  441. return self.getCameraPicture(image_id, key)
  442. return None, None
  443.  
  444. def updateEvent(self, event=None, home=None):
  445. """
  446. Update the list of event with the latest ones
  447. """
  448. if not home: home=self.default_home
  449. if not event:
  450. #If not event is provided we need to retrieve the oldest of the last event seen by each camera
  451. listEvent = dict()
  452. for cam_id in self.lastEvent:
  453. listEvent[self.lastEvent[cam_id]['time']] = self.lastEvent[cam_id]
  454. event = listEvent[sorted(listEvent)[0]]
  455.  
  456. home_data = self.homeByName(home)
  457. postParams = {
  458. "access_token" : self.getAuthToken,
  459. "home_id" : home_data['id'],
  460. "event_id" : event['id']
  461. }
  462. resp = postRequest(_GETEVENTSUNTIL_REQ, postParams)
  463. eventList = resp['body']['events_list']
  464. for e in eventList:
  465. self.events[ e['camera_id'] ][ e['time'] ] = e
  466. for camera in self.events:
  467. self.lastEvent[camera]=self.events[camera][sorted(self.events[camera])[-1]]
  468.  
  469. def personSeenByCamera(self, name, home=None, camera=None):
  470. """
  471. Return True if a specific person has been seen by a camera
  472. """
  473. try:
  474. cam_id = self.cameraByName(camera=camera, home=home)['id']
  475. except TypeError:
  476. print("personSeenByCamera: Camera name or home is unknown")
  477. return False
  478. #Check in the last event is someone known has been seen
  479. if self.lastEvent[cam_id]['type'] == 'person':
  480. person_id = self.lastEvent[cam_id]['person_id']
  481. if 'pseudo' in self.persons[person_id]:
  482. if self.persons[person_id]['pseudo'] == name:
  483. return True
  484. return False
  485.  
  486. def _knownPersons(self):
  487. known_persons = dict()
  488. for p_id,p in self.persons.items():
  489. if 'pseudo' in p:
  490. known_persons[ p_id ] = p
  491. return known_persons
  492.  
  493. def someoneKnownSeen(self, home=None, camera=None):
  494. """
  495. Return True if someone known has been seen
  496. """
  497. try:
  498. cam_id = self.cameraByName(camera=camera, home=home)['id']
  499. except TypeError:
  500. print("personSeenByCamera: Camera name or home is unknown")
  501. return False
  502. #Check in the last event is someone known has been seen
  503. if self.lastEvent[cam_id]['type'] == 'person':
  504. if self.lastEvent[cam_id]['person_id'] in self._knownPersons():
  505. return True
  506. return False
  507.  
  508. def someoneUnknownSeen(self, home=None, camera=None):
  509. """
  510. Return True if someone unknown has been seen
  511. """
  512. try:
  513. cam_id = self.cameraByName(camera=camera, home=home)['id']
  514. except TypeError:
  515. print("personSeenByCamera: Camera name or home is unknown")
  516. return False
  517. #Check in the last event is someone known has been seen
  518. if self.lastEvent[cam_id]['type'] == 'person':
  519. if self.lastEvent[cam_id]['person_id'] not in self._knownPersons():
  520. return True
  521. return False
  522.  
  523. def motionDetected(self, home=None, camera=None):
  524. """
  525. Return True if movement has been detected
  526. """
  527. try:
  528. cam_id = self.cameraByName(camera=camera, home=home)['id']
  529. except TypeError:
  530. print("personSeenByCamera: Camera name or home is unknown")
  531. return False
  532. if self.lastEvent[cam_id]['type'] == 'movement':
  533. return True
  534. return False
  535.  
  536. class WelcomeData(HomeData):
  537. """
  538. This class is now deprecated. Use HomeData instead
  539. Home can handle many devices, not only Welcome cameras
  540. """
  541. warnings.warn("The 'WelcomeData' class was renamed 'HomeData' to handle new Netatmo Home capabilities",
  542. DeprecationWarning )
  543. pass
  544.  
  545. # Utilities routines
  546.  
  547. def postRequest(url, params, json_resp=True):
  548. # Netatmo response body size limited to 64k (should be under 16k)
  549. if version_info.major == 3:
  550. req = urllib.request.Request(url)
  551. req.add_header("Content-Type","application/x-www-form-urlencoded;charset=utf-8")
  552. params = urllib.parse.urlencode(params).encode('utf-8')
  553. resp = urllib.request.urlopen(req, params)
  554. else:
  555. params = urlencode(params)
  556. headers = {"Content-Type" : "application/x-www-form-urlencoded;charset=utf-8"}
  557. req = urllib2.Request(url=url, data=params, headers=headers)
  558. resp = urllib2.urlopen(req)
  559. data = ""
  560. for buff in iter(lambda: resp.read(65535), b''):
  561. data += buff.decode("utf-8")
  562. if json_resp:
  563. return json.loads(data)
  564. else:
  565. return data
  566.  
  567. def toTimeString(value):
  568. return time.strftime("%Y-%m-%d_%H:%M:%S", time.localtime(int(value)))
  569.  
  570. def toEpoch(value):
  571. return int(time.mktime(time.strptime(value,"%Y-%m-%d_%H:%M:%S")))
  572.  
  573. def todayStamps():
  574. today = time.strftime("%Y-%m-%d")
  575. today = int(time.mktime(time.strptime(today,"%Y-%m-%d")))
  576. return today, today+3600*24
  577.  
  578. # Global shortcut
  579.  
  580. def getStationMinMaxTH(station=None, module=None):
  581. authorization = ClientAuth()
  582. devList = DeviceList(authorization)
  583. if not station : station = devList.default_station
  584. if module :
  585. mname = module
  586. else :
  587. mname = devList.stationByName(station)['module_name']
  588. lastD = devList.lastData(station)
  589. if mname == "*":
  590. result = dict()
  591. for m in lastD.keys():
  592. if time.time()-lastD[m]['When'] > 3600 : continue
  593. r = devList.MinMaxTH(module=m)
  594. result[m] = (r[0], lastD[m]['Temperature'], r[1])
  595. else:
  596. if time.time()-lastD[mname]['When'] > 3600 : result = ["-", "-"]
  597. else : result = [lastD[mname]['Temperature'], lastD[mname]['Humidity']]
  598. result.extend(devList.MinMaxTH(station, mname))
  599. return result
  600.  
  601.  
  602. # auto-test when executed directly
  603.  
  604. if __name__ == "__main__":
  605.  
  606. from sys import exit, stdout, stderr
  607.  
  608. if not _CLIENT_ID or not _CLIENT_SECRET or not _USERNAME or not _PASSWORD :
  609. stderr.write("Library source missing identification arguments to check lnetatmo.py (user/password/etc...)")
  610. exit(1)
  611.  
  612. authorization = ClientAuth() # Test authentication method
  613.  
  614. try:
  615. weatherStation = WeatherStationData(authorization) # Test DEVICELIST
  616. except NoDevice:
  617. if stdout.isatty():
  618. print("lnetatmo.py : warning, no weather station available for testing")
  619. else:
  620. weatherStation.MinMaxTH() # Test GETMEASUR
  621.  
  622.  
  623. try:
  624. Homes = HomeData(authorization)
  625. except NoDevice :
  626. if stdout.isatty():
  627. print("lnetatmo.py : warning, no home available for testing")
  628.  
  629. # If we reach this line, all is OK
  630.  
  631. # If launched interactively, display OK message
  632. if stdout.isatty():
  633. print("lnetatmo.py : OK")
  634.  
  635. exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement