Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
b132a0c0
Commit
b132a0c0
authored
Mar 28, 2016
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use_old_way
parent
edfef582
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
50 deletions
+50
-50
run_server.py
run_server.py
+50
-50
No files found.
run_server.py
View file @
b132a0c0
...
@@ -22,7 +22,7 @@ import tornado.httpclient
...
@@ -22,7 +22,7 @@ import tornado.httpclient
from
tornado.websocket
import
WebSocketClosedError
from
tornado.websocket
import
WebSocketClosedError
from
tornado.options
import
define
,
options
from
tornado.options
import
define
,
options
#
from pyinotify import WatchManager, ProcessEvent, IN_DELETE, IN_CREATE, IN_MODIFY, AsyncNotifier
from
pyinotify
import
WatchManager
,
ProcessEvent
,
IN_DELETE
,
IN_CREATE
,
IN_MODIFY
,
AsyncNotifier
import
select
import
select
from
connect
import
Tty
,
User
,
Asset
,
PermRole
,
logger
,
get_object
,
gen_resource
from
connect
import
Tty
,
User
,
Asset
,
PermRole
,
logger
,
get_object
,
gen_resource
...
@@ -101,41 +101,41 @@ class MyThread(threading.Thread):
...
@@ -101,41 +101,41 @@ class MyThread(threading.Thread):
pass
pass
# class EventHandler(ProcessEvent):
class
EventHandler
(
ProcessEvent
):
# def __init__(self, client=None):
def
__init__
(
self
,
client
=
None
):
# self.client = client
self
.
client
=
client
#
# def process_IN_MODIFY(self, event):
def
process_IN_MODIFY
(
self
,
event
):
# self.client.write_message(f.read())
self
.
client
.
write_message
(
f
.
read
())
#
#
# def file_monitor(path='.', client=None):
# wm = WatchManager()
# mask = IN_DELETE | IN_CREATE | IN_MODIFY
# notifier = AsyncNotifier(wm, EventHandler(client))
# wm.add_watch(path, mask, auto_add=True, rec=True)
# if not os.path.isfile(path):
# logger.debug("File %s does not exist." % path)
# sys.exit(3)
# else:
# logger.debug("Now starting monitor file %s." % path)
# global f
# f = open(path, 'r')
# st_size = os.stat(path)[6]
# f.seek(st_size)
#
# while True:
# try:
# notifier.process_events()
# if notifier.check_events():
# notifier.read_events()
# except KeyboardInterrupt:
# print "keyboard Interrupt."
# notifier.stop()
# break
class
MonitorHandler_old
(
tornado
.
websocket
.
WebSocketHandler
):
def
file_monitor
(
path
=
'.'
,
client
=
None
):
wm
=
WatchManager
()
mask
=
IN_DELETE
|
IN_CREATE
|
IN_MODIFY
notifier
=
AsyncNotifier
(
wm
,
EventHandler
(
client
))
wm
.
add_watch
(
path
,
mask
,
auto_add
=
True
,
rec
=
True
)
if
not
os
.
path
.
isfile
(
path
):
logger
.
debug
(
"File
%
s does not exist."
%
path
)
sys
.
exit
(
3
)
else
:
logger
.
debug
(
"Now starting monitor file
%
s."
%
path
)
global
f
f
=
open
(
path
,
'r'
)
st_size
=
os
.
stat
(
path
)[
6
]
f
.
seek
(
st_size
)
while
True
:
try
:
notifier
.
process_events
()
if
notifier
.
check_events
():
notifier
.
read_events
()
except
KeyboardInterrupt
:
print
"keyboard Interrupt."
notifier
.
stop
()
break
class
MonitorHandler
(
tornado
.
websocket
.
WebSocketHandler
):
clients
=
[]
clients
=
[]
threads
=
[]
threads
=
[]
...
@@ -442,22 +442,22 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
...
@@ -442,22 +442,22 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
pass
pass
class
MonitorHandler
(
WebTerminalHandler
):
#
class MonitorHandler(WebTerminalHandler):
@django_request_support
#
@django_request_support
@require_auth
(
'user'
)
#
@require_auth('user')
def
open
(
self
):
#
def open(self):
try
:
#
try:
self
.
returnlog
=
TermLogRecorder
.
loglist
[
self
.
get_argument
(
'id'
)]
#
self.returnlog = TermLogRecorder.loglist[self.get_argument('id')]
self
.
returnlog
.
write_message
=
self
.
write_message
#
self.returnlog.write_message = self.write_message
except
:
#
except:
self
.
write_message
(
'Log is None'
)
#
self.write_message('Log is None')
self
.
close
()
#
self.close()
#
def
on_message
(
self
,
message
):
#
def on_message(self, message):
pass
#
pass
#
def
on_close
(
self
):
#
def on_close(self):
self
.
close
()
#
self.close()
class
Application
(
tornado
.
web
.
Application
):
class
Application
(
tornado
.
web
.
Application
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment