| @@ 50-66 (lines=17) @@ | ||
| 47 | ret = requests.get(url, headers={'Accept-encoding': 'identity'}) |
|
| 48 | return ret |
|
| 49 | ||
| 50 | def test_000_start_server(self): |
|
| 51 | """Start the Glances Web Server.""" |
|
| 52 | global pid |
|
| 53 | ||
| 54 | print('INFO: [TEST_000] Start the Glances Web Server API') |
|
| 55 | if os.path.isfile('./venv/bin/python'): |
|
| 56 | cmdline = "./venv/bin/python" |
|
| 57 | else: |
|
| 58 | cmdline = "python" |
|
| 59 | cmdline += f" -m glances -B 0.0.0.0 -w -p {SERVER_PORT} --disable-webui -C ./conf/glances.conf" |
|
| 60 | print(f"Run the Glances Web Server on port {SERVER_PORT}") |
|
| 61 | args = shlex.split(cmdline) |
|
| 62 | pid = subprocess.Popen(args) |
|
| 63 | print("Please wait 5 seconds...") |
|
| 64 | time.sleep(5) |
|
| 65 | ||
| 66 | self.assertTrue(pid is not None) |
|
| 67 | ||
| 68 | def test_001_all(self): |
|
| 69 | """All.""" |
|
| @@ 51-67 (lines=17) @@ | ||
| 48 | """The function is called *every time* before test_*.""" |
|
| 49 | print('\n' + '=' * 78) |
|
| 50 | ||
| 51 | def test_000_start_server(self): |
|
| 52 | """Start the Glances Web Server.""" |
|
| 53 | global pid |
|
| 54 | ||
| 55 | print('INFO: [TEST_000] Start the Glances Web Server') |
|
| 56 | if os.path.isfile('./venv/bin/python'): |
|
| 57 | cmdline = "./venv/bin/python" |
|
| 58 | else: |
|
| 59 | cmdline = "python" |
|
| 60 | cmdline += f" -m glances -B localhost -s -p {SERVER_PORT}" |
|
| 61 | print(f"Run the Glances Server on port {SERVER_PORT}") |
|
| 62 | args = shlex.split(cmdline) |
|
| 63 | pid = subprocess.Popen(args) |
|
| 64 | print("Please wait...") |
|
| 65 | time.sleep(1) |
|
| 66 | ||
| 67 | self.assertTrue(pid is not None) |
|
| 68 | ||
| 69 | def test_001_all(self): |
|
| 70 | """All.""" |
|