logcatframe


Namelogcatframe JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/logcatframe
SummaryClass for capturing and parsing Android device logs using ADB.
upload_time2023-12-14 21:52:38
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords python logcat
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Class for capturing and parsing Android device logs using ADB.

## pip install logcatframe

### Tested against Windows / Python 3.11 / Anaconda


```python

    Args:
    - adb_path (str): Path to the ADB executable.
    - device_serial (str): Serial number of the target Android device.
    - print_output (bool): Flag to control whether to print log output to the console.
    - su (bool): Flag indicating whether to use 'su' (superuser) for logcat command (default is True).
    - clear_logcat (bool): Flag indicating whether to clear existing logcat logs before starting (default is True).

    Methods:
    - __init__(self, adb_path, device_serial, print_output, su=True, clear_logcat=True):
        Initializes a LogCatFrame instance.

    - start_recording(self):
        Starts capturing Android device logs using the specified ADB path and device serial.
        If `clear_logcat` is True, it clears existing logcat logs before starting.
        The captured logs are stored in the instance's `alldata` attribute.

    - _read_stdout(self, pr):
        Internal method for reading and printing logcat output.
        Used by the `start_recording` method in a separate thread.

    - parse_all_data(self, as_pandas=False):
        Parses the captured logs into a list of dictionaries.
        If `as_pandas` is True, converts the list into a Pandas DataFrame (requires Pandas to be installed).

    - parse_activities(self):
        Parses executed activities from the captured logs.
        Returns a list of tuples containing the executed command and associated variables.

    - get_short_path_name(long_name):
        Returns the short path name for the given long file name.
        Only applicable on Windows; on other platforms, it returns the input unchanged.


    from logcatframe import LogCatFrame

    adblog = LogCatFrame(
        adb_path=r"C:\Android\android-sdk\platform-tools\adb.exe",
        device_serial="emulator-5554",
        print_output=True,
        su=True,
        clear_logcat=True,
    )
    adblog.start_recording()
    df=adblog.parse_all_data(as_pandas=True)
    listoflist=adblog.parse_all_data(as_pandas=False)
    activities=adblog.parse_activities()
    from PrettyColorPrinter import add_printer # optional
    add_printer(1)
    print(df)
    print(listoflist)
    print(activities)


    # [('am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.android.settings/.Settings -b [47,217][161,363]',
    #   [['act', 'android.intent.action.MAIN'],
    #    ['cat', '[android.intent.category.LAUNCHER]'],
    #    ['flg', '0x10200000'],
    #    ['cmp', 'com.android.settings/.Settings'],
    #    ['bnds', '[47,217][161,363] (has extras)']]),
    #  ('am start -f 0x8000 -n com.android.settings/.Settings$PowerUsageSummaryActivity',
    #   [['flg', '0x8000'],
    #    ['cmp',
    #     'com.android.settings/.Settings$PowerUsageSummaryActivity (has extras)']]),
    #  ('am start -f 0x8000 -n com.android.settings/.Settings$DisplaySettingsActivity',
    #   [['flg', '0x8000'],
    #    ['cmp',
    #     'com.android.settings/.Settings$DisplaySettingsActivity (has extras)']]),
    #  ('am start -a com.android.intent.action.SHOW_BRIGHTNESS_DIALOG -n com.android.systemui/.settings.BrightnessDialog',
    #   [['act', 'com.android.intent.action.SHOW_BRIGHTNESS_DIALOG'],
    #    ['cmp', 'com.android.systemui/.settings.BrightnessDialog']]),
    #  ('am start -f 0x8000 -n com.android.settings/.Settings$SystemDashboardActivity',
    #   [['flg', '0x8000'],
    #    ['cmp',
    #     'com.android.settings/.Settings$SystemDashboardActivity (has extras)']]),
    #  ('am start -a android.intent.action.MAIN -n com.android.settings/.SubSettings',
    #   [['act', 'android.intent.action.MAIN'],
    #    ['cmp', 'com.android.settings/.SubSettings (has extras)']])]
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/logcatframe",
    "name": "logcatframe",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,logcat",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6f/77/42af0a396590793a6f66dab39a2ff2ed5e805713c349ae802a7d379b6a31/logcatframe-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# Class for capturing and parsing Android device logs using ADB.\r\n\r\n## pip install logcatframe\r\n\r\n### Tested against Windows / Python 3.11 / Anaconda\r\n\r\n\r\n```python\r\n\r\n    Args:\r\n    - adb_path (str): Path to the ADB executable.\r\n    - device_serial (str): Serial number of the target Android device.\r\n    - print_output (bool): Flag to control whether to print log output to the console.\r\n    - su (bool): Flag indicating whether to use 'su' (superuser) for logcat command (default is True).\r\n    - clear_logcat (bool): Flag indicating whether to clear existing logcat logs before starting (default is True).\r\n\r\n    Methods:\r\n    - __init__(self, adb_path, device_serial, print_output, su=True, clear_logcat=True):\r\n        Initializes a LogCatFrame instance.\r\n\r\n    - start_recording(self):\r\n        Starts capturing Android device logs using the specified ADB path and device serial.\r\n        If `clear_logcat` is True, it clears existing logcat logs before starting.\r\n        The captured logs are stored in the instance's `alldata` attribute.\r\n\r\n    - _read_stdout(self, pr):\r\n        Internal method for reading and printing logcat output.\r\n        Used by the `start_recording` method in a separate thread.\r\n\r\n    - parse_all_data(self, as_pandas=False):\r\n        Parses the captured logs into a list of dictionaries.\r\n        If `as_pandas` is True, converts the list into a Pandas DataFrame (requires Pandas to be installed).\r\n\r\n    - parse_activities(self):\r\n        Parses executed activities from the captured logs.\r\n        Returns a list of tuples containing the executed command and associated variables.\r\n\r\n    - get_short_path_name(long_name):\r\n        Returns the short path name for the given long file name.\r\n        Only applicable on Windows; on other platforms, it returns the input unchanged.\r\n\r\n\r\n    from logcatframe import LogCatFrame\r\n\r\n    adblog = LogCatFrame(\r\n        adb_path=r\"C:\\Android\\android-sdk\\platform-tools\\adb.exe\",\r\n        device_serial=\"emulator-5554\",\r\n        print_output=True,\r\n        su=True,\r\n        clear_logcat=True,\r\n    )\r\n    adblog.start_recording()\r\n    df=adblog.parse_all_data(as_pandas=True)\r\n    listoflist=adblog.parse_all_data(as_pandas=False)\r\n    activities=adblog.parse_activities()\r\n    from PrettyColorPrinter import add_printer # optional\r\n    add_printer(1)\r\n    print(df)\r\n    print(listoflist)\r\n    print(activities)\r\n\r\n\r\n    # [('am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.android.settings/.Settings -b [47,217][161,363]',\r\n    #   [['act', 'android.intent.action.MAIN'],\r\n    #    ['cat', '[android.intent.category.LAUNCHER]'],\r\n    #    ['flg', '0x10200000'],\r\n    #    ['cmp', 'com.android.settings/.Settings'],\r\n    #    ['bnds', '[47,217][161,363] (has extras)']]),\r\n    #  ('am start -f 0x8000 -n com.android.settings/.Settings$PowerUsageSummaryActivity',\r\n    #   [['flg', '0x8000'],\r\n    #    ['cmp',\r\n    #     'com.android.settings/.Settings$PowerUsageSummaryActivity (has extras)']]),\r\n    #  ('am start -f 0x8000 -n com.android.settings/.Settings$DisplaySettingsActivity',\r\n    #   [['flg', '0x8000'],\r\n    #    ['cmp',\r\n    #     'com.android.settings/.Settings$DisplaySettingsActivity (has extras)']]),\r\n    #  ('am start -a com.android.intent.action.SHOW_BRIGHTNESS_DIALOG -n com.android.systemui/.settings.BrightnessDialog',\r\n    #   [['act', 'com.android.intent.action.SHOW_BRIGHTNESS_DIALOG'],\r\n    #    ['cmp', 'com.android.systemui/.settings.BrightnessDialog']]),\r\n    #  ('am start -f 0x8000 -n com.android.settings/.Settings$SystemDashboardActivity',\r\n    #   [['flg', '0x8000'],\r\n    #    ['cmp',\r\n    #     'com.android.settings/.Settings$SystemDashboardActivity (has extras)']]),\r\n    #  ('am start -a android.intent.action.MAIN -n com.android.settings/.SubSettings',\r\n    #   [['act', 'android.intent.action.MAIN'],\r\n    #    ['cmp', 'com.android.settings/.SubSettings (has extras)']])]\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Class for capturing and parsing Android device logs using ADB.",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/logcatframe"
    },
    "split_keywords": [
        "python",
        "logcat"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6874518fc3abb4bb669da23c044cfcaaab6568182424f7cbfbf69b55f3f671ad",
                "md5": "002e5ad62ffd7d5d0f0c7ca060300b1f",
                "sha256": "37f5ef688fb3632c433ca5bf610652f3df86bd2492d57fcf90ace92f4abc01c2"
            },
            "downloads": -1,
            "filename": "logcatframe-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "002e5ad62ffd7d5d0f0c7ca060300b1f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13405,
            "upload_time": "2023-12-14T21:52:36",
            "upload_time_iso_8601": "2023-12-14T21:52:36.713850Z",
            "url": "https://files.pythonhosted.org/packages/68/74/518fc3abb4bb669da23c044cfcaaab6568182424f7cbfbf69b55f3f671ad/logcatframe-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f7742af0a396590793a6f66dab39a2ff2ed5e805713c349ae802a7d379b6a31",
                "md5": "300348d9e9538831dd06e5a21cf681e0",
                "sha256": "ea190a91d3d2019adaa9d9dc58379627bc3c5dd34a0a533bd860a7a19c4682e9"
            },
            "downloads": -1,
            "filename": "logcatframe-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "300348d9e9538831dd06e5a21cf681e0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11099,
            "upload_time": "2023-12-14T21:52:38",
            "upload_time_iso_8601": "2023-12-14T21:52:38.791576Z",
            "url": "https://files.pythonhosted.org/packages/6f/77/42af0a396590793a6f66dab39a2ff2ed5e805713c349ae802a7d379b6a31/logcatframe-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-14 21:52:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "logcatframe",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "logcatframe"
}
        
Elapsed time: 0.16107s