Example #1
0
        def __purge(self):
            db = Database()
            cursor = db.cursor()

            cursor.execute("""SELECT COUNT(*)
                                FROM changesets
                                JOIN customchangesets ON (customchangesets.changeset=changesets.id)
                               WHERE time < NOW() - INTERVAL '3 months'""")
            npurged = cursor.fetchone()[0]

            if npurged:
                self.info("purging %d old custom changesets" % npurged)

                cursor.execute(
                    "DELETE FROM changesets USING customchangesets WHERE id=changeset AND time < NOW() - INTERVAL '3 months'"
                )
                db.commit()

            db.close()
Example #2
0
        def __purge(self):
            db = Database()
            cursor = db.cursor()

            cursor.execute("""SELECT COUNT(*)
                                FROM changesets
                                JOIN customchangesets ON (customchangesets.changeset=changesets.id)
                               WHERE time < NOW() - INTERVAL '3 months'""")
            npurged = cursor.fetchone()[0]

            if npurged:
                self.info("purging %d old custom changesets" % npurged)

                cursor.execute("DELETE FROM changesets USING customchangesets WHERE id=changeset AND time < NOW() - INTERVAL '3 months'")
                db.commit()

            db.close()
Example #3
0
if "--json-job" in sys.argv[1:]:
    from resource import getrlimit, setrlimit, RLIMIT_RSS
    from traceback import print_exc

    soft_limit, hard_limit = getrlimit(RLIMIT_RSS)
    rss_limit = configuration.services.CHANGESET["rss_limit"]
    if soft_limit < rss_limit:
        setrlimit(RLIMIT_RSS, (rss_limit, hard_limit))

    from changeset.create import createChangeset
    from textutils import json_decode, json_encode

    request = json_decode(sys.stdin.read())

    try:
        db = Database()

        createChangeset(db, request)

        db.close()

        sys.stdout.write(json_encode(request))
    except:
        print "Request:"
        print json_encode(request, indent=2)
        print

        print_exc(file=sys.stdout)
else:
    from background.utils import JSONJobServer
Example #4
0
    NATIONALITIES[1]: pl_coordinates,
    NATIONALITIES[2]: lv_coordinates,
    NATIONALITIES[3]: lt_coordinates,
    NATIONALITIES[4]: ua_coordinates
}

uniq_names = get_uniq_names(NAMES_FILE)

logging.debug('by max_latitude: %s', by_coordinates.max_latitude())
logging.debug("by min_latitude: %s", by_coordinates.min_latitude())
logging.debug("by max_longitude: %s", by_coordinates.max_longitude())
logging.debug("by min_longitude: %s", by_coordinates.max_longitude())

logging.info('Creating the database connection')
try:
    db = Database()
    cursor = db.cursor()
    db.create_tables()
except Exception as e:
    logging.CRITICAL("Unable to create the database: %s", e)


for nationality in NATIONALITIES:
    for i in range(1000):
        name = random.choice(uniq_names)
        random_lat = random.uniform(
            NATIONAL_COORDINATES[nationality].min_latitude(),
            NATIONAL_COORDINATES[nationality].max_latitude()
            )
        random_long = random.uniform(
            NATIONAL_COORDINATES[nationality].min_longitude(),
Example #5
0
if "--json-job" in sys.argv[1:]:
    from resource import getrlimit, setrlimit, RLIMIT_RSS
    from traceback import print_exc

    soft_limit, hard_limit = getrlimit(RLIMIT_RSS)
    rss_limit = configuration.services.CHANGESET["rss_limit"]
    if soft_limit < rss_limit:
        setrlimit(RLIMIT_RSS, (rss_limit, hard_limit))

    from changeset.create import createChangeset
    from textutils import json_decode, json_encode

    request = json_decode(sys.stdin.read())

    try:
        db = Database()

        createChangeset(db, request)

        db.close()

        sys.stdout.write(json_encode(request))
    except:
        print "Request:"
        print json_encode(request, indent=2)
        print

        print_exc(file=sys.stdout)
else:
    from background.utils import JSONJobServer