PyWURFL - WURFL InFuze Module for Python

PyWURFL is a Python module wrapping the InFuze WURFL C API and encapsulating it in an object oriented manner, to provide a fast, intuitive interface. Both Python2 and Python3 builds are supported.

Installing libwurfl

In order for the Module to work it is ESSENTIAL that the libwurfl library is installed on your system. libwurfl is provided in your Customer Vault/FileX.

If you have not already installed libwurfl, instructions can be found here. Release notes for each API can be found here.


PyWURFL is installed and tested using the Python virtualenv and easy_install utilities.

Python development headers and setuptools must also be installed.

On Debian this is done by:

$ apt-get install python-dev python-setuptools

On CentOS this is done by:

$ yum install python-dev python-virtualenv

Please note that in Python3 the virtualenv command has been superseded by pyvenv. Please check your system documentation as needed.

Also, the usual C development toolchain must be available.

If needed, virtualenv can be used to create several local Python installations. This can be useful to test your code under different Python versions without polluting the system's Python interpreter.


PyWURFL is distributed as a Python "egg" and can be installed using easy_install.

Once you have obtained the egg from your File Manager and installed the InFuze WURFL library, run the following command:

$ easy_install pywurfl-<version>-py<version>-<architecture>-x86_64.egg

Sample Usage

Here is an example to get started using PyWURFL:

#import WURFL module
from pywurfl.wurfl import Wurfl

# build an engine. Please note that the installed position may change.
# for example, on OS X systems, it will be in `/usr/local/share/wurfl/`
# on Linux systems, it will be in `/usr/share/wurfl/`.
wurfl = Wurfl('/usr/share/wurfl/')

# lookup a user agent
UA = "Mozilla/5.0 (Linux; Android 5.0; SAMSUNG SM-G925 Build/LRX21V) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36"
dev = wurfl.parse_useragent(UA)

# retrieve some properties and capabilities values

#device ID:
print("device id =",

# some static capabilities:
static_capabilities = ["model_name", "brand_name", "device_os"]

# retrieve the value of a single static capability:
print("get_capability('brand_name') =", dev.get_capability(static_capabilities[0]))

# retrieve the value of many static capabilities at once:
print("get_capabilities(static_capabilities) =", dev.get_capabilities(static_capabilities))

# some virtual capabilities:
virtual_capabilities = ["complete_device_name", "form_factor"]

# retrieve the value of a single virtual capability:
print("get_virtual_capability('complete_device_name') =", dev.get_virtual_capability(virtual_capabilities[0]))

# retrieve the value of many virtual capabilities at once:
print("get_virtual_capabilities(virtual_capabilities) =", dev.get_virtual_capabilities(virtual_capabilities))

# release the device when not needed any more.

Here we create the engine object, then obtain the device object through lookup on a user agent string. Then we get device properties and static and virtual capability values as needed. Please note that virtual capabilities are calculated at runtime, so they might be significantly slower than static capabilities.

By running the above code, you should get an output like:

device id = samsung_sm_g925_ver1
get_capability('brand_name') = SM-G925
get_capabilities(static_capabilities) = {'model_name': 'SM-G925', 'brand_name': 'Samsung', 'device_os': 'Android'}
get_virtual_capability('complete_device_name') = Samsung SM-G925 (Galaxy S6 Edge)
get_virtual_capabilities(virtual_capabilities) = {'form_factor': 'Smartphone', 'complete_device_name': 'Samsung SM-G925 (Galaxy S6 Edge)'}

WURFL Updater

If you want to keep your up-to-date with ScientiaMobile's data release schedule, please consider using the Updater features, available in WURFL InFuze for Python as follows:

After creating your WURFL engine, set your personal WURFL Snapshot URL (in the form "", with "xxxxx" replaced with your personal access token, located in your license account page):

wurfl = Wurfl('')
    wurfl.set_updater_data_url("<your access token>/")
except Exception as exception:
    print("Error while setting updater data URL: ")

Optionally, specify the frequency you want to check for updates: (DAILY or WEEKLY, default is DAILY):


Then start the updater:

except Exception as exception:
    print("Error while starting the updater: ")

Updater will run a periodic check for the latest release of the file, download it, and update the running engine to the latest version - all during normal application operations.

The internal updater also supports simple file logging, useful in debugging network problems and the like:


Please note that:

  • The WURFL data file and the path where it resides, specified in the WURFL engine construction, MUST have write/rename access: the old data file will be replaced (i.e. a rename operation will be performed) with the updated version upon successful update operation completion, and the directory will be used for temp file creation, etc.

  • ScientiaMobile does not distribute uncompressed XML data files via updater. This means that, if you plan to use the updater, you MUST use the compressed (i.e. a ZIP or a XML.GZ) data file in the engine construction call..

set_updater_data_frequency() sets how often the updater checks for an updated data file, not how often the engine data file is actually updated.

The WURFL InFuze Updater functionality relies on availability and features of the well-known and widely available curl command-line utility. A check for curl availability is done in the set_updater_data_url() call.

© 2019 ScientiaMobile Inc.
All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of ScientiaMobile Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to ScientiaMobile Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from ScientiaMobile Incorporated. include('layouts.partials.license-footer')