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
9fd8d136
Commit
9fd8d136
authored
Aug 25, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added get_password method
parent
48acf09f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
handler.py
webssh/handler.py
+8
-6
No files found.
webssh/handler.py
View file @
9fd8d136
...
@@ -40,9 +40,6 @@ def parse_encoding(data):
...
@@ -40,9 +40,6 @@ def parse_encoding(data):
class
MixinHandler
(
object
):
class
MixinHandler
(
object
):
arguments_required
=
{}
# agruments must be deliverd
empty_allowed
=
{}
# emtpy value alllowed
def
get_value
(
self
,
name
):
def
get_value
(
self
,
name
):
is_required
=
name
in
self
.
arguments_required
is_required
=
name
in
self
.
arguments_required
...
@@ -52,7 +49,7 @@ class MixinHandler(object):
...
@@ -52,7 +49,7 @@ class MixinHandler(object):
if
is_required
:
if
is_required
:
raise
raise
else
:
else
:
if
not
value
and
is_required
and
name
not
in
self
.
empty_allowed
:
if
not
value
and
is_required
:
raise
ValueError
(
'The {} field is required.'
.
format
(
name
))
raise
ValueError
(
'The {} field is required.'
.
format
(
name
))
return
value
return
value
...
@@ -79,7 +76,6 @@ class MixinHandler(object):
...
@@ -79,7 +76,6 @@ class MixinHandler(object):
class
IndexHandler
(
MixinHandler
,
tornado
.
web
.
RequestHandler
):
class
IndexHandler
(
MixinHandler
,
tornado
.
web
.
RequestHandler
):
arguments_required
=
{
'hostname'
,
'port'
,
'username'
,
'password'
}
arguments_required
=
{
'hostname'
,
'port'
,
'username'
,
'password'
}
empty_allowed
=
{
'password'
}
def
initialize
(
self
,
loop
,
policy
,
host_keys_settings
):
def
initialize
(
self
,
loop
,
policy
,
host_keys_settings
):
self
.
loop
=
loop
self
.
loop
=
loop
...
@@ -152,11 +148,17 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
...
@@ -152,11 +148,17 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
raise
ValueError
(
'Invalid port: {}'
.
format
(
value
))
raise
ValueError
(
'Invalid port: {}'
.
format
(
value
))
def
get_password
(
self
):
try
:
return
self
.
get_value
(
'password'
)
except
ValueError
:
return
''
def
get_args
(
self
):
def
get_args
(
self
):
hostname
=
self
.
get_hostname
()
hostname
=
self
.
get_hostname
()
port
=
self
.
get_port
()
port
=
self
.
get_port
()
username
=
self
.
get_value
(
'username'
)
username
=
self
.
get_value
(
'username'
)
password
=
self
.
get_
value
(
'password'
)
password
=
self
.
get_
password
(
)
privatekey
=
self
.
get_privatekey
()
privatekey
=
self
.
get_privatekey
()
pkey
=
self
.
get_pkey_obj
(
privatekey
,
password
,
self
.
filename
)
\
pkey
=
self
.
get_pkey_obj
(
privatekey
,
password
,
self
.
filename
)
\
if
privatekey
else
None
if
privatekey
else
None
...
...
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