repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
XX-Net
code/default/smart_router/local/pac_server.py
.py
#!/usr/bin/env python # coding:utf-8 import os try: from urllib.parse import urlparse except ImportError: from urlparse import urlparse import simple_http_server import env_info from . import global_var as g from xlog import getLogger xlog = getLogger("smart_router") import utils current_path = os.path.dirn...
102
3,471
XX-Net
code/default/smart_router/local/global_var.py
.py
running = True gae_proxy = None x_tunnel = None config = None ip_region = None gfwlist = None domain_cache = None ip_cache = None user_rules = None connect_manager = None pipe_socks = None dns_client = None proxy_server = None dns_srv = None dns_query = None gae_proxy_listen_port = None x_tunnel_socks_port = None...
24
335
XX-Net
code/default/smart_router/local/web_control.py
.py
#!/usr/bin/env python # coding:utf-8 import os try: from urllib.parse import urlparse, parse_qs except ImportError: from urlparse import urlparse, parse_qs from xlog import getLogger xlog = getLogger("smart_router") import simple_http_server from . import pac_server from . import global_var as g current_pa...
163
5,572
XX-Net
code/default/smart_router/local/host_records.py
.py
import os import threading import time import collections from . import global_var as g import utils from xlog import getLogger xlog = getLogger("smart_router") def is_network_ok(ip): if not g.gae_proxy: return False return g.gae_proxy.check_local_network.is_ok(ip) class DomainRecords(object): ...
380
11,053
XX-Net
code/default/smart_router/local/apis.py
.py
from . import global_var as g from . import connect_manager from xlog import getLogger xlog = getLogger("smart_router") def set_proxy(args): xlog.info("set_proxy:%s", args) g.config.PROXY_ENABLE = args["enable"] g.config.PROXY_TYPE = args["type"] g.config.PROXY_HOST = args["host"] try: g...
33
714
XX-Net
code/default/smart_router/local/smart_route.py
.py
import time import socket import struct import io import ssl try: from urllib.parse import urlparse except ImportError: from urlparse import urlparse import utils import simple_http_server from .socket_wrap import SocketWrap from . import global_var as g import socks from xlog import getLogger xlog = getLogg...
634
19,732
XX-Net
code/default/smart_router/local/user_rules.py
.py
#!/usr/bin/env python # coding:utf-8 import os current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) import env_info import utils from xlog import getLogger xlog = getLogger("smart_router") data_path = os.path.join(env_info.data_path...
138
4,123
XX-Net
code/default/smart_router/tests/test_dns_query.py
.py
import json import time from unittest import TestCase import os import sys import requests current_path = os.path.dirname(os.path.abspath(__file__)) default_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) noarch_path = os.path.abspath(os.path.join(default_path, 'lib', "noarch")) sys.path.appe...
75
2,355
XX-Net
code/default/smart_router/tests/test_black_list.py
.py
import os from os.path import join import sys import unittest current_path = os.path.dirname(os.path.abspath(__file__)) smart_route_path = os.path.abspath(os.path.join(current_path, os.path.pardir)) local_path = os.path.join(smart_route_path, "local") sys.path.append(local_path) default_path = os.path.abspath(join(s...
41
1,141
XX-Net
code/default/smart_router/tests/test_set_policy.py
.py
import requests import re from unittest import TestCase class TestSetPolicy(TestCase): def test_set_global(self): url = "http://localhost:8085/module/smart_router/control/config" headers = { "Content-Type": "application/json" } data = { "cmd": "set", ...
46
1,222
XX-Net
code/default/smart_router/scripts/update_domain_list.py
.py
import os import sys from os.path import join current_path = os.path.dirname(os.path.abspath(__file__)) local_path = os.path.abspath( os.path.join(current_path, os.pardir, "local")) root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) noarch_path = join(root_path, "lib", "noarch") sys.path.app...
64
1,958
XX-Net
code/default/gae_proxy/server/gae/main.py
.py
import os import time from datetime import timedelta, datetime, tzinfo import struct import zlib import logging from urllib.parse import urlparse import http.client as httplib import json import threading import re import psutil import flask from flask import Flask, request import requests from google.cloud import st...
520
16,697
XX-Net
code/default/gae_proxy/server/gae/gunicorn.conf.py
.py
# Recommended number of workers based on instance size: # https://cloud.google.com/appengine/docs/standard/python3/runtime#entrypoint_best_practices threads = 20 # Use an asynchronous worker as most of the work is waiting for websites to load worker_class = 'gthread'
5
267
XX-Net
code/default/gae_proxy/local/check_local_network.py
.py
import sys import os import time import threading current_path = os.path.dirname(os.path.abspath(__file__)) if __name__ == "__main__": python_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) noarch_lib ...
218
6,688
XX-Net
code/default/gae_proxy/local/proxy_handler.py
.py
#!/usr/bin/env python # coding:utf-8 """ GAEProxyHandler is the handler of http proxy port. default to 8087 if HTTP request: do_METHOD() elif HTTPS request: do_CONNECT() What is Direct mode: if user access google site like www.google.com, client.google.com, we don't need forward re...
339
12,960
XX-Net
code/default/gae_proxy/local/gae_handler.py
.py
#!/usr/bin/env python # coding:utf-8 """ GoAgent local-server protocol 3.2 request: POST /_gh/ HTTP/1.1 HOST: appid.appspot.com content-length: xxx http content: 此为body { pack_req_head_len: 2 bytes,#POST 时使用 pack_req_head : deflate{ 此为负载 original request line, original reque...
1,019
37,754
XX-Net
code/default/gae_proxy/local/sni_manager.py
.py
import random import os from front_base.random_get_slice import RandomGetSlice current_path = os.path.dirname(os.path.abspath(__file__)) class SniManager(object): plus = ['-', '', "."] end = ["com", "net", "ml", "org", "us"] def __init__(self, logger): self.logger = logger fn = os.path....
33
715
XX-Net
code/default/gae_proxy/local/host_manager.py
.py
import time from front_base.connect_manager import NoRescourceException from front_base.host_manager import HostManagerBase from . sni_manager import SniManager class HostManager(HostManagerBase): def __init__(self, config, logger): self.config = config self.logger = logger self.appid_man...
34
811
XX-Net
code/default/gae_proxy/local/__init__.py
.py
from . import apis from . import web_control from . import proxy def is_ready(): return proxy.ready def start(args): proxy.main(args) def stop(): proxy.terminate()
17
183
XX-Net
code/default/gae_proxy/local/front.py
.py
import os current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) import env_info data_path = env_info.data_path module_data_path = os.path.join(data_path, 'gae_proxy') import xlog logger = xlog.getLogger("gae_proxy", log_path=module_dat...
184
6,073
XX-Net
code/default/gae_proxy/local/download_gae_lib.py
.py
import os import time import zipfile import shutil import simple_http_client import env_info from xlog import getLogger xlog = getLogger("gae_proxy") current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) top_path = os.path.abspath(os.p...
135
4,052
XX-Net
code/default/gae_proxy/local/check_ip.py
.py
#!/usr/bin/env python2 # coding:utf-8 import sys import os import threading current_path = os.path.dirname(os.path.abspath(__file__)) default_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) if __name__ == "__main__": sys.path.append(default_path) noarch_lib = os.path.abspath(os.path...
200
6,194
XX-Net
code/default/gae_proxy/local/web_control.py
.py
#!/usr/bin/env python # coding:utf-8 import platform import json import os import re import subprocess import sys import datetime import locale import time import hashlib import ssl try: from urllib.parse import urlparse, parse_qs except ImportError: from urlparse import urlparse, parse_qs import simple...
785
29,860
XX-Net
code/default/gae_proxy/local/proxy.py
.py
#!/usr/bin/env python2 # coding:utf-8 # Based on GAppProxy 2.0.0 by Du XiaoGang <dugang.2008@gmail.com> # Based on WallProxy 0.4.0 by Hust Moon <www.ehust@gmail.com> # Contributor: # Phus Lu <phus.lu@gmail.com> # Hewig Xu <hewigovens@gmail.com> # Ayanamist Yang <ayanamist@gmail.com>...
169
5,376
XX-Net
code/default/gae_proxy/local/cert_util.py
.py
#!/usr/bin/env python # coding:utf-8 import os import sys import glob import time import random import base64 import threading import subprocess import datetime try: import OpenSSL except: pass current_path = os.path.dirname(os.path.abspath(__file__)) python_path = os.path.abspath( os.path.join(current_path,...
586
24,217
XX-Net
code/default/gae_proxy/local/http2_connection.py
.py
from front_base.http2_connection import Http2Worker class GaeHttp2Worker(Http2Worker): def __init__(self, logger, ip_manager, config, ssl_sock, close_cb, retry_task_cb, idle_cb, log_debug_data, stream_class=None): super(GaeHttp2Worker, self).__init__(logger, ip_manager, config, ssl_sock,...
12
485
XX-Net
code/default/gae_proxy/local/direct_handler.py
.py
#!/usr/bin/env python # coding:utf-8 import time import re import socket import ssl import errno try: import OpenSSL NetWorkIOError = (socket.error, ssl.SSLError, OpenSSL.SSL.Error, OSError) except: NetWorkIOError = (socket.error, ssl.SSLError, OSError) from .gae_handler import send_header, return_fail...
105
3,732
XX-Net
code/default/gae_proxy/local/config.py
.py
import os from front_base.config import ConfigBase import utils import env_info current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir)) module_data_path = os.path.join(env_info.data_path, 'gae_proxy') headers = {"connection": "close"} ...
568
20,905
XX-Net
code/default/gae_proxy/local/apis.py
.py
from .front import front, direct_front from xlog import getLogger xlog = getLogger("gae_proxy") def set_proxy(args): front.set_proxy(args) direct_front.set_proxy(args) def _count_conn_num(): return len(front.connect_manager.new_conn_pool.pool) +\ front.http_dispatcher.h1_num + \ f...
34
700
XX-Net
code/default/gae_proxy/local/appid_manager.py
.py
#!/usr/bin/env python # coding:utf-8 import random import threading import time import os from front_base.random_get_slice import RandomGetSlice current_path = os.path.dirname(os.path.abspath(__file__)) class AppidManager(object): lock = threading.Lock() def __init__(self, config, logger): self.co...
113
3,681
XX-Net
code/default/gae_proxy/local/ipv6_tunnel/win32runas.py
.py
# coding:utf-8 # run as admin in Windows import os import sys import ctypes import subprocess from ctypes import c_ulong, c_char_p, c_int, c_void_p from ctypes.wintypes import HANDLE, DWORD, HWND, HINSTANCE, HKEY def is_admin(): try: return ctypes.windll.shell32.IsUserAnAdmin() except: return...
93
3,072
XX-Net
code/default/gae_proxy/local/ipv6_tunnel/__init__.py
.py
import sys import platform from .common import test_teredo if "arm" in platform.machine(): from .unknown import state, state_pp, switch_pp, enable, disable, set_best_server elif sys.platform == "win32": from .win10 import state, state_pp, switch_pp, enable, disable, set_best_server elif sys.platform.startswi...
17
625
XX-Net
code/default/gae_proxy/local/ipv6_tunnel/pteredor.py
.py
#!/usr/bin/env python # coding:utf-8 # A tool to help evaluate the teredo servers. # Thanks XndroidDev # Author: SeaHOH <seahoh@gmail.com> # Compatible: Python 2.7 & 3.4 & 3.5 & 3.6 # References: # https://tools.ietf.org/html/rfc4380 5.1 5.2 # https://tools.ietf.org/html/rfc4861 4.1 4.2 # https://tools.ietf.org/...
647
22,519
XX-Net
code/default/gae_proxy/local/ipv6_tunnel/win10.py
.py
#!/usr/bin/env python2 # coding:utf-8 import os import sys import time import socket import platform import env_info from .common import * from . import win32runas from .pteredor import local_ip_startswith current_path = os.path.dirname(os.path.abspath(__file__)) python_path = os.path.abspath( os.path.join(current_p...
294
8,072
XX-Net
code/default/gae_proxy/local/ipv6_tunnel/win_reset_gp.py
.py
# coding:utf-8 import os import sys import platform import ctypes import win32runas def win32_notify( msg='msg', title='Title'): res = ctypes.windll.user32.MessageBoxW(None, msg, title, 1) # Yes:1 No:2 return res == 1 def reset_teredo(): gp_split = b'[\x00' gp_teredo = 'v6Transition\x00;Teredo'...
57
1,588
XX-Net
code/default/gae_proxy/local/ipv6_tunnel/common.py
.py
import os import shlex import subprocess from .pteredor import teredo_prober import env_info import utils from xlog import getLogger xlog = getLogger("gae_proxy") current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir, os.pardir)) data_pat...
158
4,037
XX-Net
code/default/gae_proxy/local/ipv6_tunnel/darwin.py
.py
#!/usr/bin/env python2 # coding:utf-8 import os import sys from .common import * def state(): return "Developing" def state_pp(): return "Developing" def switch_pp(): return "Developing" def enable(is_local=False): return "Developing" def disable(is_local=False): return "Developing" def...
31
378
XX-Net
code/default/gae_proxy/tests/test_protocol.py
.py
from unittest import TestCase import os import sys from os.path import join import http.client as httplib import json import struct import zlib import traceback import requests import logging logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.DEBUG) logger = logging.getLogger('simple_example') logge...
291
9,326
XX-Net
code/default/launcher/win_tray.py
.py
#!/usr/bin/env python # coding:utf-8 if __name__ == "__main__": import os, sys current_path = os.path.dirname(os.path.abspath(__file__)) python_path = os.path.abspath(os.path.join(current_path, os.pardir)) noarch_lib = os.path.abspath(os.path.join(python_path, 'lib', 'noarch')) sys.path.append(noa...
201
7,743
XX-Net
code/default/launcher/sys_platform.py
.py
import sys import os from xlog import getLogger xlog = getLogger("launcher") current_path = os.path.dirname(os.path.abspath(__file__)) default_path = os.path.abspath(os.path.join(current_path, os.pardir)) import global_var if sys.platform.startswith("linux"): if os.path.isfile("/system/bin/dalvikvm") or os.p...
163
4,173
XX-Net
code/default/launcher/setup.py
.py
#!/usr/bin/env python from config import config import os import re import shutil import subprocess import sys import time import zipfile try: from urllib.request import build_opener, ProxyHandler except ImportError: from urllib2 import build_opener, ProxyHandler import env_info from xlog import getLogger xl...
167
5,190
XX-Net
code/default/launcher/non_tray.py
.py
#!/usr/bin/env python # coding:utf-8 import os import time import global_var class None_tray(): def notify_general(self, msg="msg", title="Title", buttons={}, timeout=3600): pass def on_quit(self, widget=None, data=None): import module_init global_var.running = False module...
35
556
XX-Net
code/default/launcher/start.py
.py
#!/usr/bin/env python3 # coding:utf-8 import platform import os import sys import time import traceback import atexit # reduce resource request for threading # for OpenWrt import threading try: threading.stack_size(64 * 1024) except: pass current_path = os.path.dirname(os.path.abspath(__file__)) sys.path.ap...
199
5,573
XX-Net
code/default/launcher/update_from_github.py
.py
import os import sys import time import subprocess import threading import re import zipfile import shutil import stat import glob current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir)) top_path = os.path.abspath(os.path.join(root_path, os.pardir, o...
496
16,285
XX-Net
code/default/launcher/update.py
.py
#!/usr/bin/env python # coding:utf-8 import os, stat import json import time import threading import zipfile import sys import platform import uuid try: from urllib.request import build_opener, HTTPSHandler, ProxyHandler except ImportError: from urllib2 import build_opener, HTTPSHandler, ProxyHandler try: ...
447
14,596
XX-Net
code/default/launcher/web_control.py
.py
#!/usr/bin/env python # coding:utf-8 import os, sys import errno import re import socket, ssl import time import threading import json import cgi import traceback import base64 try: from urllib.parse import urlparse, urlencode, parse_qs from urllib.request import urlopen, Request from urllib.error import ...
1,153
44,825
XX-Net
code/default/launcher/module_init.py
.py
import subprocess import threading import os import sys from config import config from xlog import getLogger xlog = getLogger("launcher") import web_control import time proc_handler = {} xargs = {} current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pa...
151
4,512
XX-Net
code/default/launcher/mac_tray.py
.py
#!/usr/bin/env python3 # coding:utf-8 import os import shutil import sys current_path = os.path.dirname(os.path.abspath(__file__)) helper_path = os.path.join('/tmp', 'helper') if __name__ == "__main__": default_path = os.path.abspath(os.path.join(current_path, os.pardir)) noarch_lib = os.path.abspath(os.path...
480
19,458
XX-Net
code/default/launcher/simple_i18n.py
.py
import os import sys import utils from config import get_language from xlog import getLogger xlog = getLogger("launcher") class SimpleI18N(object): def __init__(self): self.lang = get_language() xlog.debug("lang: %s", self.lang) self.base_po_dict = {} def add_translate(self, key, va...
146
3,964
XX-Net
code/default/launcher/gtk_tray.py
.py
#!/usr/bin/env python # coding:utf-8 # Contributor: # Phus Lu <phus.lu@gmail.com> import os import sys import webbrowser from config import config, app_name from xlog import getLogger xlog = getLogger("launcher") current_path = os.path.dirname(os.path.abspath(__file__)) if __name__ == "__main__": py...
204
6,150
XX-Net
code/default/launcher/post_update.py
.py
import os import shutil current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir)) top_path = os.path.abspath(os.path.join(root_path, os.pardir, os.pardir)) from xlog import getLogger xlog = getLogger("launcher") from config import config def check()...
36
1,040
XX-Net
code/default/launcher/download_modules.py
.py
import os import threading import time import zipfile import shutil from update_from_github import request, xlog, hash_file_sum import env_info current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir)) top_path = os.path.abspath(os.path.join(root_path,...
145
4,717
XX-Net
code/default/launcher/config.py
.py
#!/usr/bin/env python import os import subprocess import locale import json import sys_platform from simple_http_client import request import xconfig from xlog import getLogger xlog = getLogger("launcher") current_path = os.path.dirname(os.path.abspath(__file__)) version_path = os.path.abspath(os.path.join(current_p...
169
4,922
XX-Net
code/default/launcher/autorun.py
.py
#!/usr/bin/env python """A simple crossplatform autostart helper""" import os import sys from config import app_name from xlog import getLogger xlog = getLogger("launcher") current_path = os.path.dirname(os.path.abspath(__file__)) root_path = os.path.abspath(os.path.join(current_path, os.pardir)) top_path = os.path...
182
4,676
XX-Net
code/default/launcher/win_compat_suggest.py
.py
# coding:utf-8 import json import os import ctypes import collections import locale import subprocess import env_info from launcher.config import get_language from config import app_name, config from xlog import getLogger xlog = getLogger("launcher") current_path = os.path.dirname(os.path.abspath(__file__)) version_p...
299
9,816
XX-Net
code/default/launcher/tests/try_smartroute_sock4.py
.py
import simple_http_client def smart_route_proxy_socks4(): proxy = "socks4://localhost:8086" res = simple_http_client.request("GET", "https://github.com/", proxy=proxy, timeout=1000) return res if __name__ == "__main__": smart_route_proxy_socks4()
12
267
XX-Net
code/default/launcher/tests/test_win_port_reserve.py
.py
from unittest import TestCase import sys from launcher.win_compat_suggest import Win10PortReserveSolution empty_output = [ b'\r\n', b'Protocol tcp Port Exclusion Ranges\r\n', b'\r\n', b'Start Port End Port \r\n', b'---------- -------- \r\n', b'\r\n', b'* - Administered port...
57
1,264
XX-Net
code/default/launcher/tests/test_update.py
.py
import os.path import unittest import tempfile import os from launcher.update_from_github import download_file class UpdateTest(unittest.TestCase): def test_download(self): tp = tempfile.gettempdir() fn = os.path.join(tp, "v4.txt") res = download_file("https://raw.githubusercontent.com/XX...
17
403
XX-Net
code/default/launcher/tests/test_web_api.py
.py
from unittest import TestCase import json import simple_http_client class TestAPi(TestCase): def setUp(self): self.base_url = "http://localhost:8085" def test_set_proxy_applist(self): url = self.base_url + "/set_proxy_applist" headers = { "Content-Type": "application/json...
26
627
XX-Net
code/default/launcher/tests/try_run.py
.py
import logging import sys import os from subprocess import Popen, PIPE, STDOUT from logging import getLogger xlog = getLogger("test") xlog.setLevel(logging.DEBUG) current_path = os.path.dirname(os.path.abspath(__file__)) default_path = os.path.abspath(os.path.join(current_path, os.path.pardir, os.path.pardir)) clas...
39
1,157
XX-Net
code/default/launcher/tests/integrate_testing.py
.py
import json import os import time import sys from subprocess import Popen, PIPE, STDOUT import threading current_path = os.path.dirname(os.path.abspath(__file__)) default_path = os.path.abspath(os.path.join(current_path, os.path.pardir, os.path.pardir)) root_path = os.path.abspath(os.path.join(default_path, os.path.pa...
304
10,419
glances
run-venv.py
.py
#!.venv/bin/python import re import sys from glances import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main())
10
184
glances
run.py
.py
#!/usr/bin/python import re import sys from glances import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) sys.exit(main())
10
183
glances
generate_webui_conf.py
.py
import json from glances.outputs.glances_curses import _GlancesCurses print( json.dumps( { "topMenu": list(_GlancesCurses._top), "leftMenu": [p for p in _GlancesCurses._left_sidebar if p != "now"], }, indent=4, ) )
14
273
glances
generate_openapi.py
.py
import json from unittest.mock import patch from fastapi.openapi.utils import get_openapi from glances.main import GlancesMain # sys.path.append('./glances/outputs') from glances.outputs.glances_restful_api import GlancesRestfulApi # Init Glances core testargs = ["glances", "-C", "./conf/glances.conf"] with patch('...
34
1,032
glances
tests-data/tools/csvcheck.py
.py
#!/usr/bin/env python # # Check a CSV file. # The input CSV file should be given as an input with the -i <file> option. # Check the following thinks: # - number of line (without the header) should be equal to the number given with the -l <number of lines> option # - each line should have the same number of columns # - ...
86
3,163
glances
tests-data/tools/duckdbcheck.py
.py
#!/usr/bin/env python # # Check a DuckDB file. # The input DuckDB file should be given as an input with the -i <file> option. # Check the following thinks: # - number of line (without the header) should be equal to the number given with the -l <number of lines> option # - each line should have the same number of column...
66
2,157
glances
tests-data/issues/issue2849.py
.py
import sys import time sys.path.insert(0, '../glances') ########### # from glances.cpu_percent import cpu_percent # for _ in range(0, 5): # print([i['total'] for i in cpu_percent.get_percpu()]) # time.sleep(2) ########### from glances.main import GlancesMain from glances.stats import GlancesStats core = ...
26
533
glances
tests-data/issues/issue3290.py
.py
import time from multiprocessing import Process, Queue import psutil def exit_after(seconds, default=None): """Exit the function if it takes more than 'second' seconds to complete. In this case, return the value of 'default' (default: None).""" def handler(q, func, args, kwargs): q.put(func(*arg...
49
1,243
glances
tests-data/issues/issue2851.py
.py
import os import sys import time import psutil sys.path.insert(0, '../glances') from glances.globals import disable, enable from glances.main import GlancesMain from glances.stats import GlancesStats core = GlancesMain() stats = GlancesStats(config=core.get_config(), args=core.get_args()) refresh = 2 iteration = 6...
58
1,887
glances
tests-data/issues/issue869.py
.py
# Install PyWebview before running this test # But need Qt installed on the system... import webview webview.create_window('Hello world', 'http://localhost:61208/') webview.start()
8
183
glances
tests-data/issues/issue3319.py
.py
#################################################################################### # # Migration of the code issue3290.py to use multiprocessing with 'fork' start method # #################################################################################### import multiprocessing import time import psutil # multipr...
58
1,601
glances
tests-data/issues/issue3027.py
.py
import os import sys import time import psutil sys.path.insert(0, '../glances') from glances.globals import disable, enable from glances.main import GlancesMain from glances.stats import GlancesStats core = GlancesMain() stats = GlancesStats(config=core.get_config(), args=core.get_args()) refresh = 2 iteration = 6...
60
1,936
glances
tests-data/issues/issue3341-NATS/pub.py
.py
import asyncio import nats async def main(): nc = nats.NATS() await nc.connect(servers=["nats://localhost:4222"]) await nc.publish("glances.test", b'A test') await nc.flush() if __name__ == '__main__': asyncio.run(main()) # To run this test script, make sure you have a NATS server running lo...
19
327
glances
tests-data/issues/issue3341-NATS/sub.py
.py
import asyncio import nats async def main(): duration = 30 subject = "glances.*" nc = nats.NATS() await nc.connect(servers=["nats://localhost:4222"]) future = asyncio.Future() async def cb(msg): subject = msg.subject reply = msg.reply data = msg.data.decode() ...
33
697
glances
tests/test_api.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2025 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances API unitary tests suite.""" from unittest.mock import patch from glances import __version__, api # Global variables # ===========...
91
2,643
glances
tests/test_core.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # # Refactor by @ariel-anieli in 2024 """Glances unitary tests suite.""" import json import multiprocessing import time import unittest from dat...
1,281
56,811
glances
tests/test_plugin_processcount.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the ProcessCount plugin.""" import json from unittest.mock import PropertyMock, patch import pytest from glances.processes impo...
327
13,016
glances
tests/test_processes_cache.py
.py
"""Tests for the GlancesProcesses internal cache eviction.""" import pytest from glances.processes import GlancesProcesses @pytest.fixture def processes(): return GlancesProcesses() def test_remove_non_running_procs_keeps_running_pids(processes): processes.processlist_cache = {1: {'cmdline': 'a'}, 2: {'cm...
36
1,270
glances
tests/test_plugin_cpu.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the CPU plugin.""" import json import time import pytest from glances.globals import WINDOWS @pytest.fixture def cpu_plugin(g...
279
9,648
glances
tests/test_stdout_csv.py
.py
#!/usr/bin/env python # # This file is part of Glances. # # SPDX-FileCopyrightText: 2025 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Unit tests for the stdout CSV output (--stdout-csv). Regression tests for issue #3606: when a list-type plugin (e.g. network) gains or loses ...
146
5,031
glances
tests/test_plugin_virsh_injection.py
.py
#!/usr/bin/env python # # This file is part of Glances. # # SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the Virsh VM engine command-injection safety. Regression tests for GHSA-v5r2-qh84-fjx5 / CVE-2026-46606: VM domain names parsed fro...
196
7,985
glances
tests/test_perf.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances unitary tests suite for Glances perf.""" from glances.timer import Timer def test_perf_update(glances_stats): """ Test Gl...
41
1,237
glances
tests/test_glances_stats.py
.py
import tempfile from pathlib import Path from unittest.mock import MagicMock, patch import pytest from glances.stats import GlancesStats @pytest.fixture def plugin_manager(): """Create plugin manager instance.""" return GlancesStats() class Testload_additional_plugins: # noqa: D203 """Tests for helpe...
113
3,611
glances
tests/test_lazy_views.py
.py
"""Tests for the lazily built process views.""" import json import pytest def make_process(pid): return { 'pid': pid, 'key': 'pid', 'name': f'proc{pid}', 'cmdline': [f'proc{pid}'], 'username': 'someone', 'status': 'S', 'nice': 0, 'num_threads': 1, ...
76
2,066
glances
tests/test_glances_curses.py
.py
import curses from types import SimpleNamespace from unittest.mock import MagicMock, Mock import pytest from glances.outputs.glances_curses import _GlancesCurses @pytest.fixture def glancescreen(): """Create a lightweight _GlancesCurses instance for helper method testing. The full curses interface is inten...
216
7,211
glances
tests/test_browser_restful.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances unit tests for the WebUI/RESTful API Central Browser mode. Tests cover: - /api/<version>/serverslist endpoint returns a valid serve...
290
10,688
glances
tests/test_xmlrpc.py
.py
#!/usr/bin/env python # # This file is part of Glances. # # SPDX-FileCopyrightText: 2022 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the Glances XML-RPC server security headers: - Host header validation (GHSA-w856-8p3r-p338 / CVE-2026-46611) - CORS per-request orig...
237
8,859
glances
tests/test_plugin_sensors.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the Sensors plugin.""" import json import pytest from glances.config import Config from glances.globals import LINUX from glanc...
388
14,716
glances
tests/test_export_timescaledb_list.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2025 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances unit tests for the TimescaleDB export of list plugins. Tests cover: - The number of generated columns matches the number of values ...
87
3,069
glances
tests/test_api_secure.py
.py
# # This file is part of Glances. # # SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Regression tests for GHSA-4h34-v6r8-mmjc (CVE-2026-68520). Both /api/4/config and /api/4/args serve a sanitised view when Glances runs without authentication, and ...
190
6,097
glances
tests/test_plugin_docker.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the Docker container engine (issue #3559 performance fix).""" from unittest.mock import MagicMock, patch import pytest from gla...
120
4,170
glances
tests/test_actions_sanitize.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances unit tests for action command sanitization. Tests cover: - _sanitize_mustache_dict strips shell operators from string values - Pipe...
513
19,413
glances
tests/test_plugin_diskio.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the DiskIO plugin.""" import json import time import pytest @pytest.fixture def diskio_plugin(glances_stats): """Return th...
351
12,496
glances
tests/test_globals.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for glances.globals helper functions.""" import socket from collections import OrderedDict from types import SimpleNamespace from uni...
89
2,860
glances
tests/test_json_serializer.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the JSON serializer module. These tests are designed to be runnable standalone without requiring the full Glances initialization,...
359
12,826
glances
tests/test_amp_secure_popen.py
.py
# # This file is part of Glances. # # SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Regression tests for GHSA-3vwc-qwhc-3mj7. AMP `command` / `service_cmd` values are loaded verbatim from glances.conf and passed to secure_popen(), which interprets...
94
3,749
glances
tests/test_plugin_gpu.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the GPU plugin (ARM and Tegra backends).""" import pytest from glances.globals import LINUX from glances.plugins.gpu.cards impor...
322
12,283
glances
tests/test_outdated.py
.py
#!/usr/bin/env python # # This file is part of Glances. # # SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Tests for the Glances version cache safety: - Insecure pickle deserialization (GHSA-9837-48hr-q32j / CVE-2026-46607).""" import json import o...
165
6,008
glances
tests/test_memoryleak.py
.py
#!/usr/bin/env python # # Glances - An eye on your system # # SPDX-FileCopyrightText: 2024 Nicolas Hennion <nicolas@nicolargo.com> # # SPDX-License-Identifier: LGPL-3.0-only # """Glances unitary tests suite for Glances memory leak.""" import time import tracemalloc def test_memoryleak_no_history(glances_stats_no_hi...
40
1,248