diff --git a/PiBox/PiHome/PiApp/api.py b/PiBox/PiHome/PiApp/api.py
index dc35a09..366a43c 100644
--- a/PiBox/PiHome/PiApp/api.py
+++ b/PiBox/PiHome/PiApp/api.py
@@ -49,9 +49,9 @@ def check_username(request):
return HttpResponse(simplejson.dumps({'msg':'Please enter a valid email format'}))
user = PiUser.objects.get(username = request.GET['username'])
if user is not None:
- return HttpResponse(simplejson.dumps({'msg':'Username already exists'}))
+ return HttpResponse(simplejson.dumps({'msg':'Email already exists'}))
except:
- return HttpResponse(simplejson.dumps({'msg':'Username can be used'}))
+ return HttpResponse(simplejson.dumps({'msg':'Email can be used'}))
def check_login(request):
if request.user.is_authenticated():
diff --git a/PiBox/PiHome/PiApp/models.py b/PiBox/PiHome/PiApp/models.py
index 979e21e..c8ec195 100644
--- a/PiBox/PiHome/PiApp/models.py
+++ b/PiBox/PiHome/PiApp/models.py
@@ -21,7 +21,7 @@ class PiUser(AbstractUser):
class PiSettings(models.Model):
- ip = models.IPAddressField(default="127.0.0.1")
+ ip = models.GenericIPAddressField(default="127.0.0.1")
port = models.IntegerField(default=3333)
enable_register = models.BooleanField(default=True)
diff --git a/PiBox/PiHome/WebShell/www/Thumbs.db b/PiBox/PiHome/WebShell/www/Thumbs.db
new file mode 100644
index 0000000..8ae9ea7
Binary files /dev/null and b/PiBox/PiHome/WebShell/www/Thumbs.db differ
diff --git a/PiBox/PiHome/templates/login.html b/PiBox/PiHome/templates/login.html
index 060be16..820a213 100644
--- a/PiBox/PiHome/templates/login.html
+++ b/PiBox/PiHome/templates/login.html
@@ -27,9 +27,11 @@
{% csrf_token %}
+
+
diff --git "a/PiBox/sh/datapoint_tools\200pic.py" "b/PiBox/sh/datapoint_tools\200pic.py"
new file mode 100644
index 0000000..6c6cbc6
--- /dev/null
+++ "b/PiBox/sh/datapoint_tools\200pic.py"
@@ -0,0 +1,106 @@
+#/bin/env python
+# -*-coding:utf8-*-
+'''
+# Any issues or improvements please contact jacob-chen@iotwrt.com
+'''
+import urllib
+import urllib2
+import sys
+import json
+
+try:
+ from poster.encode import multipart_encode
+ from poster.streaminghttp import register_openers
+except:
+ print "In order to post file,you should install poster modules!!"
+ print "sudo pip install poster"
+
+if __name__ == '__main__':
+
+ choose = int(raw_input('1.write 2.read 3.edit 4.remove 5.history'))
+ domain = raw_input('domain(as 192.168.10.106:8000) : ')
+ sensor_id = raw_input('sensor_id(int) : ')
+
+ #write
+ if choose == 1:
+ filepath = raw_input('filepath(as ./xxx.jpg) : ')
+ key = raw_input('key(as 2012-12-12T11:11:11) : ')
+
+ # 在 urllib2 上注册 http 流处理句柄
+ register_openers()
+
+ # 开始对文件的 multiart/form-data 编码
+ # "value" 是参数的名字,一般通过 HTML 中的 标签的 name 参数设置
+ # headers 包含必须的 Content-Type 和 Content-Length
+ # datagen 是一个生成器对象,返回编码过后的参数,这里如果有多个参数的话依次添加即可
+ datagen, headers = multipart_encode({"value": open(filepath, "rb"), "key" : key})
+
+ request = urllib2.Request("http://" + domain + "/API/sensor/" + sensor_id + "/datapoint/", datagen, headers)
+
+ get = urllib2.urlopen(request).read()
+ print 'ret body:', get
+ s = json.loads(get)
+ print 'msg:', s['msg']
+
+ #read
+ elif choose == 2:
+ key = raw_input('key(as 2012-12-12T11:11:11) : ')
+ params = urllib.urlencode({'key': key})
+ f = urllib.urlopen("http://" + domain + "/API/sensor/" + sensor_id + "/datapoint/get/?%s" % params)
+ get = f.read()
+ print 'ret body:', get
+ s = json.loads(get)
+ print 'key:',s['key'],'value:',s['value']
+
+ #edit
+ elif choose == 3:
+ filepath = raw_input('filepath(as ./xxx.jpg) : ')
+ key = raw_input('key(as 2012-12-12T11:11:11) : ')
+
+ # 在 urllib2 上注册 http 流处理句柄
+ register_openers()
+
+ # 开始对文件的 multiart/form-data 编码
+ # "value" 是参数的名字,一般通过 HTML 中的 标签的 name 参数设置
+ # headers 包含必须的 Content-Type 和 Content-Length
+ # datagen 是一个生成器对象,返回编码过后的参数,这里如果有多个参数的话依次添加即可
+ datagen, headers = multipart_encode({"value": open(filepath, "rb"), "key" : key})
+
+ request = urllib2.Request("http://" + domain + "/API/sensor/" + sensor_id + "/datapoint/edit/", datagen, headers)
+
+ get = urllib2.urlopen(request).read()
+ print 'ret body:', get
+ s = json.loads(get)
+ print 'msg:', s['msg']
+
+ #remove
+ elif choose == 4:
+ key = raw_input('key(as 2012-12-12T11:11:11) : ')
+ params = urllib.urlencode({'key': key})
+ f = urllib.urlopen("http://" + domain + "/API/sensor/" + sensor_id + "/datapoint/remove/?%s" % params)
+ get = f.read()
+ print 'ret body:', get
+ s = json.loads(get)
+ print 'msg:', s['msg']
+
+ #history
+ elif choose == 5:
+ ex = raw_input('latest 20?y or n')
+ if ex == 'y':
+ f = urllib.urlopen("http://" + domain + "/API/sensor/" + sensor_id + "/datapoint/history/")
+ get = f.read()
+ print 'ret body:', get
+ s = json.loads(get)
+ for item in s['datapoint']:
+ print 'key:',item['key'],'value:',item['value']
+ else:
+ start = raw_input('start(as 2012-12-12T11:11:11) : ')
+ end = raw_input('end(as 2012-12-12T11:11:11) : ')
+ interval = raw_input('interval(int) : ')
+ params = urllib.urlencode({'start': start, 'end' : end, 'interval' : interval})
+ f = urllib.urlopen("http://" + domain + "/API/sensor/" + sensor_id + "/datapoint/history/?%s" % params)
+ get = f.read()
+ print 'ret body:', get
+ s = json.loads(get)
+ for item in s['datapoint']:
+ print 'key:',item['key'],'value:',item['value']
\ No newline at end of file
diff --git "a/PiBox/sh/datapoint_tools\360switch.py" "b/PiBox/sh/datapoint_tools\360switch.py"
new file mode 100644
index 0000000..8f35c58
--- /dev/null
+++ "b/PiBox/sh/datapoint_tools\360switch.py"
@@ -0,0 +1,33 @@
+#/bin/env python
+# -*-coding:utf8-*-
+'''
+# Any issues or improvements please contact jacob-chen@iotwrt.com
+'''
+import urllib
+import json
+
+if __name__ == '__main__':
+
+ choose = int(raw_input('1.write 2.read '))
+ domain = raw_input('domain(as 192.168.10.106:8000) : ')
+ sensor_id = raw_input('sensor_id(int) : ')
+
+ if choose == 1:
+ value = int(raw_input('value(int) : '))
+ # params = urllib.urlencode()
+ params = urllib.urlencode({'value': value})
+ f = urllib.urlopen("http://" + domain + "/API/sensor/" + sensor_id + "/datapoint/?%s" % params)
+ get = f.read()
+ print 'ret body:', get
+
+ s = json.loads(get)
+ print 'msg:', s['msg']
+
+ elif choose == 2:
+ # params = urllib.urlencode()
+ f = urllib.urlopen("http://" + domain + "/API/sensor/" + sensor_id + "/datapoint/get/")
+ get = f.read()
+ print 'ret body:', get
+
+ s = json.loads(get)
+ print 'value:', s['value']