Example #1
0
def dosimple(command, pw):
	print "attempting remote %s (%s) for server on local machine" % (command, pw)
	from gfclient import gfclient
	machine = socket.gethostname()
	conn = gfclient("admin", PORT, pw, machine)
	action = getattr(conn, command)
	print action()
Example #2
0
def dosimple(command, pw):
    print "attempting remote %s (%s) for server on local machine" % (command, pw)
    from gfclient import gfclient
    machine = socket.gethostname()
    conn = gfclient("admin", PORT, pw, machine)
    action = getattr(conn, command)
    print action()
Example #3
0
def policy_test():
    """test the test1 and test policies"""
    print "testing non-admin policies test and test1"
    from gfclient import gfclient
    import sys
    machine = socket.gethostname()
    conn = gfclient("test", PORT, "test", machine)
    cursor = conn.cursor()
    print "testing test policy: nan values before:"
    cursor.execute_prepared("getnan")
    for x in cursor.fetchall():
        print x
    print "updating nan"
    cursor.execute_prepared("updatenan", ("pabst", 4))
    print "nan after"
    cursor.execute_prepared("getnan")
    for x in cursor.fetchall():
        print x
    print "updating nan again"
    cursor.execute_prepared("updatenan", ("rollingrock", 1))
    print "trying an illegal update"
    try:
        cursor.execute("delete from frequents")
    except:
        print "exception", sys.exc_type, sys.exc_value
        print "as expected"
    else:
        raise "DAMN!", "illegal query apparently completed!!!"
    print
    print "testing policy test1"
    print
    conn = gfclient("test1", PORT, "test1", machine)
    cursor = conn.cursor()
    print "getting norm"
    cursor.execute_prepared("qlike", ("norm", ))
    print cursor.description
    for x in cursor.fetchall():
        print x
    print "trying an illegal query again"
    try:
        cursor.execute("create table test(name varchar)")
    except:
        print "exception", sys.exc_type, sys.exc_value
        print "as expected"
    else:
        raise "Damn!(2)", "illegal query apparently completed"
Example #4
0
 def __init__(self, user):
   try:
     self.db = gfclient(bnmdbcfg.policy, bnmdbcfg.port,
                        bnmdbcfg.passwd, bnmdbcfg.host)
     self.sql = self.db.cursor()
     self.errbuf = []
   except Exception, why:
     print 'Cannot connect to database: %s', (why)
     raise
Example #5
0
def policy_test():
    """test the test1 and test policies"""
    print "testing non-admin policies test and test1"
    from gfclient import gfclient
    import sys
    machine = socket.gethostname()
    conn = gfclient("test", PORT, "test", machine)
    cursor = conn.cursor()
    print "testing test policy: nan values before:"
    cursor.execute_prepared("getnan")
    for x in cursor.fetchall():
        print x
    print "updating nan"
    cursor.execute_prepared("updatenan", ("pabst", 4))
    print "nan after"
    cursor.execute_prepared("getnan")
    for x in cursor.fetchall():
        print x
    print "updating nan again"
    cursor.execute_prepared("updatenan", ("rollingrock", 1))
    print "trying an illegal update"
    try:
        cursor.execute("delete from frequents")
    except:
        print "exception", sys.exc_type, sys.exc_value
        print "as expected"
    else:
        raise "DAMN!", "illegal query apparently completed!!!"
    print; print "testing policy test1"; print
    conn = gfclient("test1", PORT, "test1", machine)
    cursor = conn.cursor()
    print "getting norm"
    cursor.execute_prepared("qlike", ("norm",))
    print cursor.description
    for x in cursor.fetchall():
        print x
    print "trying an illegal query again"
    try:
        cursor.execute("create table test(name varchar)")
    except:
        print "exception", sys.exc_type, sys.exc_value
        print "as expected"
    else:
        raise "Damn!(2)", "illegal query apparently completed"
Example #6
0
def doqueries():
    print "executing queries and updates"
    from gfclient import gfclient
    import sys
    machine = socket.gethostname()
    conn = gfclient("admin", PORT, PW, machine)
    cursor = conn.cursor()
    for q in admin_queries:
        print;print;print q;print
        try:
            cursor.execute(q)
        except:
            print "exception in execute"
            print sys.exc_type
            v = sys.exc_value
            from types import TupleType, ListType
            if type(v) in (TupleType, ListType):
               for x in v: print x
            else:
               print v
        else:
            print "executed"
            #print q
            print "description"
            print cursor.description
            print "results"
            try:
                r = cursor.fetchall()
                if r is None:
                    print "no results"
                else:
                    for x in r:
                        print x
            except:
                print "exception in results"
                print sys.exc_type, sys.exc_value
                print dir(cursor)
    # try dumpwork
    print; print; print "dumpwork"; print
    cursor.execute_prepared("dumpwork")
    for x in cursor.fetchall():
        print x
    # try dynamic parameters
    stat = """
    select distinct drinker
    from likes l, serves s
    where l.beer = s.beer and s.bar=?
    """
    print; print stat; print "dynamic query ?=cheers"
    cursor.execute(stat, ("cheers",))
    for x in cursor.fetchall():
        print x
Example #7
0
def doqueries():
	print "executing queries and updates"
	from gfclient import gfclient
	import sys
	machine = socket.gethostname()
	conn = gfclient("admin", PORT, PW, machine)
	cursor = conn.cursor()
	for q in admin_queries:
		print;print;print q;print
		try:
			cursor.execute(q)
		except:
			print "exception in execute"
			print sys.exc_type
			v = sys.exc_value
			from types import TupleType, ListType
			if type(v) in (TupleType, ListType):
				for x in v: print x
			else:
				print v
		else:
			print "executed"
			#print q
			print "description"
			print cursor.description
			print "results"
			try:
				r = cursor.fetchall()
				if r is None:
					print "no results"
				else:
					for x in r:
						print x
			except:
				print "exception in results"
				print sys.exc_type, sys.exc_value
				print dir(cursor)
	# try dumpwork
	print; print; print "dumpwork"; print
	cursor.execute_prepared("dumpwork")
	for x in cursor.fetchall():
		print x
	# try dynamic parameters
	stat = """
    select distinct drinker
    from likes l, serves s
    where l.beer = s.beer and s.bar=?
    """
	print; print stat; print "dynamic query ?=cheers"
	cursor.execute(stat, ("cheers",))
	for x in cursor.fetchall():
		print x
Example #8
0
PORT = 2222
DB = "bnmdb"
DBDIR = "/home/rand/apr/db/bnmdb"
PW = "admin"

import sys, socket
sys.path.append('/home/rand/rand/internet/gadfly')
from gfclient import gfclient


machine = socket.gethostname()
conn = gfclient("admin", PORT, "admin", machine)
cursor = conn.cursor()
cursor.execute("select * from domaene")
for x in cursor.fetchall():
  print x
cursor.execute("select name,subsystem from domaene")
for x in cursor.fetchall():
  print x