def run(offset=0):
  redisUrl = urlparse.urlparse(REDIS_URL)
  redisClient = redis.Redis(
    host=redisUrl.hostname, port=redisUrl.port,
    db=REDIS_DB, password=redisUrl.password
  )
  count = offset
  catalog = createCatalog(offset=offset)

  for page in catalog:
    for resource in page:
      if shouldProcess(redisClient, resource):
        processResource(redisClient, resource)
      else:
        print "Skipped {}".format(resource.getId())
      count += 1
      if count % 10 == 0:
        keyCount = len(redisClient.keys("*"))
        percStored = float(keyCount) / float(count)
        print colored(
          "Inspected %i streams, stored %i temporal streams (%f)."
          % (count, keyCount, percStored),
          "cyan"
        )
Esempio n. 2
0
GOOGLE_MAPS_API_KEY = os.environ["GOOGLE_MAPS_API_KEY"]
REDIS_URL = os.environ["REDIS_URL"]
REDIS_DB = 1
POOL = None

urls = (
  "/", "index",
  "/catalog", "catalog",
  "/catalog/(.+)", "catalog",
  "/resource/(.+)", "resource",
  "/list", "list",
)
app = web.application(urls, globals())
render = web.template.render('templates/')
redisUrl = urlparse.urlparse(REDIS_URL)
cat = createCatalog()

# def createConnectionPool():
#   redisUrl = urlparse.urlparse(REDIS_URL)
#   print redisUrl.hostname
#   print redisUrl.port
#   return redis.ConnectionPool(
#     host=redisUrl.hostname, port=redisUrl.port,
#     db=REDIS_DB, password=redisUrl.password
#   )


def chunks(l, n):
  """Yield successive n-sized chunks from l."""
  for i in xrange(0, len(l), n):
    yield l[i:i + n]
Esempio n. 3
0
#!/usr/bin/env python

from sodatap import createCatalog

catalog = createCatalog()
print type(catalog)
page = catalog[0]
# for resource in page:
resource = page[1]
print resource.hasMultipleSeries()

# for page in catalog:
#   for resource in page:
#     print resource