wmclient


Namewmclient JSON
Version 2.3.1 PyPI version JSON
download
home_pageNone
SummaryWURFL Microservice client for Python
upload_time2024-10-28 14:10:12
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseapache-2.0
keywords device mobile device detection analytics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # wmclient - WURFL Microservice Client for Python

## Differences between version 2.2.0 and previous ones.

Version 2.2.0 makes WURFL microservice client backward compatible with Python 2.7. To do that it replaces two libraries that are available for Python 3.x only:

- pywurfl (replaced by urrllib3)
- @lru_cache (replaced by pylru)

While in older versions cache was used by default, in this version you'll have to use the `set_cache_size` function of the client to ensure it is created and used.

## Python WURFL Microservice Client

WURFL Microservice (by ScientiaMobile, Inc.) is a mobile device detection service that can quickly and accurately detect over 500 capabilities of visiting devices. It can differentiate between portable mobile devices, desktop devices, SmartTVs and any other types of devices that have a web browser.

This is the Python Client API for accessing the WURFL Microservice. The API is released under Open-Source and can be integrated with other open-source or proprietary code. In order to operate, it requires access to a running instance of the WURFL Microservice product, such as:

- WURFL Microservice for Docker: https://www.scientiamobile.com/products/wurfl-microservice-docker-detect-device/

- WURFL Microservice for AWS: https://www.scientiamobile.com/products/wurfl-device-detection-microservice-aws/

- WURFL Microservice for Azure: https://www.scientiamobile.com/products/wurfl-microservice-for-azure/

- WURFL Microservice for Google Cloud Platform: https://www.scientiamobile.com/products/wurfl-microservice-for-gcp/

Python implementation of the WM Client api.
Requires:
- Python 3.x
- pip
- pycurl module (you can install it with `pip install pycurl`)
- requests module (you can install it with `pip install requests`)
- pylru module (you can install it with `pip install pylru`)

The Example project contains an example of client api usage for a script :


