Ejemplo n.º 1
0
def wurfl(handler, url=''):
    try:
        StandardDevice.objects.all().delete()
        stats = parse_wurfl(handler)
    except Exception, err:
        transaction.rollback()
        stats = {'errors': [err]}
Ejemplo n.º 2
0
def hybrid():
    updates = []
    # First, truncate then build the patch table
    # :TODO: rewrite if/when a objects.truncate() becomes available
    PatchDevice.objects.all().delete()
    # Get all active patches to apply in order
    patches = Patch.objects.filter(active=True).order_by('priority', 'created')
    
    stats = {'errors':[]}
    for patch in patches:
        try:
            stats_patch = parse_wurfl(StringIO(patch.patch), device_class=PatchDevice, merge=True)
            for (key, val) in stats_patch.items():
                if key in stats:
                    stats[key] += stats_patch[key]
                else:
                    stats[key] = stats_patch[key]
        except Exception, err:
            stats['errors'].append('In patch `%s` : %s' % (patch.name,err,))