Exemplo n.º 1
0
    conn.close()


if __name__ == '__main__':
    try:
        force_queue = argv[1:][0]
    except IndexError:
        force_queue = None

    due = time() + 55

    logging.basicConfig(level=logging.INFO)

    bucket = connect_bucket(key, secret, prefix + 'stuff')

    queue_create = connect_queue(key, secret, prefix + 'create')
    queue_tile = connect_queue(key, secret, prefix + 'tile')

    while time() < due:
        #
        if force_queue == "create":
            message = queue_create.get_messages(visibility_timeout=5)
            if message:
                process_queue(queue_create, message, bucket)

        elif force_queue == "tile":
            message = queue_tile.get_messages(visibility_timeout=5)
            if message:
                process_queue(queue_tile, message, bucket)

        else:
Exemplo n.º 2
0
    conn.close()
    
if __name__ == '__main__': 
    try:
        force_queue = argv[1:][0]
    except IndexError:
        force_queue = None
     
   
    due = time() + 55
    
    logging.basicConfig(level=logging.INFO)

    bucket = connect_bucket(key, secret, prefix+'stuff')
    
    queue_create = connect_queue(key, secret, prefix+'create') 
    queue_tile = connect_queue(key, secret, prefix+'tile')
    
    while time() < due:
        #
        if force_queue == "create":
            message = queue_create.get_messages(visibility_timeout=5)
            if message:
                process_queue(queue_create, message, bucket) 
                
        elif force_queue == "tile":
            message = queue_tile.get_messages(visibility_timeout=5)
            if message:
                process_queue(queue_tile, message, bucket) 
                
        else:
Exemplo n.º 3
0
from PIL import Image
from PIL.ImageStat import Stat
from StringIO import StringIO
from urllib import urlopen, quote_plus

from flask import Flask, request, redirect, render_template, jsonify, make_response, abort
from mysql.connector import connect, cursor

from util import connect_queue, get_config_vars, get_all_records
from data import place_roughly, choose_map, create_atlas  
from relative_time import timesince

aws_key, aws_secret, aws_prefix, mysql_hostname, mysql_username, mysql_database, mysql_password, mysql_port =  get_config_vars(dirname(__file__)) 

queue_create = connect_queue(aws_key, aws_secret, aws_prefix+'create') 
queue_tile = connect_queue(aws_key, aws_secret, aws_prefix+'tile')

def mysql_connection():
    conn = connect(user=mysql_username, password=mysql_password, database=mysql_database, host=mysql_hostname, port=mysql_port, autocommit=True)
    conn.autocommit = True
    return conn

class MySQLCursorDict(cursor.MySQLCursor):
    def fetchdict(self):
        row = self.fetchone()
        if row:
            return dict(zip(self.column_names, row))
        return None
    
    def fetchdicts(self):
Exemplo n.º 4
0
from PIL import Image
from PIL.ImageStat import Stat
from StringIO import StringIO
from urllib import urlopen, quote_plus

from flask import Flask, request, redirect, render_template, jsonify, make_response, abort
from mysql.connector import connect, cursor

from util import connect_queue, get_config_vars, get_all_records
from data import place_roughly, choose_map, create_atlas
from relative_time import timesince

aws_key, aws_secret, aws_prefix, mysql_hostname, mysql_username, mysql_database, mysql_password, mysql_port = get_config_vars(
    dirname(__file__))

queue_create = connect_queue(aws_key, aws_secret, aws_prefix + 'create')
queue_tile = connect_queue(aws_key, aws_secret, aws_prefix + 'tile')


def mysql_connection():
    conn = connect(user=mysql_username,
                   password=mysql_password,
                   database=mysql_database,
                   host=mysql_hostname,
                   port=mysql_port,
                   autocommit=True)
    conn.autocommit = True
    return conn


class MySQLCursorDict(cursor.MySQLCursor):