def gethits():
    accessdb = db.accessdb()
    cur = accessdb.conn.cursor()
    cur.execute("SELECT hit.agent, ip.latitude, ip.longitude, count(hit.ip), hit.ip FROM IP ip, HIT hit where hit.ip = ip.id group by hit.agent, hit.ip")
    hits = set()
    try:
        for hit in cur:
            if hit[1] != "unknown":
	        if hit[0] == "OMERO.server":
			hits.add(("./registry.S.png","new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
		elif hit[0] == "OMERO.insight":
			hits.add(("./registry.N.png","new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
		elif hit[0] == "OMERO.editor":
			hits.add(("./registry.E.png","new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
		elif hit[0] == "OMERO.importer":
			hits.add(("./registry.M.png","new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
		elif hit[0] == "OMERO.imagej":
			hits.add(("./registry.J.png","new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
		elif hit[0] == "OMERO.web":
			hits.add(("./registry.W.png","new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
		else:
			pass
    finally:
        accessdb.close()
    return hits
Beispiel #2
0
def gethits():
    accessdb = db.accessdb()
    cur = accessdb.conn.cursor()
    cur.execute(
        "SELECT hit.agent, ip.latitude, ip.longitude, count(hit.ip), hit.ip FROM IP ip, HIT hit where hit.ip = ip.id group by hit.agent, hit.ip"
    )
    hits = set()
    try:
        for hit in cur:
            if hit[1] != "unknown":
                if hit[0] == "OMERO.server":
                    hits.add(
                        ("./registry.S.png",
                         "new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
                elif hit[0] == "OMERO.insight":
                    hits.add(
                        ("./registry.N.png",
                         "new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
                elif hit[0] == "OMERO.editor":
                    hits.add(
                        ("./registry.E.png",
                         "new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
                elif hit[0] == "OMERO.importer":
                    hits.add(
                        ("./registry.M.png",
                         "new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
                elif hit[0] == "OMERO.imagej":
                    hits.add(
                        ("./registry.J.png",
                         "new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
                elif hit[0] == "OMERO.web":
                    hits.add(
                        ("./registry.W.png",
                         "new YGeoPoint(%s, %s)" % (hit[1], hit[2]), hit[3]))
                else:
                    pass
    finally:
        accessdb.close()
    return hits
Beispiel #3
0
        for idx in keys:
		values = []
		for m in [data[app] for app in applications]:
			try:
				values.append(int(m[idx]))
			except KeyError:
				values.append(0)
		for jdx in range(0,len(applications)):
			totals[jdx] = totals[jdx] + values[jdx]
		values.append( sum(values) )
		values.insert( 0, idx)
                print ("%8s\t%8s" + "\t%8s"*len(applications)) % tuple(values)
	totals.append(sum(totals))
	print total_format % tuple(totals)
	
accessdb = db.accessdb()
try:
	c = accessdb.conn.cursor()

	#
	# LAST 30 DAYS
	#
	ndays = """SELECT date(time), count(date(time))
	            FROM hit """ + where_filter + """
		     AND agent = 'OMERO.%s'
                GROUP BY date(time)
		ORDER BY date(time) desc limit 30"""
	m = {}
	def doDay(app):
		c.execute(ndays % app)
		m[app] = {}
Beispiel #4
0
import db, GeoIP

def doIp(db, ipaddr):
        if not hasattr(GeoIP,"gi"):
            GeoIP.gi = GeoIP.open("GeoLiteCity.dat",GeoIP.GEOIP_STANDARD)

        try:
            print ipaddr,
            gir = GeoIP.gi.record_by_addr(ipaddr)
            lat = gir["latitude"]
            lon = gir["longitude"]
	    print lat, lon
        except:
	    print "unknown"
            lat = "unknown"
            lon = "unknown"

	c2 = db.conn.cursor()
	c2.execute("UPDATE ip SET latitude = ?, longitude = ? WHERE id = ?", (lat, lon, ipaddr))

try:
	db = db.accessdb()
	c  = db.conn.cursor()
	c.execute('SELECT id FROM ip')
	for ip in c:
		doIp(db, ip[0])
	db.conn.commit()
finally:
	db.close()

Beispiel #5
0
 def __init__(self):
     """
     Currently unused initialization.
     """
     Resource.__init__(self)
     self.db = db.accessdb("sqlite.db")
Beispiel #6
0
 def __init__(self):
     """
     Currently unused initialization.
     """
     Resource.__init__(self)
     self.db = db.accessdb("sqlite.db")