Rohmad Hidayat's Blog


My Notes on Mobile Technology, Python GUI, Python Web Framework, Software Development, Database, Server, Embedded System, Mini Computer

Parallel Processing and Multiprocessing in Python

A number of Python-related libraries exist for the programming of solutions either employing multiple CPUs or multicore CPUs in a symmetric multiprocessing (SMP) or shared memory environment, or potentially huge numbers of computers in a cluster or grid environment. This page seeks to provide references to the different libraries and solutions available.

Filed under: Python

A minimal mobile-aware web app with Python & cloud-based device detection

In this article we’ll look at a how to make a minimal device-aware web application. The point of this article is not to demonstrate a useful application but rather to show just how little code is required to make an app that is fully device aware, and that can change its presentation entirely depending on the nature of the device accessing it.

To keep things simple and lightweight we’ll use Python in conjunction with and DeviceAtlas Personal (the cloud-based version of DeviceAtlas). is a minimalist Python web framework that suits this example because it is simple and lightweight but the techniques demonstrated here will work equally well in any other web framework. You will need to install if you want to run this example.


DeviceAtlas Personal is a device detection web service that requires no installation, configuration or maintenance – it just works. To make this easier to incorporate into a Python project I’ve attached a Python module to this article that wraps the web service into a convenience function that does everything you need.

Without further ado, here is the code:

import web
from DeviceAtlas import DaPersonal
urls = ( '/', 'index',)
app = web.application(urls, globals())
pageTemplate = '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" ""><html xmlns=""> <head> <title>test page</title></head><body><p>Hello, %s user</p><p>%s</p></body></html>'
class index:
    def GET(self):
        props = DaPersonal.get_device_properties(web.ctx.env['HTTP_USER_AGENT'])
        if props.has_key('mobileDevice') and props['mobileDevice']:
            return pageTemplate % ('mobile', props)
            return pageTemplate % ('sedentary', '')
if __name__ == "__main__":

Run the server as follows:


Now, accessing the URL http://localhost:8080/ will result in two different outputs:

Desktop browser

Hello, sedentary user

Mobile browser

Hello, mobile user

{u’mobileDevice’: True, u’isBrowser’: False, u’displayWidth’: 320, u’displayHeight’: 480, ‘_source’: ‘cache’}


  • Caching – DeviceAtlas Personal is best used in conjunction with local caching to avoid the delay incurred by the round-trip to our servers. For new devices that have not been seen before and hence are not in the cache, the detection time is typically in the order of 500ms; for previously-seen (cached) devices it is unmeasurably small (less than 1ms). Caching is enabled by default in the module but you will need to create the appropriate directory for it (typically /tmp/DeviceAtlasCache).
  • DeviceAtlas Personal – this is a preview version of the service, and right now we make no guarantees about stability, performance, or uptime.
  • Deployment – this application can be run as a standalone application that implements its own HTTP stack, or run as a CGI, or WSGI, or mod_python application with Apache / Lighttpd / nginx

Closing Comments

This is an extremely simple application, clearly, but it nonetheless demonstrates a couple of key points:

  • Device adaptation need not be complex. In this application cloud-based detection has completely removed this burden, and yet is accurate and very fast
  • Adapting websites do not necessarily require complex frameworks and lots of code


Filed under: Catatan Lepas, Programming, Python

Update Software Penyusunan ASB V3.07

Developer MGSI segera melakukan update 1. Aplikasi Penyusuna ASB dengan menggunakan temporary table sbg media proses penghitungan koeffisien model 2. Update dan Pengembangan SIM ASET 3. Update dan Pengembangan SIM Parkir bagi klien yg menggunakan produk kami. segera kami kirim update terbaru. Salam

Filed under: Product, Programming, Python, Update Software