class HighFrequencyGlitch: def __init__(self): self.stone = StoneHandler() self.stone.activate() def dbg(self, msg): return "HighFrequencyGlitch ==> " + msg def glitch(self): for i in range(100000000): self.dbg("*** GLITCH START ***") self.stone.deactivate() sleep(0.001) self.stone.activate() self.dbg("*** GLITCH OVER ***") def activate(self): for i in range(100000000): self.dbg("*** ACTIVATE ***") self.stone.activate() sleep(0.1) def deactivate(self): for i in range(100000000): self.dbg("*** DEACTIVATE ***") self.stone.deactivate() sleep(0.1)
def __init__(self, Stone=0, th=0): self.sh = Stone self.th = th print self.dbg("Contructor") os.environ['CORAL_DBLOOKUP_PATH'] = '/afs/cern.ch/sw/lcg/app/pool/db' os.environ['CORAL_AUTH_PATH'] = '/afs/cern.ch/sw/lcg/app/pool/db' os.environ['TNS_ADMIN'] = '.' if not self.sh: self.sh = StoneHandler() self.sh.activate()
class NetworkInterruption: # def __init__(self,Stone=True, StoneH =): def __init__(self, Stone=0, th=0): self.sh = Stone self.th = th print self.dbg("Contructor") os.environ['CORAL_DBLOOKUP_PATH'] = '/afs/cern.ch/sw/lcg/app/pool/db' os.environ['CORAL_AUTH_PATH'] = '/afs/cern.ch/sw/lcg/app/pool/db' os.environ['TNS_ADMIN'] = '.' if not self.sh: self.sh = StoneHandler() self.sh.activate() def dbg(self, msg): return "__NetworkInterruption n. " + str(self.th) + " ==> " + msg def netInterruption(self, time=1, obj=""): print "__Interruption ==> " self.sh.deactivate() sleep(time) print "__Object ==> ", obj self.sh.activate() def connect(self): try: self.svc = coral.ConnectionService() self.session1 = self.svc.connect( 'oracle://lcg_coral_nightly_proxy/lcg_coral_nightly', accessMode=coral.access_Update) self.transaction = self.session1.transaction() self.transaction.start() self.schema = self.session1.nominalSchema() self.rowBuffer = coral.AttributeList() except Exception, e: print str(e)
def __init__(self): self.stone = StoneHandler() self.stone.activate()
Thread.__init__(self) def run(self): HighFrequencyGlitch().activate() class testitDeactivate(Thread): def __init__(self): Thread.__init__(self) def run(self): HighFrequencyGlitch().deactivate() threadlist = [] sh = StoneHandler() sh.activate() glitch = testitGlitch() threadlist.append(glitch) glitch.start() time.sleep(10) ##activate = testitActivate() ##deactivate = testitActivate() ##threadlist.append(activate) ##threadlist.append(deactivate) ##activate.start() ##deactivate.start() for th in range(1):
MSGHDR = "+++ PYCORAL TEST +++" tableName = "prova_1" tunnelUrl = 'oracle://lcg_coral_nightly_proxy/lcg_coral_nightly' rowBuffer = coral.AttributeList() rowBuffer.extend("ID", "int") rowBuffer.extend("Data", "float") print MSGHDR, "Instantiate the PyCoral connection service" svc = coral.ConnectionService() print MSGHDR, "Instantiate a NetworkTunnel" sh = StoneHandler() os.environ['CORAL_DBLOOKUP_PATH'] = '/afs/cern.ch/sw/lcg/app/pool/db' os.environ['CORAL_AUTH_PATH'] = '/afs/cern.ch/sw/lcg/app/pool/db' os.environ['TNS_ADMIN'] = '.' #============================================================================ def printSeparator(): print "-----------------------------------------------------------------" #============================================================================
#!/usr/bin/env python import os, sys, unittest from ssh_tunnel import StoneHandler from time import sleep sh = StoneHandler() sh.activate() sh.glitch()