Skip to content

Commit

Permalink
change ZK to 7.201
Browse files Browse the repository at this point in the history
  • Loading branch information
shaofang committed Oct 28, 2013
1 parent 4f8c64b commit 32d74ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def log_request(self):

app = Bottle()

@app.get('/ping')
def ping():
return 'pong'

@app.route("/smartserver/<filename:path>")
def assets(filename):
Expand Down
3 changes: 2 additions & 1 deletion smartapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

__all__ = [ "ZK_URI", "WEB_HOST", "WEB_PORT"]

PI_PATH = "/pi/alive/mac"

ZK_URI = os.getenv("ZK_URI", "127.0.0.1:2181")
WEB_HOST = os.getenv("WEB_HOST", "")
WEB_PORT = int(os.getenv("WEB_PORT", "80"))
WEB_PORT = int(os.getenv("WEB_PORT", "80"))
17 changes: 9 additions & 8 deletions smartapi/zkconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# -*- coding: utf-8 -*-

import os
from config import ZK_URI
from config import ZK_URI, PI_PATH
from kazoo.client import KazooClient

__all__ = ["get_devices_list"]

PI_PATH = "/pi"
#PI_PATH = "/pi"
JOIN = os.path.join

def get_devices_list():
Expand All @@ -18,10 +18,11 @@ def get_devices_list():
for sub in subs:
data = zk.get(JOIN(PI_PATH, sub))
if data is not None:
values = data[0].split(':')
if len(values) > 1:
pi_list.append({'ip': values[0], 'deviceid': values[1],'product': values[2], 'build': values[3] })
else:
pi_list.append({'ip': values[0], 'deviceid': '','product': '', 'build': ''})
#values = data[0].split(':')
#if len(values) > 1:
# pi_list.append({'ip': values[0], 'deviceid': values[1],'product': values[2], 'build': values[3] })
#else:
# pi_list.append({'ip': values[0], 'deviceid': '','product': '', 'build': ''})
pi_list.append(data)
zk.stop()
return pi_list
return pi_list

0 comments on commit 32d74ad

Please sign in to comment.