Example #1
0
 def _get_ft_client():
     cl = FT(settings.FT_CONSUMER_KEY, settings.FT_CONSUMER_SECRET,
             settings.FT_TOKEN, settings.FT_SECRET)
     table_id = cl.table_id(settings.FT_TABLE)
     if not table_id:
         raise Exception("Create areas %s first" % settings.FT_TABLE)
     return cl
 def _get_ft_client():
     cl = FT(settings.FT_CONSUMER_KEY,
             settings.FT_CONSUMER_SECRET,
             settings.FT_TOKEN,
             settings.FT_SECRET)
     table_id = cl.table_id(settings.FT_TABLE)
     if not table_id:
         raise Exception("Create areas %s first" % settings.FT_TABLE)
     return cl
    def kml(self, table, row_id):
        cl = FT(settings.FT_CONSUMER_KEY, settings.FT_CONSUMER_SECRET, settings.FT_TOKEN, settings.FT_SECRET)

        # TODO: do this better
        if table == 1568452:
            id = "ex_area"
        else:
            id = "name"

        info = cl.sql("select geometry from %s where %s = %s" % (table, id, row_id))
        polygon = info.split("\n")[1]
        polygon = polygon.replace('"', "")
        return polygon
def create_table():
    cl = FT(settings.FT_CONSUMER_KEY, settings.FT_CONSUMER_SECRET,
            settings.FT_TOKEN, settings.FT_SECRET)
    table_desc = {
        settings.FT_TABLE: {
            'added_on': 'DATETIME',
            'type': 'NUMBER',
            'geo': 'LOCATION',
            'rowid_copy': 'NUMBER',
            'asset_id': 'NUMBER',
            'report_id': 'NUMBER',
        }
    }

    return str(cl.create_table(table_desc))
def create_table():
    cl = FT(settings.FT_CONSUMER_KEY,
            settings.FT_CONSUMER_SECRET,
            settings.FT_TOKEN,
            settings.FT_SECRET)
    table_desc = {settings.FT_TABLE: {
       'added_on': 'DATETIME',
       'type': 'NUMBER',
       'geo': 'LOCATION',
       'rowid_copy': 'NUMBER',
       'asset_id': 'NUMBER',
       'report_id': 'NUMBER',
    }}

    return str(cl.create_table(table_desc))
    def kml(self, table, row_id):
        cl = FT(settings.FT_CONSUMER_KEY, settings.FT_CONSUMER_SECRET,
                settings.FT_TOKEN, settings.FT_SECRET)

        #TODO: do this better
        if (table == 1568452):
            id = 'ex_area'
        else:
            id = 'name'

        info = cl.sql("select geometry from %s where %s = %s" %
                      (table, id, row_id))
        polygon = info.split('\n')[1]
        polygon = polygon.replace("\"", "")
        return polygon
    def kml(self, table, row_id):
        cl = FT(settings.FT_CONSUMER_KEY,
                settings.FT_CONSUMER_SECRET,
                settings.FT_TOKEN,
                settings.FT_SECRET)

        #TODO: do this better
        if (table == 1568452):
          id = 'ex_area'
        else:
          id = 'name'

        info = cl.sql("select geometry from %s where %s = %s" % 
            (table, id, row_id))
        polygon = info.split('\n')[1]
        polygon = polygon.replace("\"", "")
        return polygon
def fusion_tables_names():
    """ precache de fusion tables names """
    for x in FustionTablesNames.all():
        x.delete()

    cl = FT(settings.FT_CONSUMER_KEY, settings.FT_CONSUMER_SECRET,
            settings.FT_TOKEN, settings.FT_SECRET)

    for desc, table, name in tables:
        info = cl.sql("select %s, description from %s" % (name, table))
        data = []
        # sorry
        for line in info.split('\n')[1:]:
            if line:
                tk = line.split(',')
                #TODO: fix html decoding
                data.append((tk[0], tk[1]))

        FustionTablesNames(table_id=str(table),
                           json=json.dumps(dict(data))).put()

    return "working"
def fusion_tables_names():
    """ precache de fusion tables names """
    for x in FustionTablesNames.all():
        x.delete()

    cl = FT(settings.FT_CONSUMER_KEY,
            settings.FT_CONSUMER_SECRET,
            settings.FT_TOKEN,
            settings.FT_SECRET)

    for desc, table, name in tables:
        info = cl.sql("select %s, description from %s" % (name, table))
        data = []
        # sorry
        for line in info.split('\n')[1:]: 
            if line:
                tk = line.split(',')
                #TODO: fix html decoding
                data.append((tk[0], tk[1]))

        FustionTablesNames(table_id=str(table), json=json.dumps(dict(data))).put()

    return "working"
def show_tables():
    cl = FT(settings.FT_CONSUMER_KEY, settings.FT_CONSUMER_SECRET,
            settings.FT_TOKEN, settings.FT_SECRET)
    return '\n'.join(map(str, cl.get_tables()))
def show_tables():
    cl = FT(settings.FT_CONSUMER_KEY,
            settings.FT_CONSUMER_SECRET,
            settings.FT_TOKEN,
            settings.FT_SECRET)
    return '\n'.join(map(str, cl.get_tables()))