def main(): """Main entry point for Glances. Select the mode (standalone, client or server) Run it... """ # Log Glances and PSutil version logger.info('Start Glances {}'.format(__version__)) logger.info('{} {} and PSutil {} detected'.format( platform.python_implementation(), platform.python_version(), psutil_version)) # Share global var global core # Create the Glances main instance core = GlancesMain() config = core.get_config() args = core.get_args() # Catch the CTRL-C signal signal.signal(signal.SIGINT, __signal_handler) # Glances can be ran in standalone, client or server mode if core.is_standalone() and not WINDOWS: start_standalone(config=config, args=args) elif core.is_client() and not WINDOWS: if core.is_client_browser(): start_clientbrowser(config=config, args=args) else: start_client(config=config, args=args) elif core.is_server(): start_server(config=config, args=args) elif core.is_webserver() or (core.is_standalone() and WINDOWS): # 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 start_webserver(config=config, args=args)
# You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """Glances unitary tests suite.""" import sys import time import unittest # Global variables # ================= # Init Glances core from glances.main import GlancesMain core = GlancesMain() if not core.is_standalone(): print('ERROR: Glances core should be ran in standalone mode') sys.exit(1) # Init Glances stats from glances.stats import GlancesStats stats = GlancesStats() from glances import __version__ from glances.globals import WINDOWS, LINUX from glances.outputs.glances_bars import Bar # Unitest class # ============== print('Unitary tests for Glances %s' % __version__)
def main(): """Main entry point for Glances. Select the mode (standalone, client or server) Run it... """ # Log Glances and PSutil version logger.info('Start Glances {0}'.format(__version__)) logger.info('{0} {1} and PSutil {2} detected'.format( platform.python_implementation(), platform.python_version(), __psutil_version)) # Share global var global core, standalone, client, server, webserver # Create the Glances main instance core = GlancesMain() # Catch the CTRL-C signal signal.signal(signal.SIGINT, __signal_handler) # Glances can be ran in standalone, client or server mode if core.is_standalone(): logger.info("Start standalone mode") # Import the Glances standalone module from glances.standalone import GlancesStandalone # Init the standalone mode standalone = GlancesStandalone(config=core.get_config(), args=core.get_args()) # Start the standalone (CLI) loop standalone.serve_forever() elif core.is_client(): if core.is_client_browser(): logger.info("Start client mode (browser)") # Import the Glances client browser module from glances.client_browser import GlancesClientBrowser # Init the client client = GlancesClientBrowser(config=core.get_config(), args=core.get_args()) else: logger.info("Start client mode") # Import the Glances client module from glances.client import GlancesClient # Init the client client = GlancesClient(config=core.get_config(), args=core.get_args()) # Test if client and server are in the same major version if not client.login(): logger.critical( "The server version is not compatible with the client") sys.exit(2) # Start the client loop client.serve_forever() # Shutdown the client client.end() elif core.is_server(): logger.info("Start server mode") # Import the Glances server module from glances.server import GlancesServer args = core.get_args() server = GlancesServer(cached_time=core.cached_time, config=core.get_config(), args=args) print('Glances server is running on {0}:{1}'.format( args.bind_address, args.port)) # Set the server login/password (if -P/--password tag) if args.password != "": server.add_user(args.username, args.password) # Start the server loop server.serve_forever() # Shutdown the server? server.server_close() elif core.is_webserver(): logger.info("Start web server mode") # Import the Glances web server module from glances.webserver import GlancesWebServer # Init the web server mode webserver = GlancesWebServer(config=core.get_config(), args=core.get_args()) # Start the web server loop webserver.serve_forever()
def main(): """Main entry point for Glances. Select the mode (standalone, client or server) Run it... """ # Log Glances and PSutil version logger.info('Start Glances {0}'.format(__version__)) logger.info('{0} {1} and PSutil {2} detected'.format( platform.python_implementation(), platform.python_version(), psutil_version)) # Share global var global core, standalone, client, server, webserver # Create the Glances main instance core = GlancesMain() # Catch the CTRL-C signal signal.signal(signal.SIGINT, __signal_handler) # Glances can be ran in standalone, client or server mode if core.is_standalone(): logger.info("Start standalone mode") # Import the Glances standalone module from glances.standalone import GlancesStandalone # Init the standalone mode standalone = GlancesStandalone(config=core.get_config(), args=core.get_args()) # Start the standalone (CLI) loop standalone.serve_forever() elif core.is_client(): if core.is_client_browser(): logger.info("Start client mode (browser)") # Import the Glances client browser module from glances.client_browser import GlancesClientBrowser # Init the client client = GlancesClientBrowser(config=core.get_config(), args=core.get_args()) else: logger.info("Start client mode") # Import the Glances client module from glances.client import GlancesClient # Init the client client = GlancesClient(config=core.get_config(), args=core.get_args()) # Test if client and server are in the same major version if not client.login(): logger.critical("The server version is not compatible with the client") sys.exit(2) # Start the client loop client.serve_forever() # Shutdown the client client.end() elif core.is_server(): logger.info("Start server mode") # Import the Glances server module from glances.server import GlancesServer args = core.get_args() server = GlancesServer(cached_time=core.cached_time, config=core.get_config(), args=args) print('Glances server is running on {0}:{1}'.format(args.bind_address, args.port)) # Set the server login/password (if -P/--password tag) if args.password != "": server.add_user(args.username, args.password) # Start the server loop server.serve_forever() # Shutdown the server? server.server_close() elif core.is_webserver(): logger.info("Start web server mode") # Import the Glances web server module from glances.webserver import GlancesWebServer # Init the web server mode webserver = GlancesWebServer(config=core.get_config(), args=core.get_args()) # Start the web server loop webserver.serve_forever()