```python
from wmclient import *
from requests import Request as HttpRequest

try:
    client = WmClient.create("http", "localhost", 8080, "")

    info = client.get_info()
    print("Printing WM server information")
    print("WURFL API version: " + info.wurfl_api_version)
    print("WM server version:  " + info.wm_version)
    print("Wurfl file info: " + info.wurfl_info)

    ua = "Mozilla/5.0 (Linux; Android 7.1.1; ONEPLUS A5000 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) " \
         "Chrome/56.0.2924.87 Mobile Safari/537.36 "

    req_headers = {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "en-US,en;q=0.9",
        "Referer": "http://itvv.net/",
        "User-Agent": "Mozilla/5.0 (Linux; U; Android 7.1.1; XT1635-02 Build/NPN26.107; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.127 Mobile Safari/537.36 OPR/51.0.2254.150807",
        "X-Forwarded-For": "157.32.186.226",
        "X-Requested-With": "com.opera.mini.native"
    }
    req = HttpRequest('GET', "http://mywebsite.com", headers=req_headers)

    client.set_requested_static_capabilities(["brand_name", "model_name"])
    client.set_requested_virtual_capabilities(["is_smartphone", "form_factor"])
    print()
    print("Detecting device for user-agent: " + ua)

    # Perform a device detection calling WM server API
    device = client.lookup_request(req)

    if device.error is not None and len(device.error) > 0:
        print("An error occurred: " + device.error)
    else:
        # Let's get the device capabilities and print some of them
        capabilities = device.capabilities
        print("Detected device WURFL ID: " + capabilities["wurfl_id"])
        print("Device brand & model: " + capabilities["brand_name"] + " " + capabilities["model_name"])
        print("Detected device form factor: " + capabilities["form_factor"])
        if capabilities["is_smartphone"] == "true":
            print("This is a smartphone")
            # Iterate over all the device capabilities and print them
            print("All received capabilities");
            for k in capabilities:
                print(k + ": " + capabilities[k])

            # Get all the device manufacturers, and print the first twenty
            print()
            limit = 20
            deviceMakes = client.get_all_device_makes()
            print("Print the first {} Brand of {} retrieved from server\n".format(limit, len(deviceMakes)))

            # Sort the device manufacturer names
            list.sort(deviceMakes)
            for i in range(limit):
                print(" - {}\n".format(deviceMakes[i]))

            # Now call the WM server to get all device model and marketing names produced by Apple
            print("Print all Model for the Apple Brand")
            devNames = client.get_all_devices_for_make("Apple")

            for model_mkt_name in devNames:
                print(" - {} {}\n".format(model_mkt_name.brand_name, model_mkt_name.model_name))

            # Now call the WM server to get all operative system names
            print("Print the list of OSes")
            oses = client.get_all_OSes()
            # Sort and print all OS names
            list.sort(oses)
            for os in oses:
                print(" - {}\n".format(os))

            # Let's call the WM server to get all version of the Android OS
            print("Print all versions for the Android OS")
            osVersions = client.get_all_versions_for_OS("Android")
            # Sort all Android version numbers and print them.
            list.sort(osVersions)
            for ver in osVersions:
                print(" - {}\n".format(ver))

except WmClientError as wme:
    # problems such as network errors  or internal server problems
    print("An error has occurred: " + wme.message)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "wmclient",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "device, mobile, device detection, analytics",
    "author": null,
    "author_email": "\"Scientiamobile Inc.\" <support@scientiamobile.com>",
    "download_url": "https://files.pythonhosted.org/packages/8b/65/ea49dafc06f9593ff144a581af40c087a836ff93681877ad21e6ce4fa6b7/wmclient-2.3.1.tar.gz",
    "platform": null,
    "description": "# wmclient - WURFL Microservice Client for Python\n\n## Differences between version 2.2.0 and previous ones.\n\nVersion 2.2.0 makes WURFL microservice client backward compatible with Python 2.7. To do that it replaces two libraries that are available for Python 3.x only:\n\n- pywurfl (replaced by urrllib3)\n- @lru_cache (replaced by pylru)\n\nWhile in older versions cache was used by default, in this version you'll have to use the `set_cache_size` function of the client to ensure it is created and used.\n\n## Python WURFL Microservice Client\n\nWURFL Microservice (by ScientiaMobile, Inc.) is a mobile device detection service that can quickly and accurately detect over 500 capabilities of visiting devices. It can differentiate between portable mobile devices, desktop devices, SmartTVs and any other types of devices that have a web browser.\n\nThis is the Python Client API for accessing the WURFL Microservice. The API is released under Open-Source and can be integrated with other open-source or proprietary code. In order to operate, it requires access to a running instance of the WURFL Microservice product, such as:\n\n- WURFL Microservice for Docker: https://www.scientiamobile.com/products/wurfl-microservice-docker-detect-device/\n\n- WURFL Microservice for AWS: https://www.scientiamobile.com/products/wurfl-device-detection-microservice-aws/\n\n- WURFL Microservice for Azure: https://www.scientiamobile.com/products/wurfl-microservice-for-azure/\n\n- WURFL Microservice for Google Cloud Platform: https://www.scientiamobile.com/products/wurfl-microservice-for-gcp/\n\nPython implementation of the WM Client api.\nRequires:\n- Python 3.x\n- pip\n- pycurl module (you can install it with `pip install pycurl`)\n- requests module (you can install it with `pip install requests`)\n- pylru module (you can install it with `pip install pylru`)\n\nThe Example project contains an example of client api usage for a script :\n\n\n```python\nfrom wmclient import *\nfrom requests import Request as HttpRequest\n\ntry:\n    client = WmClient.create(\"http\", \"localhost\", 8080, \"\")\n\n    info = client.get_info()\n    print(\"Printing WM server information\")\n    print(\"WURFL API version: \" + info.wurfl_api_version)\n    print(\"WM server version:  \" + info.wm_version)\n    print(\"Wurfl file info: \" + info.wurfl_info)\n\n    ua = \"Mozilla/5.0 (Linux; Android 7.1.1; ONEPLUS A5000 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) \" \\\n         \"Chrome/56.0.2924.87 Mobile Safari/537.36 \"\n\n    req_headers = {\n        \"Accept\": \"*/*\",\n        \"Accept-Encoding\": \"gzip, deflate\",\n        \"Accept-Language\": \"en-US,en;q=0.9\",\n        \"Referer\": \"http://itvv.net/\",\n        \"User-Agent\": \"Mozilla/5.0 (Linux; U; Android 7.1.1; XT1635-02 Build/NPN26.107; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.127 Mobile Safari/537.36 OPR/51.0.2254.150807\",\n        \"X-Forwarded-For\": \"157.32.186.226\",\n        \"X-Requested-With\": \"com.opera.mini.native\"\n    }\n    req = HttpRequest('GET', \"http://mywebsite.com\", headers=req_headers)\n\n    client.set_requested_static_capabilities([\"brand_name\", \"model_name\"])\n    client.set_requested_virtual_capabilities([\"is_smartphone\", \"form_factor\"])\n    print()\n    print(\"Detecting device for user-agent: \" + ua)\n\n    # Perform a device detection calling WM server API\n    device = client.lookup_request(req)\n\n    if device.error is not None and len(device.error) > 0:\n        print(\"An error occurred: \" + device.error)\n    else:\n        # Let's get the device capabilities and print some of them\n        capabilities = device.capabilities\n        print(\"Detected device WURFL ID: \" + capabilities[\"wurfl_id\"])\n        print(\"Device brand & model: \" + capabilities[\"brand_name\"] + \" \" + capabilities[\"model_name\"])\n        print(\"Detected device form factor: \" + capabilities[\"form_factor\"])\n        if capabilities[\"is_smartphone\"] == \"true\":\n            print(\"This is a smartphone\")\n            # Iterate over all the device capabilities and print them\n            print(\"All received capabilities\");\n            for k in capabilities:\n                print(k + \": \" + capabilities[k])\n\n            # Get all the device manufacturers, and print the first twenty\n            print()\n            limit = 20\n            deviceMakes = client.get_all_device_makes()\n            print(\"Print the first {} Brand of {} retrieved from server\\n\".format(limit, len(deviceMakes)))\n\n            # Sort the device manufacturer names\n            list.sort(deviceMakes)\n            for i in range(limit):\n                print(\" - {}\\n\".format(deviceMakes[i]))\n\n            # Now call the WM server to get all device model and marketing names produced by Apple\n            print(\"Print all Model for the Apple Brand\")\n            devNames = client.get_all_devices_for_make(\"Apple\")\n\n            for model_mkt_name in devNames:\n                print(\" - {} {}\\n\".format(model_mkt_name.brand_name, model_mkt_name.model_name))\n\n            # Now call the WM server to get all operative system names\n            print(\"Print the list of OSes\")\n            oses = client.get_all_OSes()\n            # Sort and print all OS names\n            list.sort(oses)\n            for os in oses:\n                print(\" - {}\\n\".format(os))\n\n            # Let's call the WM server to get all version of the Android OS\n            print(\"Print all versions for the Android OS\")\n            osVersions = client.get_all_versions_for_OS(\"Android\")\n            # Sort all Android version numbers and print them.\n            list.sort(osVersions)\n            for ver in osVersions:\n                print(\" - {}\\n\".format(ver))\n\nexcept WmClientError as wme:\n    # problems such as network errors  or internal server problems\n    print(\"An error has occurred: \" + wme.message)\n```\n",
    "bugtrack_url": null,
    "license": "apache-2.0",
    "summary": "WURFL Microservice client for Python",
    "version": "2.3.1",
    "project_urls": {
        "Homepage": "https://github.com/WURFL/wurfl-microservice-client-python"
    },
    "split_keywords": [
        "device",
        " mobile",
        " device detection",
        " analytics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c04e2ce00d2673e351d0349d23c9748f8ab12915a7c51aed81154c46070c449",
                "md5": "35e194fef5fac4d5bb980f7699c8723a",
                "sha256": "ac63954ec7ffec659842a21f8d3881ffc6d823fda4f5b2d5daabbef204ede049"
            },
            "downloads": -1,
            "filename": "wmclient-2.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "35e194fef5fac4d5bb980f7699c8723a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 19925,
            "upload_time": "2024-10-28T14:10:10",
            "upload_time_iso_8601": "2024-10-28T14:10:10.894304Z",
            "url": "https://files.pythonhosted.org/packages/5c/04/e2ce00d2673e351d0349d23c9748f8ab12915a7c51aed81154c46070c449/wmclient-2.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b65ea49dafc06f9593ff144a581af40c087a836ff93681877ad21e6ce4fa6b7",
                "md5": "2f8a4d80aac91af4c6e3f9cbe036d7e5",
                "sha256": "43f279aa57206b78a5a37778e4a6bfaef9bf014702ccf42b46f35242b357df0c"
            },
            "downloads": -1,
            "filename": "wmclient-2.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2f8a4d80aac91af4c6e3f9cbe036d7e5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14579,
            "upload_time": "2024-10-28T14:10:12",
            "upload_time_iso_8601": "2024-10-28T14:10:12.448135Z",
            "url": "https://files.pythonhosted.org/packages/8b/65/ea49dafc06f9593ff144a581af40c087a836ff93681877ad21e6ce4fa6b7/wmclient-2.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-28 14:10:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "WURFL",
    "github_project": "wurfl-microservice-client-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "wmclient"
}
        
Elapsed time: 0.77955s