Browse Source

删除 django-websocket

添加 requirements.txt
pull/2/head
guanghongwei 10 years ago
parent
commit
9cdd62b62d
  1. 1
      scripts/pip-requirement.txt
  2. 14
      scripts/requirements.txt
  3. 19
      webroot/AutoSa/AutoSa/views.py
  4. 2
      webroot/AutoSa/UserManage/models.py
  5. 28
      webroot/AutoSa/templates/websocket.html

1
scripts/pip-requirement.txt

@ -1 +0,0 @@
pexpect == 3.3

14
scripts/requirements.txt

@ -0,0 +1,14 @@
pexpect==3.3
django-socketio==0.3.9
gevent-socketio==0.2.1
sphinx-me==0.3
django==1.7.1
gevent-websocket==0.9.3
gevent==1.0.1
greenlet==0.4.5
python-ldap==2.4.18
paramiko==1.15.1
pycrypto==2.6.1
ecdsa>=0.11
MySQL-python==1.2.5
python-ldap==2.4.18

19
webroot/AutoSa/AutoSa/views.py

@ -23,8 +23,6 @@ from AutoSa.settings import CONF_DIR
from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.core.paginator import Paginator, InvalidPage, EmptyPage
import time import time
import datetime import datetime
from django_websocket import require_websocket
from django_websocket import accept_websocket
cf = ConfigParser.ConfigParser() cf = ConfigParser.ConfigParser()
@ -1004,25 +1002,8 @@ def killSession(request):
return HttpResponse('ok') return HttpResponse('ok')
@require_websocket
def echo(request):
f = open('/tmp/websocket.log')
message = f.read()
request.websocket.send(message)
@accept_websocket
def lower_case(request):
f = open('/tmp/websocket.log')
while True:
message = f.read()
request.websocket.send(message)
time.sleep(5)
def test_websocket(request):
return render_to_response('websocket.html')

2
webroot/AutoSa/UserManage/models.py

@ -14,7 +14,7 @@ class User(models.Model):
key_pass = models.CharField(max_length=100) key_pass = models.CharField(max_length=100)
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
group = models.ManyToManyField(Group) group = models.ManyToManyField(Group)
is_admin = models.BooleanField() is_admin = models.BooleanField(default=False)
is_superuser = models.BooleanField() is_superuser = models.BooleanField()
ldap_password = models.CharField(max_length=100, null=False) ldap_password = models.CharField(max_length=100, null=False)
email = models.EmailField(max_length=50, null=True, blank=True) email = models.EmailField(max_length=50, null=True, blank=True)

28
webroot/AutoSa/templates/websocket.html

@ -1,28 +0,0 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>WebSocket Test</title>
<script language="javascript" type="text/javascript">
var wsUri = "ws://echo.websocket.org/";
var output;
function init() {
output = document.getElementById("output"); testWebSocket();
}
function testWebSocket() {
var websocket = new WebSocket(wsUri);
websocket.onopen = function(evt) { onOpen(evt) };
websocket.onclose = function(evt) { onClose(evt) };
websocket.onmessage = function(evt) { onMessage(evt) };
websocket.onerror = function(evt) { onError(evt) }; }
function onOpen(evt) { writeToScreen("CONNECTED"); doSend("WebSocket rocks"); }
function onClose(evt) { writeToScreen("DISCONNECTED"); }
function onMessage(evt) { writeToScreen('<span style="color: blue;">RESPONSE: ' + evt.data+'</span>'); websocket.close(); }
function onError(evt) { writeToScreen('<span style="color: red;">ERROR:</span> ' + evt.data); }
function doSend(message) { writeToScreen("SENT: " + message); websocket.send(message); }
function writeToScreen(message) {
var pre = document.createElement("p");
pre.style.wordWrap = "break-word";
pre.innerHTML = message; output.appendChild(pre); }
window.addEventListener("load", init, false);
</script>
<h2>WebSocket Test</h2>
<div id="output"></div>
Loading…
Cancel
Save