def ScrollServer(): """ Initialize the server. """ configDict = config.parseConfig() if configDict['help']: # Don't start the server if the user only wants help. sys.exit() global htmlbase, caching, xsltparam htmlbase = configDict['cache-dir'] caching = not configDict['disable-cache'] if configDict['timing']: xsltparam = '--timing' else: xsltparam = '' interface = configDict['interface'] port = configDict['port'] print "ScrollServer v0.6 -- development version!" if caching: os.system("rm -rf " + htmlbase + "*") else: print '(Caching disabled)' if interface != '': print '(Listening on interface %s, port %s)' % (interface, port) else: print '(Listening on all interfaces, port %s)' % port server = BaseHTTPServer.HTTPServer((interface, port), RequestHandler) server.serve_forever()
def __init__(self, options, test_type, image_type): super(FlatFieldTestCoordinator, self).__init__(options, test_type, image_type) self.bcount = options.getInt('bcount', 1) self.use_photodiodes = True self.hilim = options.getFloat('hilim', 999.0) self.lolim = options.getFloat('lolim', 1.0) self.filterConfigFile = options.get('filterconfig', 'filter.cfg') self.filterConfig = config.Config( dict(config.parseConfig(self.filterConfigFile).items('FILTER'))) if not self.filterConfig: raise Exception("Missing filter config file: %s" % self.filterConfigFile)
def config(self): opts, args = self.cmdline c = parseConfig(os.path.normpath(os.path.join(self._initwd, opts.itemsDir))) if opts.tagFileName: c.tagFileName = opts.tagFileName if opts.enableValueFilters: c.enableValueFilters = opts.enableValueFilters if opts.enableRootItemLinks: c.enableRootItemLinks = opts.enableRootItemLinks logging.debug('Using configuration %s' % c) return c
def config(self): opts, args = self.cmdline c = parseConfig( os.path.normpath(os.path.join(self._initwd, opts.itemsDir))) if opts.tagFileName: c.tagFileName = opts.tagFileName if opts.enableValueFilters: c.enableValueFilters = opts.enableValueFilters if opts.enableRootItemLinks: c.enableRootItemLinks = opts.enableRootItemLinks logging.debug('Using configuration %s' % c) return c
CCS.setDefaultTimeout(Duration.ofSeconds(30)) # Parse command line options parser = OptionParser() parser.add_option("--dry-run", action="store_true", dest="dry_run", default=False) parser.add_option("-9", "--ds9", action="store_true", dest="ds9") parser.add_option("--run", dest="run") parser.add_option("--symlink", dest="symlink") (options, args) = parser.parse_args() if len(args) != 1: parser.print_help() exit(1) #CCS.aliases = {'focal-plane': 'focal-plane-sim', 'bot-bench': 'bot-bench-sim'} #CCS.aliases = {'focal-plane': 'focal-plane-sim'} #ccs_sub.write_versions() import config cfg = config.parseConfig(args[0]) config.execute(cfg, { "dry_run": options.dry_run, "run": options.run, "symlink": options.symlink })
def main(): #from IPython import embed from output import makeText #bloodly pywin32 being pulled in by this from config import parseConfig PICKLEPATH, CSVPATH, MCC_DLLPATH, PAUSE_ON_LOAD, NO_CELL_STRING, OFF_STRING, ROW_ORDER, ROW_NAMES, HS_TO_UID_DICT, PROTOCOL_MODE_DICT, STATE_TO_UNIT_DICT = parseConfig('config.ini.example') #d=dataio('pickletest.pickle','csvtest.csv') sample_data = { 'asdf filename.abf':(1,{1:'really?'}), 'asdf filename2.abf':(1,{2:'really?'}), 'asdf filename3.abf':(1,{3:'really?'}), } update_data = { 'did this update work?':(2,{'ALL THE THINGS':'NOPE'}), '2 did this update work?':(2,{'ALL THE THINGS':'NOPE'}), } nHeadstages = len(HS_TO_UID_DICT) with dataio('nrw.pickle','nrw.csv') as nrw , dataio('nwr.pickle','nwr.csv') as nwr: print(nrw.loadCSV()) print(nrw.loadPickle()) nrw.updatePickle(sample_data) nrw.updatePickle( makeText(sample_data,ROW_ORDER,ROW_NAMES,OFF_STRING,STATE_TO_UNIT_DICT,nHeadstages,delimiter=',') ) nrw.updatePickle(update_data) nrw.updatePickle( makeText(update_data,ROW_ORDER,ROW_NAMES,OFF_STRING,STATE_TO_UNIT_DICT,nHeadstages,delimiter=',') ) nwr.updatePickle(sample_data) nwr.updatePickle( makeText(sample_data,ROW_ORDER,ROW_NAMES,OFF_STRING,STATE_TO_UNIT_DICT,nHeadstages,delimiter=',') ) print(nwr.loadCSV()) print(nwr.loadPickle()) nwr.updatePickle(update_data) nwr.updatePickle( makeText(update_data,ROW_ORDER,ROW_NAMES,OFF_STRING,STATE_TO_UNIT_DICT,nHeadstages,delimiter=',') ) def csvTest(): print(d.loadCSV()) d.updateCSV('\nTHIS,LINE,SHOULD,NOT,BE,HERE\nTHIS,ONE,SHOULD,BE,HERE\netc\n\tetc') try: d.updateCSV('BADTHIS,LINE,SHOULD,NOT,BE,HERE\nTHIS,ONE,SHOULD,BE,HERE\netc\netc') #this should create an error failed=False except: failed=True assert failed, 'Bad string did not fail' print(d.loadCSV()) def pickleTest(): #embed() #d.updatePickle({2:'aaaaaaaaaaaaaaaaaaaa'}) #d.updatePickle({4:'aaaaaabbbbbbbbbbb'}) #d.updatePickle({'4sdf':'aaaaaabbbbbbbbbbb','zzz':'testing!'}) #d.updatePickle({1:'WILL IT WORK!?!'}) #d.updatePickle('asdfasdfasdfasdfasdf') d.loadPickle('pickletest.pickle')
def main(cfg): try: robot = werobot.WeRoBot(cfg['wiexin']['Token']) urls.register_urls(robot.app) wxrobot.register_handler(robot) robot.run(server='tornado', host="0.0.0.0", port=80, url=cfg['wiexin']["ServerUrl"]) except KeyboardInterrupt: print "exit" if __name__ == "__main__": cfg = config.parseConfig(tomlFile=os.path.join(dir, "cfg.toml")) if "create_menu" in sys.argv: print create_menu(cfg) print get_menu(cfg) elif "get_menu" in sys.argv: print get_menu(cfg) else: main(cfg)
def main(): #from IPython import embed from output import makeText #bloodly pywin32 being pulled in by this from config import parseConfig PICKLEPATH, CSVPATH, MCC_DLLPATH, PAUSE_ON_LOAD, NO_CELL_STRING, OFF_STRING, ROW_ORDER, ROW_NAMES, HS_TO_UID_DICT, PROTOCOL_MODE_DICT, STATE_TO_UNIT_DICT = parseConfig( 'config.ini.example') #d=dataio('pickletest.pickle','csvtest.csv') sample_data = { 'asdf filename.abf': (1, { 1: 'really?' }), 'asdf filename2.abf': (1, { 2: 'really?' }), 'asdf filename3.abf': (1, { 3: 'really?' }), } update_data = { 'did this update work?': (2, { 'ALL THE THINGS': 'NOPE' }), '2 did this update work?': (2, { 'ALL THE THINGS': 'NOPE' }), } nHeadstages = len(HS_TO_UID_DICT) with dataio('nrw.pickle', 'nrw.csv') as nrw, dataio('nwr.pickle', 'nwr.csv') as nwr: print(nrw.loadCSV()) print(nrw.loadPickle()) nrw.updatePickle(sample_data) nrw.updatePickle( makeText(sample_data, ROW_ORDER, ROW_NAMES, OFF_STRING, STATE_TO_UNIT_DICT, nHeadstages, delimiter=',')) nrw.updatePickle(update_data) nrw.updatePickle( makeText(update_data, ROW_ORDER, ROW_NAMES, OFF_STRING, STATE_TO_UNIT_DICT, nHeadstages, delimiter=',')) nwr.updatePickle(sample_data) nwr.updatePickle( makeText(sample_data, ROW_ORDER, ROW_NAMES, OFF_STRING, STATE_TO_UNIT_DICT, nHeadstages, delimiter=',')) print(nwr.loadCSV()) print(nwr.loadPickle()) nwr.updatePickle(update_data) nwr.updatePickle( makeText(update_data, ROW_ORDER, ROW_NAMES, OFF_STRING, STATE_TO_UNIT_DICT, nHeadstages, delimiter=',')) def csvTest(): print(d.loadCSV()) d.updateCSV( '\nTHIS,LINE,SHOULD,NOT,BE,HERE\nTHIS,ONE,SHOULD,BE,HERE\netc\n\tetc' ) try: d.updateCSV( 'BADTHIS,LINE,SHOULD,NOT,BE,HERE\nTHIS,ONE,SHOULD,BE,HERE\netc\netc' ) #this should create an error failed = False except: failed = True assert failed, 'Bad string did not fail' print(d.loadCSV()) def pickleTest(): #embed() #d.updatePickle({2:'aaaaaaaaaaaaaaaaaaaa'}) #d.updatePickle({4:'aaaaaabbbbbbbbbbb'}) #d.updatePickle({'4sdf':'aaaaaabbbbbbbbbbb','zzz':'testing!'}) #d.updatePickle({1:'WILL IT WORK!?!'}) #d.updatePickle('asdfasdfasdfasdfasdf') d.loadPickle('pickletest.pickle')