Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
427d7034
G
glances
项目概览
蜕变的菜鸟
/
glances
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glances
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
427d7034
编写于
1月 03, 2014
作者:
A
Alessio Sergi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix password flags handling [issues #314 & #315]
上级
a38183e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
8 deletion
+17
-8
glances/glances.py
glances/glances.py
+17
-8
未找到文件。
glances/glances.py
浏览文件 @
427d7034
...
...
@@ -4478,7 +4478,7 @@ def signal_handler(signal, frame):
end
()
def
getpassword
(
description
=
''
,
confirm
=
False
):
def
get
_
password
(
description
=
''
,
confirm
=
False
):
"""
Read a password from the command line (with confirmation if confirm = True)
"""
...
...
@@ -4497,7 +4497,7 @@ def getpassword(description='', confirm=False):
return
password1
else
:
sys
.
stdout
.
write
(
_
(
"[Warning] Passwords did not match, please try again...
\n
"
))
return
getpassword
(
description
=
description
,
confirm
=
confirm
)
return
get
_
password
(
description
=
description
,
confirm
=
confirm
)
def
main
():
...
...
@@ -4528,6 +4528,8 @@ def main():
html_tag
=
False
csv_tag
=
False
client_tag
=
False
password_tag
=
False
password_prompt
=
False
if
is_Windows
and
not
is_colorConsole
:
# Force server mode for Windows OS without colorconsole
server_tag
=
True
...
...
@@ -4574,13 +4576,16 @@ def main():
sys
.
exit
(
0
)
elif
opt
in
(
"-s"
,
"--server"
):
server_tag
=
True
elif
opt
in
(
"-P"
,
"--password"
):
elif
opt
in
(
"-P"
):
try
:
arg
except
NameError
:
print
(
_
(
"Error: -P flag need an argument (password)"
))
sys
.
exit
(
2
)
password_tag
=
True
password
=
arg
elif
opt
in
(
"--password"
):
password_prompt
=
True
elif
opt
in
(
"-B"
,
"--bind"
):
try
:
arg
...
...
@@ -4654,6 +4659,10 @@ def main():
sys
.
exit
(
0
)
# Check options
if
password_tag
and
password_prompt
:
print
(
_
(
"Error: Cannot use both -P and --password flag"
))
sys
.
exit
(
2
)
if
server_tag
:
if
client_tag
:
print
(
_
(
"Error: Cannot use both -s and -c flag"
))
...
...
@@ -4661,8 +4670,8 @@ def main():
if
html_tag
or
csv_tag
:
print
(
_
(
"Error: Cannot use both -s and -o flag"
))
sys
.
exit
(
2
)
if
password
==
''
:
password
=
getpassword
(
description
=
_
(
"Define the password for the Glances server"
),
confirm
=
True
)
if
password
_prompt
:
password
=
get
_
password
(
description
=
_
(
"Define the password for the Glances server"
),
confirm
=
True
)
if
client_tag
:
if
html_tag
or
csv_tag
:
...
...
@@ -4672,8 +4681,8 @@ def main():
print
(
_
(
"Error: Cannot use both -c and -C flag"
))
print
(
_
(
" Limits are set based on the server ones"
))
sys
.
exit
(
2
)
if
password
==
''
:
password
=
getpassword
(
description
=
_
(
"Enter the Glances server password"
),
confirm
=
False
)
if
password
_prompt
:
password
=
get
_
password
(
description
=
_
(
"Enter the Glances server password"
),
confirm
=
False
)
if
html_tag
:
if
not
html_lib_tag
:
...
...
@@ -4724,7 +4733,7 @@ def main():
print
(
_
(
"Glances server is running on"
)
+
" %s:%s"
%
(
bind_ip
,
server_port
))
server
=
GlancesServer
(
bind_ip
,
int
(
server_port
),
GlancesXMLRPCHandler
,
cached_time
)
# Set the server login/password (if -P tag)
# Set the server login/password (if -P
/--password
tag)
if
password
!=
""
:
server
.
add_user
(
username
,
password
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录