def __init__(self, wrap_app):
     self.wrap_app = wrap_app
     # Create a Wurfl Cloud Config
     config = utils.load_config('filecache_config.conf')
     # Create a WURFL Cache Loader
     cache = utils.get_cache(config)
     # Create a WURFL Cloud Client
     self.Client = Cloud(config, cache)
Exemplo n.º 2
0
def index():
    # Client UA
    ua = request.headers.get('User-Agent')

    # Cloud client stuf
    config = utils.load_config('/home/joe/code/python/adtech-demo/app/filecache_config.conf')
    cache = utils.get_cache(config)
    client = WurflCloud(config, cache)
    device = client(ua, capabilities=["resolution_height", "resolution_width"])

    

    user_agent = {'User-agent': ua}
    title = "ad:tech 2014"
    h = requests.get('http://www.scientiamobile.com/site/header', headers=user_agent)
    switch = h.text
    h1 = switch.replace('<a href="/', '<a href="http://www.scientiamobile.com/')
    header = h1.replace('src="/', '<img src="http://www.scientiamobile.com/')

    f = requests.get('http://www.scientiamobile.com/site/footer', headers=user_agent)
    f1 = f.text
    fswitch = f1.replace('<a href="/', '<a href="http://www.scientiamobile.com/')
    footer = fswitch.replace('src="/', '<img src="http://www.scientiamobile.com/')
    return render_template('index.html',title=title, header=header, footer=footer, device=device)
Exemplo n.º 3
0
 def __init__(self, df):
     self.df_w = df
     self.ua_in = self.df_w['user_agent']
     self.config = utils.load_config(sys.argv[1]) #load config and cache files
     self.cache = utils.get_cache(self.config)
import sys

from wurfl_cloud import Cloud
from wurfl_cloud import utils


if len(sys.argv) != 2:
    print "usage:  python example_command.py [config file]"
    sys.exit(1)

ua =  ur'''Mozilla/5.0 (Linux; U; Android 1.5; en-gb; T-Mobile G1 Build/CRB17) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1'''

config = utils.load_config(sys.argv[1])
cache = utils.get_cache(config)
cloud = Cloud(config, cache)

try:
    dev1 = cloud(ua, capabilities=["model_name", "pointing_method"])
    if not dev1["errors"]:
        print "dev1"
        print "===="
        print "'%s': %s" % ("model_name", dev1["capabilities"]["model_name"])
        print "'%s': %s" % ("pointing_method",
                            dev1["capabilities"]["pointing_method"])
    else:
        print "dev1"
        print dev1["errors"]
except LookupError as e:
    print "dev1", "==>", e
print