Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
616466f4
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,发现更多精彩内容 >>
提交
616466f4
编写于
10月 27, 2016
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'issue946' into develop
上级
19fc718f
8866321a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
6 deletion
+28
-6
glances/__init__.py
glances/__init__.py
+12
-4
glances/main.py
glances/main.py
+2
-0
glances/outputs/glances_bottle.py
glances/outputs/glances_bottle.py
+13
-1
glances/webserver.py
glances/webserver.py
+1
-1
未找到文件。
glances/__init__.py
浏览文件 @
616466f4
...
...
@@ -43,6 +43,7 @@ except ImportError:
# Note: others Glances libs will be imported optionally
from
glances.logger
import
logger
from
glances.main
import
GlancesMain
from
glances.globals
import
WINDOWS
# Check locale
try
:
...
...
@@ -118,7 +119,7 @@ def main():
signal
.
signal
(
signal
.
SIGINT
,
__signal_handler
)
# Glances can be ran in standalone, client or server mode
if
core
.
is_standalone
():
if
core
.
is_standalone
()
and
not
WINDOWS
:
logger
.
info
(
"Start standalone mode"
)
# Import the Glances standalone module
...
...
@@ -131,7 +132,7 @@ def main():
# Start the standalone (CLI) loop
standalone
.
serve_forever
()
elif
core
.
is_client
():
elif
core
.
is_client
()
and
not
WINDOWS
:
if
core
.
is_client_browser
():
logger
.
info
(
"Start client mode (browser)"
)
...
...
@@ -185,15 +186,22 @@ def main():
# Shutdown the server?
server
.
server_close
()
elif
core
.
is_webserver
():
elif
core
.
is_webserver
()
or
(
core
.
is_standalone
()
and
WINDOWS
)
:
logger
.
info
(
"Start web server mode"
)
# Import the Glances web server module
from
glances.webserver
import
GlancesWebServer
args
=
core
.
get_args
()
# Web server mode replace the standalone mode on Windows OS
# In this case, try to start the web browser mode automaticaly
if
core
.
is_standalone
()
and
WINDOWS
:
args
.
open_web_browser
=
True
# Init the web server mode
webserver
=
GlancesWebServer
(
config
=
core
.
get_config
(),
args
=
core
.
get_args
()
)
args
=
args
)
# Start the web server loop
webserver
.
serve_forever
()
glances/main.py
浏览文件 @
616466f4
...
...
@@ -215,6 +215,8 @@ Start the client browser (browser mode):\n\
dest
=
'webserver'
,
help
=
'run Glances in web server mode (bottle needed)'
)
parser
.
add_argument
(
'--cached-time'
,
default
=
self
.
cached_time
,
type
=
int
,
dest
=
'cached_time'
,
help
=
'set the server cache time [default: {} sec]'
.
format
(
self
.
cached_time
))
parser
.
add_argument
(
'--open-web-browser'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'open_web_browser'
,
help
=
'try to open the Web UI in the default Web browser'
)
# Display options
parser
.
add_argument
(
'-q'
,
'--quiet'
,
default
=
False
,
action
=
'store_true'
,
dest
=
'quiet'
,
help
=
'do not display the curses interface'
)
...
...
glances/outputs/glances_bottle.py
浏览文件 @
616466f4
...
...
@@ -24,8 +24,10 @@ import os
import
sys
import
tempfile
from
io
import
open
import
webbrowser
from
glances.timer
import
Timer
from
glances.globals
import
WINDOWS
from
glances.logger
import
logger
try
:
...
...
@@ -117,9 +119,19 @@ class GlancesBottle(object):
self
.
plugins_list
=
self
.
stats
.
getAllPlugins
()
# Bind the Bottle TCP address/port
bindmsg
=
'Glances web server started on http://{}:{}/'
.
format
(
self
.
args
.
bind_address
,
self
.
args
.
port
)
bindurl
=
'http://{}:{}/'
.
format
(
self
.
args
.
bind_address
,
self
.
args
.
port
)
bindmsg
=
'Glances web server started on {}'
.
format
(
bindurl
)
logger
.
info
(
bindmsg
)
print
(
bindmsg
)
if
self
.
args
.
open_web_browser
:
# Implementation of the issue #946
# Try to open the Glances Web UI in the default Web browser if:
# 1) --open-web-browser option is used
# 2) Glances standalone mode is running on Windows OS
webbrowser
.
open
(
bindurl
,
new
=
2
,
autoraise
=
1
)
self
.
_app
.
run
(
host
=
self
.
args
.
bind_address
,
port
=
self
.
args
.
port
,
quiet
=
not
self
.
args
.
debug
)
def
end
(
self
):
...
...
glances/webserver.py
浏览文件 @
616466f4
...
...
@@ -2,7 +2,7 @@
#
# This file is part of Glances.
#
# Copyright (C) 201
5
Nicolargo <nicolas@nicolargo.com>
# Copyright (C) 201
6
Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录