adbkonnekt


Nameadbkonnekt JSON
Version 0.14 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/adbkonnekt
Summaryautomates ADB management in Windows, ensuring ADB listens to all TCP (no USB!) devices, handles configurations, and restarts if killed
upload_time2024-03-27 02:07:58
maintainerNone
docs_urlNone
authorJohannes Fischer
requires_pythonNone
licenseMIT
keywords android adb
VCS
bugtrack_url
requirements konfigleser procciao psutil sharedbuiltinmutables subprocess_alive touchtouch
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# automates ADB management in Windows, ensuring ADB listens to all TCP (no USB!) devices, handles configurations, and restarts if killed

## pip install adbkonnekt 

### Tested against Windows / Python 3.11 / Anaconda / BlueStacks / LdPlayer / MeMu 


#### ADB 

https://developer.android.com/tools/releases/platform-tools

```python
from konfigleser import write_config_file
import sys
import subprocess

# Use a config file:
r"""
[DEFAULT]
outputfolder = C:\stdoutstderradblog
adb_path = C:\ProgramData\chocolatey\lib\adb\tools\platform-tools\adb.exe
shell = False
window_style = Maximized
timeout_check_if_proc_running = 30
kill_running_adb = True
is_alive_sleeptime = 0.05
check_if_alive = True
restart_when_killed = True
auto_connect_devices = True
max_port_number = 5555
adb_port = 5037
adb_executables_to_kill = ('hd-adb.exe', 'adb.exe')
sleep_after_connection_attempt = 0.1
sleep_after_starting_the_process = 1
daemon = False
priority = high
listen_on_all_ports = True
min_port = 5550
no_auto_connect = (8080, 8000, 8888, 1433, 1521, 3306, 5000, 5432, 6379, 27017, 27018, 8443, 3389)
ignore_exceptions = True
new_connection_interval = 30
update_shared_devices_info = 30
"""

# Parameters:
# - adb_path (str): Path to the ADB executable.
# - outputfolder (str): Path to the folder where the output logs will be stored.
# - timeout_check_if_proc_running (Union[int, float]): Timeout duration in seconds to check if the process is running.
# - window_style (Literal['Hidden', 'Maximized', 'Minimized', 'Normal']): Window style for the ADB process.
# - kill_running_adb (bool): Flag to kill any running ADB instances before starting. Default is True.
# - is_alive_sleeptime (Union[int, float]): Time in seconds to sleep while checking if the ADB process is alive.
# - check_if_alive (bool): Flag to check if the ADB process is alive. Default is True.
# - restart_when_killed (bool): Flag to restart ADB if it gets killed. Default is True.
# - auto_connect_devices (bool): Flag to automatically connect devices. Default is True.
# - max_port_number (int): Maximum port number for adb scan. Default is 5555 - ADB scans only one port, and, because
#   of that, you get a great speed up .
# - adb_port (int): ADB port number. Default is 5037.
# - adb_executables_to_kill (tuple[str]): Tuple of ADB executable names to kill. Default is ("hd-adb.exe", "adb.exe").
# - sleep_after_connection_attempt (Union[int, float]): Sleep time in seconds after attempting a connection to a client.
# - sleep_after_starting_the_process (Union[int, float]): Sleep time in seconds after starting the ADB process.
# - daemon (bool): Flag to run ADB in daemon mode. Default is False. (if start_server_mode is True -> always daemon)
# - priority (Literal["realtime", "high", "above normal", "normal", "below normal", "low"]): Priority level for the
#   ADB process. Default is "above normal".
# - shell (bool): Flag to use shell when starting ADB. Default is True.
# - listen_on_all_ports (bool): Flag to listen on all ports. Default is True. -> fast [re]connect
# - min_port (int): Minimum port number to consider for connections. Default is 5550.
# - no_auto_connect (tuple[int]): Tuple of port numbers to not auto-[re]connect. (HTML, SQL ...)
# - ignore_exceptions (bool): Flag to ignore exceptions and continue execution. Default is True.
# - new_connection_interval (Union[int, float]): Time in seconds to wait between checking new connections. Default is 30. / 0 disables it
# - update_shared_devices_info (Union[int, float]): Time in seconds to update the shared memory dict to get the devices information.


# or a dict and convert it to a config file
adbexe = r"C:\ProgramData\chocolatey\lib\adb\tools\platform-tools\adb.exe"
cfgdata = {
    "DEFAULT": {
        "outputfolder": "C:\\stdoutstderradblog",
        "adb_path": adbexe,
        "shell": False,
        "window_style": "Maximized",
        "timeout_check_if_proc_running": 30,
        "kill_running_adb": True,
        "is_alive_sleeptime": 0.05,
        "check_if_alive": True,
        "restart_when_killed": True,
        "auto_connect_devices": True,
        "max_port_number": 5555,
        "adb_port": 5037,
        "adb_executables_to_kill": ("hd-adb.exe", "adb.exe"),
        "sleep_after_connection_attempt": 0.1,
        "sleep_after_starting_the_process": 1,
        "daemon": False,
        "priority": "high",
        "listen_on_all_ports": True,
        "min_port": 5550,
        "no_auto_connect": (
            8080,
            8000,
            8888,
            1433,
            1521,
            3306,
            5000,
            5432,
            6379,
            27017,
            27018,
            8443,
            3389,
        ),
        "ignore_exceptions": True,
        "new_connection_interval": 30,
        "update_shared_devices_info": 30,
    }
}
savepath = "c:\\adb_connection_config.ini"
write_config_file(d=cfgdata, filepath=savepath)

# run the init_file in a subprocess, it creates a completely detached process with powershell (needs elevated/admin rights!!),
# that means you can close this python script here after you see the other console running
p = subprocess.Popen(
    [
        sys.executable,
        r"C:\ProgramData\anaconda3\envs\a0\Lib\site-packages\adbkonnekt\__init__.py",  # path is different on your pc
        savepath,
    ],
)
print(p)

# After running the script, you can have access to all device information by using

# from sharedbuiltinmutables import MemSharedDict
# emulatordata = MemSharedDict({}, name="ADBDEVICES", size=4096000)
# print(emulatordata)

# You don't have to be in the same env, even different versions of Python will work.

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/adbkonnekt",
    "name": "adbkonnekt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "android, adb",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/21/5e/2b0dc022b0d09f9d647261c122998c9d6c76b3677549431064efd0901689/adbkonnekt-0.14.tar.gz",
    "platform": null,
    "description": "\r\n# automates ADB management in Windows, ensuring ADB listens to all TCP (no USB!) devices, handles configurations, and restarts if killed\r\n\r\n## pip install adbkonnekt \r\n\r\n### Tested against Windows / Python 3.11 / Anaconda / BlueStacks / LdPlayer / MeMu \r\n\r\n\r\n#### ADB \r\n\r\nhttps://developer.android.com/tools/releases/platform-tools\r\n\r\n```python\r\nfrom konfigleser import write_config_file\r\nimport sys\r\nimport subprocess\r\n\r\n# Use a config file:\r\nr\"\"\"\r\n[DEFAULT]\r\noutputfolder = C:\\stdoutstderradblog\r\nadb_path = C:\\ProgramData\\chocolatey\\lib\\adb\\tools\\platform-tools\\adb.exe\r\nshell = False\r\nwindow_style = Maximized\r\ntimeout_check_if_proc_running = 30\r\nkill_running_adb = True\r\nis_alive_sleeptime = 0.05\r\ncheck_if_alive = True\r\nrestart_when_killed = True\r\nauto_connect_devices = True\r\nmax_port_number = 5555\r\nadb_port = 5037\r\nadb_executables_to_kill = ('hd-adb.exe', 'adb.exe')\r\nsleep_after_connection_attempt = 0.1\r\nsleep_after_starting_the_process = 1\r\ndaemon = False\r\npriority = high\r\nlisten_on_all_ports = True\r\nmin_port = 5550\r\nno_auto_connect = (8080, 8000, 8888, 1433, 1521, 3306, 5000, 5432, 6379, 27017, 27018, 8443, 3389)\r\nignore_exceptions = True\r\nnew_connection_interval = 30\r\nupdate_shared_devices_info = 30\r\n\"\"\"\r\n\r\n# Parameters:\r\n# - adb_path (str): Path to the ADB executable.\r\n# - outputfolder (str): Path to the folder where the output logs will be stored.\r\n# - timeout_check_if_proc_running (Union[int, float]): Timeout duration in seconds to check if the process is running.\r\n# - window_style (Literal['Hidden', 'Maximized', 'Minimized', 'Normal']): Window style for the ADB process.\r\n# - kill_running_adb (bool): Flag to kill any running ADB instances before starting. Default is True.\r\n# - is_alive_sleeptime (Union[int, float]): Time in seconds to sleep while checking if the ADB process is alive.\r\n# - check_if_alive (bool): Flag to check if the ADB process is alive. Default is True.\r\n# - restart_when_killed (bool): Flag to restart ADB if it gets killed. Default is True.\r\n# - auto_connect_devices (bool): Flag to automatically connect devices. Default is True.\r\n# - max_port_number (int): Maximum port number for adb scan. Default is 5555 - ADB scans only one port, and, because\r\n#   of that, you get a great speed up .\r\n# - adb_port (int): ADB port number. Default is 5037.\r\n# - adb_executables_to_kill (tuple[str]): Tuple of ADB executable names to kill. Default is (\"hd-adb.exe\", \"adb.exe\").\r\n# - sleep_after_connection_attempt (Union[int, float]): Sleep time in seconds after attempting a connection to a client.\r\n# - sleep_after_starting_the_process (Union[int, float]): Sleep time in seconds after starting the ADB process.\r\n# - daemon (bool): Flag to run ADB in daemon mode. Default is False. (if start_server_mode is True -> always daemon)\r\n# - priority (Literal[\"realtime\", \"high\", \"above normal\", \"normal\", \"below normal\", \"low\"]): Priority level for the\r\n#   ADB process. Default is \"above normal\".\r\n# - shell (bool): Flag to use shell when starting ADB. Default is True.\r\n# - listen_on_all_ports (bool): Flag to listen on all ports. Default is True. -> fast [re]connect\r\n# - min_port (int): Minimum port number to consider for connections. Default is 5550.\r\n# - no_auto_connect (tuple[int]): Tuple of port numbers to not auto-[re]connect. (HTML, SQL ...)\r\n# - ignore_exceptions (bool): Flag to ignore exceptions and continue execution. Default is True.\r\n# - new_connection_interval (Union[int, float]): Time in seconds to wait between checking new connections. Default is 30. / 0 disables it\r\n# - update_shared_devices_info (Union[int, float]): Time in seconds to update the shared memory dict to get the devices information.\r\n\r\n\r\n# or a dict and convert it to a config file\r\nadbexe = r\"C:\\ProgramData\\chocolatey\\lib\\adb\\tools\\platform-tools\\adb.exe\"\r\ncfgdata = {\r\n    \"DEFAULT\": {\r\n        \"outputfolder\": \"C:\\\\stdoutstderradblog\",\r\n        \"adb_path\": adbexe,\r\n        \"shell\": False,\r\n        \"window_style\": \"Maximized\",\r\n        \"timeout_check_if_proc_running\": 30,\r\n        \"kill_running_adb\": True,\r\n        \"is_alive_sleeptime\": 0.05,\r\n        \"check_if_alive\": True,\r\n        \"restart_when_killed\": True,\r\n        \"auto_connect_devices\": True,\r\n        \"max_port_number\": 5555,\r\n        \"adb_port\": 5037,\r\n        \"adb_executables_to_kill\": (\"hd-adb.exe\", \"adb.exe\"),\r\n        \"sleep_after_connection_attempt\": 0.1,\r\n        \"sleep_after_starting_the_process\": 1,\r\n        \"daemon\": False,\r\n        \"priority\": \"high\",\r\n        \"listen_on_all_ports\": True,\r\n        \"min_port\": 5550,\r\n        \"no_auto_connect\": (\r\n            8080,\r\n            8000,\r\n            8888,\r\n            1433,\r\n            1521,\r\n            3306,\r\n            5000,\r\n            5432,\r\n            6379,\r\n            27017,\r\n            27018,\r\n            8443,\r\n            3389,\r\n        ),\r\n        \"ignore_exceptions\": True,\r\n        \"new_connection_interval\": 30,\r\n        \"update_shared_devices_info\": 30,\r\n    }\r\n}\r\nsavepath = \"c:\\\\adb_connection_config.ini\"\r\nwrite_config_file(d=cfgdata, filepath=savepath)\r\n\r\n# run the init_file in a subprocess, it creates a completely detached process with powershell (needs elevated/admin rights!!),\r\n# that means you can close this python script here after you see the other console running\r\np = subprocess.Popen(\r\n    [\r\n        sys.executable,\r\n        r\"C:\\ProgramData\\anaconda3\\envs\\a0\\Lib\\site-packages\\adbkonnekt\\__init__.py\",  # path is different on your pc\r\n        savepath,\r\n    ],\r\n)\r\nprint(p)\r\n\r\n# After running the script, you can have access to all device information by using\r\n\r\n# from sharedbuiltinmutables import MemSharedDict\r\n# emulatordata = MemSharedDict({}, name=\"ADBDEVICES\", size=4096000)\r\n# print(emulatordata)\r\n\r\n# You don't have to be in the same env, even different versions of Python will work.\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "automates ADB management in Windows, ensuring ADB listens to all TCP (no USB!) devices, handles configurations, and restarts if killed",
    "version": "0.14",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/adbkonnekt"
    },
    "split_keywords": [
        "android",
        " adb"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7953e900e45d8c7a79dcf44340d16cad8d762074685b21c7cb90de0863cd4413",
                "md5": "08433a64256dcf570677fc4caa51e426",
                "sha256": "95e075f35cf188e7496c37479a41cfba84a5b9d96ac585d9dee97008253c3989"
            },
            "downloads": -1,
            "filename": "adbkonnekt-0.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "08433a64256dcf570677fc4caa51e426",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 15757,
            "upload_time": "2024-03-27T02:07:56",
            "upload_time_iso_8601": "2024-03-27T02:07:56.407670Z",
            "url": "https://files.pythonhosted.org/packages/79/53/e900e45d8c7a79dcf44340d16cad8d762074685b21c7cb90de0863cd4413/adbkonnekt-0.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "215e2b0dc022b0d09f9d647261c122998c9d6c76b3677549431064efd0901689",
                "md5": "e2b8355d287ffead63c318115f2f83b3",
                "sha256": "0307eaf40901219495948c400bba60bc564d00da67cfd8ed583f10e5e7f34c2b"
            },
            "downloads": -1,
            "filename": "adbkonnekt-0.14.tar.gz",
            "has_sig": false,
            "md5_digest": "e2b8355d287ffead63c318115f2f83b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14703,
            "upload_time": "2024-03-27T02:07:58",
            "upload_time_iso_8601": "2024-03-27T02:07:58.162537Z",
            "url": "https://files.pythonhosted.org/packages/21/5e/2b0dc022b0d09f9d647261c122998c9d6c76b3677549431064efd0901689/adbkonnekt-0.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-27 02:07:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "adbkonnekt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "konfigleser",
            "specs": []
        },
        {
            "name": "procciao",
            "specs": []
        },
        {
            "name": "psutil",
            "specs": []
        },
        {
            "name": "sharedbuiltinmutables",
            "specs": []
        },
        {
            "name": "subprocess_alive",
            "specs": []
        },
        {
            "name": "touchtouch",
            "specs": []
        }
    ],
    "lcname": "adbkonnekt"
}
        
Elapsed time: 0.21207s