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()
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()
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 def describeRequest(request): if request["changeset_type"] in ("direct", "merge", "conflicts"): return "%s (%s)" % (request["changeset_type"], request["child_sha1"][:8]) else:
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(), NATIONAL_COORDINATES[nationality].max_longitude() ) cursor.execute( 'INSERT INTO users(\ name, nationality, latitude, longitude)\ VALUES(%s, %s, %s, %s) ', ( name, nationality, random_lat, random_long)) db.commit() db.close() logging.info('Exiting')