mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-16 16:01:35 +00:00
test websocket
This commit is contained in:
parent
969d54050f
commit
5b2911a5ed
@ -121,6 +121,7 @@ def connect(host, port, user, password):
|
|||||||
log_date_dir = '%s/%s' % (log_dir, time.strftime('%Y%m%d'))
|
log_date_dir = '%s/%s' % (log_dir, time.strftime('%Y%m%d'))
|
||||||
if not os.path.isdir(log_date_dir):
|
if not os.path.isdir(log_date_dir):
|
||||||
os.mkdir(log_date_dir)
|
os.mkdir(log_date_dir)
|
||||||
|
os.chmod(log_date_dir, 0777)
|
||||||
structtime_start = time.localtime()
|
structtime_start = time.localtime()
|
||||||
datetime_start = time.strftime('%Y%m%d%H%M%S', structtime_start)
|
datetime_start = time.strftime('%Y%m%d%H%M%S', structtime_start)
|
||||||
logtime_start = time.strftime('%Y/%m/%d %H:%M:%S', structtime_start)
|
logtime_start = time.strftime('%Y/%m/%d %H:%M:%S', structtime_start)
|
||||||
|
@ -21,7 +21,10 @@ import paramiko
|
|||||||
from django.core.servers.basehttp import FileWrapper
|
from django.core.servers.basehttp import FileWrapper
|
||||||
from AutoSa.settings import CONF_DIR
|
from AutoSa.settings import CONF_DIR
|
||||||
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
||||||
import time, datetime
|
import time
|
||||||
|
import datetime
|
||||||
|
from django_websocket import require_websocket
|
||||||
|
from django_websocket import accept_websocket
|
||||||
|
|
||||||
|
|
||||||
cf = ConfigParser.ConfigParser()
|
cf = ConfigParser.ConfigParser()
|
||||||
@ -1001,6 +1004,23 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user