adbscripts


Nameadbscripts JSON
Version 0.11 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/adbscripts
Summarysome adb scripts
upload_time2023-10-21 23:48:30
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords adb scripts
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# some adb scripts

## Tested against Windows / Python 3.11 / Anaconda

## pip install adbscripts

```python
from adbscripts import AdbCapture
path_adb = r"C:\Android\android-sdk\platform-tools\adb.exe"
device_serial = "127.0.0.1:5555"
adbscripts = AdbCapture(
    adb_path=path_adb,
    device_serial=device_serial,
    capture_buffer=100000,
    use_busybox=False,
)
adbscripts.connect_to_device()
df1, stderr = adbscripts.get_one_csv_uiautomator(
    defaultvalue="null",convert_to_pandas=True
)


df, stderr = adbscripts.get_one_csv_activities(
    defaultvalue="null",
    with_hashcode=1,convert_to_pandas=True
)



from time import sleep
import pandas as pd
import io
from adbscripts import AdbCapture

path_adb = r"C:\Android\android-sdk\platform-tools\adb.exe"
device_serial = "127.0.0.1:5555"

self = AdbCapture(
    adb_path=path_adb,
    device_serial=device_serial,
    capture_buffer_for_ui_activities=100000,
    use_busybox=False,
)
stdout, stderr = self.connect_to_device()
exa = False
lscommand = self.execute_shell_script(
    "ls | cat",
    su=False,
    add_exit=True,
    print_stderr=True,
    print_stdout=True,
    clear_temp_lines_for_csv=False,
)
lscommand.is_alive()
print(lscommand.captured_stdout)

lscommand2 = self.execute_shell_script(
    """
while true; do    
    ls | cat
done    
    """,
    su=False,
    add_exit=True,
    print_stderr=True,
    print_stdout=True,
    clear_temp_lines_for_csv=False,
)

sleep(4)
print(lscommand2.is_alive())
lscommand2.stop_capturing = True
sleep(0.5)
print(lscommand2.is_alive())

activitieselements = self.start_capture_activities(
    print_csv=1,
    defaultvalue="null",
    sleeptime=1,
    addtoscript="",
    print_stdout=False,
    print_stderr=True,
    add_exit=False,
    stripline=0,
    with_class=0,
    with_mid=0,
    with_hashcode=0,
    with_elementid=0,
    with_visibility=0,
    with_focusable=0,
    with_enabled=0,
    with_drawn=0,
    with_scrollbars_horizontal=0,
    with_scrollbars_vertical=0,
    with_clickable=0,
    with_long_clickable=0,
    with_context_clickable=0,
    with_pflag_is_root_namespace=0,
    with_pflag_focused=0,
    with_pflag_selected=0,
    with_pflag_prepressed=0,
    with_pflag_hovered=0,
    with_pflag_activated=0,
    with_pflag_invalidated=0,
    with_pflag_dirty_mask=0,
)
sleep(5)
print(activitieselements.stdout_for_ui_and_activities)
activitieselements.stop_capturing = True
df = pd.read_csv(io.StringIO(activitieselements.stdout_for_ui_and_activities[-1]))
print(df)
uia = self.start_capture_uiautomator(
    print_csv=1,
    defaultvalue="null",
    sleeptime=1,
    addtoscript="",
    print_stdout=True,
    print_stderr=True,
    add_exit=False,
)
sleep(5)
uia.stop_capturing = True
# df2=(pd.read_csv(io.StringIO(uia.stdout_for_ui_and_activities[-1])))
# print(df2)

capturedpixel = self.start_capture_get_color_at_pixel(
    x=500,
    y=509,
    print_stderr=True,
    print_stdout=True,
)
sleep(5)
capturedpixel.stop_capturing = True
print(capturedpixel.captured_stdout)

onlyonetime = self.get_color_at_pixel(
    x=100,
    y=200,
    print_stderr=True,
    print_stdout=True,
)
print(onlyonetime)

activneu = self.start_capture_activities()
sleep(20)
activneu.stop_capturing = True
print(activneu.stdout_for_ui_and_activities)
pd.read_csv(io.StringIO(activneu.stdout_for_ui_and_activities[1]))


webscraping = self.start_chrome_webscraping(
    id_positive_button="app:id/positive_button",
    id_save_offline_button="app:id/save_offline_button",
    id_refresh_button="",
    # id_refresh_button="app:id/refresh_button",
    sleep_after_positive_button=1,
    sleep_after_save_offline_button=1,
    sleep_after_refresh_button=1,
    print_stderr=True,
    print_stdout=False,
)

counter = 0
from lxml2pandas import subprocess_parsing
from threading import Lock

lock = Lock()
parsedata = []
tmpfiles = []
co = 0

bubu = False
while True:
    try:
        sleep(5)
        if webscraping.captured_stdout:
            try:
                lock.acquire()

                parsedata = [webscraping.captured_stdout[-1]]
                webscraping.captured_stdout.clear()
            finally:
                lock.release()
        if parsedata:
            df = subprocess_parsing(
                parsedata,
                chunks=1,
                processes=4,
                print_stdout=True,
                print_stderr=True,
                print_function_exceptions=True,
                children_and_parents=True,
                allowed_tags=(),
                forbidden_tags=("html", "body"),
                filter_function=lambda x: "t" in str(x.aa_attr_values).lower(),
            )
            print(df)
            parsedata.clear()

    except Exception as fe:
        print(fe)
        continue

webscraping.stop_capturing = True

```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/adbscripts",
    "name": "adbscripts",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "adb,scripts",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e1/a0/157749e78d06278e09f930d7eceeeb4f598c05cd7d3d57b505c687aa0a6b/adbscripts-0.11.tar.gz",
    "platform": null,
    "description": "\r\n# some adb scripts\r\n\r\n## Tested against Windows / Python 3.11 / Anaconda\r\n\r\n## pip install adbscripts\r\n\r\n```python\r\nfrom adbscripts import AdbCapture\r\npath_adb = r\"C:\\Android\\android-sdk\\platform-tools\\adb.exe\"\r\ndevice_serial = \"127.0.0.1:5555\"\r\nadbscripts = AdbCapture(\r\n    adb_path=path_adb,\r\n    device_serial=device_serial,\r\n    capture_buffer=100000,\r\n    use_busybox=False,\r\n)\r\nadbscripts.connect_to_device()\r\ndf1, stderr = adbscripts.get_one_csv_uiautomator(\r\n    defaultvalue=\"null\",convert_to_pandas=True\r\n)\r\n\r\n\r\ndf, stderr = adbscripts.get_one_csv_activities(\r\n    defaultvalue=\"null\",\r\n    with_hashcode=1,convert_to_pandas=True\r\n)\r\n\r\n\r\n\r\nfrom time import sleep\r\nimport pandas as pd\r\nimport io\r\nfrom adbscripts import AdbCapture\r\n\r\npath_adb = r\"C:\\Android\\android-sdk\\platform-tools\\adb.exe\"\r\ndevice_serial = \"127.0.0.1:5555\"\r\n\r\nself = AdbCapture(\r\n    adb_path=path_adb,\r\n    device_serial=device_serial,\r\n    capture_buffer_for_ui_activities=100000,\r\n    use_busybox=False,\r\n)\r\nstdout, stderr = self.connect_to_device()\r\nexa = False\r\nlscommand = self.execute_shell_script(\r\n    \"ls | cat\",\r\n    su=False,\r\n    add_exit=True,\r\n    print_stderr=True,\r\n    print_stdout=True,\r\n    clear_temp_lines_for_csv=False,\r\n)\r\nlscommand.is_alive()\r\nprint(lscommand.captured_stdout)\r\n\r\nlscommand2 = self.execute_shell_script(\r\n    \"\"\"\r\nwhile true; do    \r\n    ls | cat\r\ndone    \r\n    \"\"\",\r\n    su=False,\r\n    add_exit=True,\r\n    print_stderr=True,\r\n    print_stdout=True,\r\n    clear_temp_lines_for_csv=False,\r\n)\r\n\r\nsleep(4)\r\nprint(lscommand2.is_alive())\r\nlscommand2.stop_capturing = True\r\nsleep(0.5)\r\nprint(lscommand2.is_alive())\r\n\r\nactivitieselements = self.start_capture_activities(\r\n    print_csv=1,\r\n    defaultvalue=\"null\",\r\n    sleeptime=1,\r\n    addtoscript=\"\",\r\n    print_stdout=False,\r\n    print_stderr=True,\r\n    add_exit=False,\r\n    stripline=0,\r\n    with_class=0,\r\n    with_mid=0,\r\n    with_hashcode=0,\r\n    with_elementid=0,\r\n    with_visibility=0,\r\n    with_focusable=0,\r\n    with_enabled=0,\r\n    with_drawn=0,\r\n    with_scrollbars_horizontal=0,\r\n    with_scrollbars_vertical=0,\r\n    with_clickable=0,\r\n    with_long_clickable=0,\r\n    with_context_clickable=0,\r\n    with_pflag_is_root_namespace=0,\r\n    with_pflag_focused=0,\r\n    with_pflag_selected=0,\r\n    with_pflag_prepressed=0,\r\n    with_pflag_hovered=0,\r\n    with_pflag_activated=0,\r\n    with_pflag_invalidated=0,\r\n    with_pflag_dirty_mask=0,\r\n)\r\nsleep(5)\r\nprint(activitieselements.stdout_for_ui_and_activities)\r\nactivitieselements.stop_capturing = True\r\ndf = pd.read_csv(io.StringIO(activitieselements.stdout_for_ui_and_activities[-1]))\r\nprint(df)\r\nuia = self.start_capture_uiautomator(\r\n    print_csv=1,\r\n    defaultvalue=\"null\",\r\n    sleeptime=1,\r\n    addtoscript=\"\",\r\n    print_stdout=True,\r\n    print_stderr=True,\r\n    add_exit=False,\r\n)\r\nsleep(5)\r\nuia.stop_capturing = True\r\n# df2=(pd.read_csv(io.StringIO(uia.stdout_for_ui_and_activities[-1])))\r\n# print(df2)\r\n\r\ncapturedpixel = self.start_capture_get_color_at_pixel(\r\n    x=500,\r\n    y=509,\r\n    print_stderr=True,\r\n    print_stdout=True,\r\n)\r\nsleep(5)\r\ncapturedpixel.stop_capturing = True\r\nprint(capturedpixel.captured_stdout)\r\n\r\nonlyonetime = self.get_color_at_pixel(\r\n    x=100,\r\n    y=200,\r\n    print_stderr=True,\r\n    print_stdout=True,\r\n)\r\nprint(onlyonetime)\r\n\r\nactivneu = self.start_capture_activities()\r\nsleep(20)\r\nactivneu.stop_capturing = True\r\nprint(activneu.stdout_for_ui_and_activities)\r\npd.read_csv(io.StringIO(activneu.stdout_for_ui_and_activities[1]))\r\n\r\n\r\nwebscraping = self.start_chrome_webscraping(\r\n    id_positive_button=\"app:id/positive_button\",\r\n    id_save_offline_button=\"app:id/save_offline_button\",\r\n    id_refresh_button=\"\",\r\n    # id_refresh_button=\"app:id/refresh_button\",\r\n    sleep_after_positive_button=1,\r\n    sleep_after_save_offline_button=1,\r\n    sleep_after_refresh_button=1,\r\n    print_stderr=True,\r\n    print_stdout=False,\r\n)\r\n\r\ncounter = 0\r\nfrom lxml2pandas import subprocess_parsing\r\nfrom threading import Lock\r\n\r\nlock = Lock()\r\nparsedata = []\r\ntmpfiles = []\r\nco = 0\r\n\r\nbubu = False\r\nwhile True:\r\n    try:\r\n        sleep(5)\r\n        if webscraping.captured_stdout:\r\n            try:\r\n                lock.acquire()\r\n\r\n                parsedata = [webscraping.captured_stdout[-1]]\r\n                webscraping.captured_stdout.clear()\r\n            finally:\r\n                lock.release()\r\n        if parsedata:\r\n            df = subprocess_parsing(\r\n                parsedata,\r\n                chunks=1,\r\n                processes=4,\r\n                print_stdout=True,\r\n                print_stderr=True,\r\n                print_function_exceptions=True,\r\n                children_and_parents=True,\r\n                allowed_tags=(),\r\n                forbidden_tags=(\"html\", \"body\"),\r\n                filter_function=lambda x: \"t\" in str(x.aa_attr_values).lower(),\r\n            )\r\n            print(df)\r\n            parsedata.clear()\r\n\r\n    except Exception as fe:\r\n        print(fe)\r\n        continue\r\n\r\nwebscraping.stop_capturing = True\r\n\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "some adb scripts",
    "version": "0.11",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/adbscripts"
    },
    "split_keywords": [
        "adb",
        "scripts"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bbe9108843db1715100a6a118c072392e2f077e1ef80975d649889d98a57e501",
                "md5": "3d861291a8ede4ca07a4701ac771536f",
                "sha256": "b2aff2e01baefc95e85c4a65690d947440ee38fe782a9788315dc2ace9cd5e09"
            },
            "downloads": -1,
            "filename": "adbscripts-0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3d861291a8ede4ca07a4701ac771536f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 24826,
            "upload_time": "2023-10-21T23:48:28",
            "upload_time_iso_8601": "2023-10-21T23:48:28.776283Z",
            "url": "https://files.pythonhosted.org/packages/bb/e9/108843db1715100a6a118c072392e2f077e1ef80975d649889d98a57e501/adbscripts-0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1a0157749e78d06278e09f930d7eceeeb4f598c05cd7d3d57b505c687aa0a6b",
                "md5": "23b336750ec161d217b1d7f10e357453",
                "sha256": "701a127033f117218042de3034c3ebcfbc99f5eea3c6e1bd6647d5fef7292b33"
            },
            "downloads": -1,
            "filename": "adbscripts-0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "23b336750ec161d217b1d7f10e357453",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 22706,
            "upload_time": "2023-10-21T23:48:30",
            "upload_time_iso_8601": "2023-10-21T23:48:30.683464Z",
            "url": "https://files.pythonhosted.org/packages/e1/a0/157749e78d06278e09f930d7eceeeb4f598c05cd7d3d57b505c687aa0a6b/adbscripts-0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-21 23:48:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "adbscripts",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "adbscripts"
}
        
Elapsed time: 0.13488s