Package: wmclient
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-device-detection-microservice-azure/Python implementation of the WM Client api.Requires:Python 2.7 or 3.xpippycurl module (you can install it withpip install pycurl)The Example project contains an example of client api usage for a script
:fromwmclientimportWmClient,WmClientErrortry: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 "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 APIdevice=client.lookup_useragent(ua)ifdevice.errorisnotNoneandlen(device.error)>0:print("An error occurred: "+device.error)else:# Let's get the device capabilities and print some of themcapabilities=device.capabilitiesprint("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"])ifcapabilities["is_smartphone"]=="true":print("This is a smartphone")# Iterate over all the device capabilities and print themprint("All received capabilities");forkincapabilities:print(k+": "+capabilities[k])# Get all the device manufacturers, and print the first twentyprint()limit=20deviceMakes=client.get_all_device_makes()print("Print the first{}Brand of{}retrieved from server\n".format(limit,len(deviceMakes)))# Sort the device manufacturer nameslist.sort(deviceMakes)foriinrange(limit):print(" -{}\n".format(deviceMakes[i]))# Now call the WM server to get all device model and marketing names produced by Appleprint("Print all Model for the Apple Brand")devNames=client.get_all_devices_for_make("Apple")formodel_mkt_nameindevNames:print(" -{}{}\n".format(model_mkt_name.brand_name,model_mkt_name.model_name))# Now call the WM server to get all operative system namesprint("Print the list of OSes")oses=client.get_all_OSes()# Sort and print all OS nameslist.sort(oses)forosinoses:print(" -{}\n".format(os))# Let's call the WM server to get all version of the Android OSprint("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)forverinosVersions:print(" -{}\n".format(ver))exceptWmClientErroraswme:# problems such as network errors  or internal server problemsprint("An error has occurred: "+wme.message)