Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webssh
Overview
Overview
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
郑天保
webssh
Commits
9b38d111
Commit
9b38d111
authored
Aug 26, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use class attribute formater
parent
b69bdefc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
handler.py
webssh/handler.py
+5
-3
No files found.
webssh/handler.py
View file @
9b38d111
...
...
@@ -44,6 +44,8 @@ class InvalidException(Exception):
class
MixinHandler
(
object
):
formater
=
'Missing value {}'
def
write_error
(
self
,
status_code
,
**
kwargs
):
exc_info
=
kwargs
.
get
(
'exc_info'
)
if
exc_info
and
len
(
exc_info
)
>
1
:
...
...
@@ -52,10 +54,10 @@ class MixinHandler(object):
self
.
_reason
=
info
.
split
(
':'
,
1
)[
-
1
]
.
strip
()
super
(
MixinHandler
,
self
)
.
write_error
(
status_code
,
**
kwargs
)
def
get_value
(
self
,
name
,
formater
=
'Missing value {}'
):
def
get_value
(
self
,
name
):
value
=
self
.
get_argument
(
name
)
if
not
value
:
raise
InvalidException
(
formater
.
format
(
name
))
raise
InvalidException
(
self
.
formater
.
format
(
name
))
return
value
def
get_real_client_addr
(
self
):
...
...
@@ -262,7 +264,7 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler):
self
.
src_addr
=
self
.
get_client_addr
()
logging
.
info
(
'Connected from {}:{}'
.
format
(
*
self
.
src_addr
))
try
:
worker_id
=
self
.
get_value
(
'id'
,
formater
=
self
.
formater
)
worker_id
=
self
.
get_value
(
'id'
)
except
(
tornado
.
web
.
MissingArgumentError
,
InvalidException
)
as
exc
:
self
.
close
(
reason
=
str
(
exc
)
.
split
(
':'
,
1
)[
-
1
]
.
strip
())
else
:
...
...
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