def main(argv): # define some defaults configFile = scriptPath + '/../etc/config.xml' # parse the command line arguments try: opts, args = getopt.getopt(argv, "hf:n:", ['help', 'fields=', 'name']) except getopt.GetoptError: sys.exit(2) field = 'status,address,speed' name = '' # override defaults based on command line arguments for opt, arg in opts: if opt in ('-h', '--help'): usage() sys.exit() elif opt == '-f': field = arg elif opt == '-n': name = arg # load up the configs Config = ParseConfig.parseConfig(configFile) fields = field.split(',') getData(Config, fields)
def main(argv): # define some defaults configFile = scriptPath + '/../etc/config.xml' # parse the command line arguments try: opts, args = getopt.getopt(argv, "hf:n:", ['help', 'fields=', 'name']) except getopt.GetoptError: sys.exit(2) field = 'status,address,speed' name = '' # override defaults based on command line arguments for opt, arg in opts: if opt in ('-h', '--help'): usage() sys.exit() elif opt == '-f': field = arg elif opt == '-n': name = arg # load up the configs Config = ParseConfig.parseConfig(configFile); fields = field.split(','); getData(Config, fields)
import wrap import sys, os import datetime sys.path.append(os.getcwd()) import ParseConfig reload(ParseConfig) print "Select config file" configFile = wrap.openFileDialog("Select config file", filter="Text Files (*.txt)") print "Config file is '%s'" % configFile tasks = ParseConfig.parseConfig(configFile, 'DefaultSettings_2_Wrapping.txt') tasksCount = len(tasks) for taskNum, task in enumerate(tasks): print "Task %d of %d" % (taskNum + 1, tasksCount) print "Loading scan '%s'..." % task['scanFileName'] scan = wrap.Geom(task['scanFileName'], fitToView=False) scan.wireframe = False scaleFactor = 100.0 / scan.boundingBoxSize[0] scan.scale(scaleFactor) wrap.fitToView() print "OK" if 'textureFileName' in task: print "Loading texture '%s'" % task['textureFileName'] scan.texture = wrap.Image(task['textureFileName']) print "OK"
def main(): pid = os.getpid() logFile = "/tmp/backend-%d.log" % pid debug = 1 # define some defaults configFile = scriptPath + "/../etc/config.xml" # load up the configs Config = ParseConfig.parseConfig(configFile) # setup the logger if debug: logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) ch = logging.handlers.RotatingFileHandler(logFile, maxBytes=25000000, backupCount=5) if debug: ch.setLevel(logging.DEBUG) else: ch.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") ch.setFormatter(formatter) logger.addHandler(ch) # and fire up the logger logger.info("startup") first_time = True db = TimeSeries(Config) # here, we have to deal with how to talk to PowerDNS. while 1: # loop forever reading from PowerDNS rawline = sys.stdin.readline() if rawline == "": logger.debug("EOF") return # EOF detected line = rawline.rstrip() logger.debug("received from pdns:%s" % line) # If this is the first pass reading from PowerDNS, look for a HELO if first_time: if line == "HELO\t1": fprint("OK\togslb backend firing up") else: fprint("FAIL") logger.debug("HELO input not received - execution aborted") rawline = sys.stdin.readline() # as per docs - read another line before aborting logger.debug("calling sys.exit()") sys.exit(1) first_time = False else: # now we actually get busy query = line.split("\t") if len(query) != 6: # fprint('LOG\tPowerDNS sent unparseable line') # fprint('FAIL') fprint("END") else: logger.debug("Performing DNSLookup(%s)" % repr(query)) lookup = "" # Here, we actually to the real work. Lookup a hostname in redis and prioritize it lookup = DNSLookup(db, query) if lookup != "": logger.debug(lookup) fprint(lookup) fprint("END")
def main(): pid = os.getpid() logFile = '/tmp/backend-%d.log' % pid debug = 1 # define some defaults configFile = scriptPath + '/../etc/config.xml' # load up the configs Config = ParseConfig.parseConfig(configFile) # setup the logger if (debug): logger.setLevel(logging.DEBUG) else: logger.setLevel(logging.INFO) ch = logging.handlers.RotatingFileHandler(logFile, maxBytes=25000000, backupCount=5) if (debug): ch.setLevel(logging.DEBUG) else: ch.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") ch.setFormatter(formatter) logger.addHandler(ch) # and fire up the logger logger.info('startup') first_time = True db = TimeSeries(Config) # here, we have to deal with how to talk to PowerDNS. while 1: # loop forever reading from PowerDNS rawline = sys.stdin.readline() if rawline == '': logger.debug('EOF') return # EOF detected line = rawline.rstrip() logger.debug('received from pdns:%s' % line) # If this is the first pass reading from PowerDNS, look for a HELO if first_time: if line == 'HELO\t1': fprint('OK\togslb backend firing up') else: fprint('FAIL') logger.debug('HELO input not received - execution aborted') rawline = sys.stdin.readline( ) # as per docs - read another line before aborting logger.debug('calling sys.exit()') sys.exit(1) first_time = False else: # now we actually get busy query = line.split('\t') if len(query) != 6: # fprint('LOG\tPowerDNS sent unparseable line') # fprint('FAIL') fprint('END') else: logger.debug('Performing DNSLookup(%s)' % repr(query)) lookup = '' # Here, we actually to the real work. Lookup a hostname in redis and prioritize it lookup = DNSLookup(db, query) if lookup != '': logger.debug(lookup) fprint(lookup) fprint('END')
import wrap import sys, os sys.path.append(os.getcwd()) import ParseConfig reload(ParseConfig) print "Select config file" configFile = wrap.openFileDialog("Select config file", filter="Text Files (*.txt)") print "Config file is '%s'" % configFile tasks = ParseConfig.parseConfig(configFile) basemesh = None scan = None for taskNum, task in enumerate(tasks): if basemesh: del basemesh if scan: del scan wrap.fitToView() print "Task %d of %d" % (taskNum + 1, len(tasks)) print "Loading scan '%s'..." % task['scanFileName'] scan = wrap.Geom(task['scanFileName'], fitToView=False) scan.wireframe = False scaleFactor = 100.0 / scan.boundingBoxSize[0] scan.scale(scaleFactor) wrap.fitToView() print "OK"
import wrap import sys,os sys.path.append(os.getcwd()) import ParseConfig; reload(ParseConfig) print "Select config file" configFile = wrap.openFileDialog("Select config file",filter="Text Files (*.txt)") print "Config file is '%s'" % configFile tasks = ParseConfig.parseConfig(configFile, "DefaultSettings_3_PostProcessing.txt") for taskNum, task in enumerate(tasks): if 'wrapped' in locals(): del wrapped if 'scan' in locals(): del scan print "Task %d of %d" % (taskNum + 1, len(tasks)) print "Loading scan '%s'..." % task['scanFileName'] scan = wrap.Geom(task['scanFileName'], fitToView = False) scan.wireframe = False scaleFactor = 100.0 / scan.boundingBoxSize[0] scan.scale(scaleFactor) wrap.fitToView() print "OK" if 'textureFileName' in task: print "Loading texture '%s'" % task['textureFileName'] scan.texture = wrap.Image(task['textureFileName']) print "OK" else:
import wrap import sys,os sys.path.append(os.getcwd()) import ParseConfig; reload(ParseConfig) print "Select config file" configFile = wrap.openFileDialog("Select config file",filter="Text Files (*.txt)") print "Config file is '%s'" % configFile tasks = ParseConfig.parseConfig(configFile) taskNum = 0 while True: task = tasks[taskNum] print "Task %d of %d" % (taskNum + 1, len(tasks)) print "Loading scan '%s'..." % task['scanFileName'] scan = wrap.Geom(task['scanFileName'], fitToView = False) scan.wireframe = False scaleFactor = 100.0 / scan.boundingBoxSize[0] scan.scale(scaleFactor) wrap.fitToView() print "OK" if 'textureFileName' in task: print "Loading texture '%s'" % task['textureFileName'] scan.texture = wrap.Image(task['textureFileName']) print "OK"
import wrap import sys, os sys.path.append(os.getcwd()) import ParseConfig reload(ParseConfig) print "Select config file" configFile = wrap.openFileDialog("Select config file", filter="Text Files (*.txt)") print "Config file is '%s'" % configFile tasks = ParseConfig.parseConfig(configFile, "DefaultSettings_3_PostProcessing.txt") for taskNum, task in enumerate(tasks): if 'wrapped' in locals(): del wrapped if 'scan' in locals(): del scan print "Task %d of %d" % (taskNum + 1, len(tasks)) print "Loading scan '%s'..." % task['scanFileName'] scan = wrap.Geom(task['scanFileName'], fitToView=False) scan.wireframe = False scaleFactor = 100.0 / scan.boundingBoxSize[0] scan.scale(scaleFactor) wrap.fitToView() print "OK" if 'textureFileName' in task: print "Loading texture '%s'" % task['textureFileName']
import wrap import sys,os import datetime sys.path.append(os.getcwd()) import ParseConfig; reload(ParseConfig) print "Select config file" configFile = wrap.openFileDialog("Select config file",filter="Text Files (*.txt)") print "Config file is '%s'" % configFile tasks = ParseConfig.parseConfig(configFile, 'DefaultSettings_2_Wrapping.txt') tasksCount = len(tasks) for taskNum, task in enumerate(tasks): print "Task %d of %d" % (taskNum + 1, tasksCount) print "Loading scan '%s'..." % task['scanFileName'] scan = wrap.Geom(task['scanFileName'], fitToView = False) scan.wireframe = False scaleFactor = 100.0 / scan.boundingBoxSize[0] scan.scale(scaleFactor) wrap.fitToView() print "OK" if 'textureFileName' in task: print "Loading texture '%s'" % task['textureFileName'] scan.texture = wrap.Image(task['textureFileName']) print "OK" else: print "No texture found"