def cc_check_features(self,kind='cc'): v=self.env test=Configure.check_data() test.code='int main() {return 0;}\n' test.env=v test.execute=1 test.force_compiler=kind ret=self.run_check(test) self.check_message('compiler could create','programs',not(ret is False)) if not ret:self.fatal("no programs") lib_obj=Configure.check_data() lib_obj.code="int k = 3;\n" lib_obj.env=v lib_obj.build_type="shlib" lib_obj.force_compiler=kind ret=self.run_check(lib_obj) self.check_message('compiler could create','shared libs',not(ret is False)) if not ret:self.fatal("no shared libs") lib_obj=Configure.check_data() lib_obj.code="int k = 3;\n" lib_obj.env=v lib_obj.build_type="staticlib" lib_obj.force_compiler=kind ret=self.run_check(lib_obj) self.check_message('compiler could create','static libs',not(ret is False)) if not ret:self.fatal("no static libs")
def detect_tbb(conf): env = conf.env opt = Options.options if Options.options.no_tbb: print "TBB (multicore) is disabled" return 0 if Options.options.tbb: conf.env['CPPPATH_TBB'] = [Options.options.tbb + '/include'] conf.env['LIBPATH_TBB'] = [Options.options.tbb + '/lib'] else: conf.env['CPPPATH_TBB'] = ['/opt/intel/include'] conf.env['LIBPATH_TBB'] = ['/opt/intel/lib'] res = Configure.find_file('tbb/parallel_for.h', conf.env['CPPPATH_TBB']+['/usr/include', '/usr/local/include']) conf.check_message('header','tbb/parallel_for.h', (res != '') , res) if (res == '') : return 0 if Options.options.apple: res = Configure.find_file('libtbb.dylib', conf.env['LIBPATH_TBB'] + ['/usr/lib', '/usr/local/lib']) else: res = Configure.find_file('libtbb.so', conf.env['LIBPATH_TBB'] + ['/usr/lib', '/usr/local/lib']) conf.check_message('library','libtbb', (res != ''), res) if (res == '') : return 0 conf.env['LIB_TBB'] = ['tbb'] return 1
def detect_tbb(conf): env = conf.env opt = Options.options if Options.options.no_tbb: print "TBB (multicore) is disabled" return 0 if Options.options.tbb: conf.env['CPPPATH_TBB'] = [Options.options.tbb + '/include'] #conf.env['LIBPATH_TBB'] = [Options.options.tbb + '/lib'] conf.env['LIBPATH_TBB'] = [Options.options.tbb + '/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21'] #print conf.env['LIBPATH_TBB'] else: conf.env['CPPPATH_TBB'] = ['/opt/intel/include'] conf.env['LIBPATH_TBB'] = ['/opt/intel/lib'] res = Configure.find_file('tbb/parallel_for.h', conf.env['CPPPATH_TBB']+['/usr/include', '/usr/local/include']) conf.check_message('header','tbb/parallel_for.h', (res != '') , res) if (res == '') : return 0 if Options.options.apple: res = Configure.find_file('libtbb.dylib', conf.env['LIBPATH_TBB'] + ['/usr/lib', '/usr/local/lib']) else: res = Configure.find_file('libtbb.so', conf.env['LIBPATH_TBB'] + ['/usr/lib', '/usr/local/lib']) conf.check_message('library','libtbb', (res != ''), res) if (res == '') : return 0 conf.env['LIB_TBB'] = ['tbb'] return 1
def detect(conf): cython = conf.find_program('cython', var='CYTHON') if not cython: return False # Register version checking method in configure class. Configure.conf(check_cython_version) conf.env['CYTHON_EXT'] = ['.pyx'] return True
def test_missing_srcdir(self): self._setup_options() Utils.g_module = imp.new_module('main_wscript') Utils.g_module.blddir = 'out' # TODO: tests for WafError upon change conf = Configure.ConfigurationContext() self.failUnlessRaises(Utils.WscriptError, Scripting.configure, conf)
def detect(conf): # xml2po xml2po = conf.find_program('xml2po', var='XML2PO') if not xml2po: # xml2po: on win32 'xml2po' is not executable thus this hook if conf.env['IS_WIN32']: python = conf.find_program('python', var='PYTHON') if not python: conf.fatal( 'The program python (required by xml2po) could not be found' ) xml2podir = Configure.find_file( 'xml2po', os.environ['PATH'].split(os.pathsep)) if not xml2podir: conf.fatal('The program xml2po is mandatory!') conf.env['XML2PO'] = Utils.to_list( conf.env['PYTHON']) + [xml2podir + os.sep + 'xml2po'] conf.check_message('xml2po', '', True, ' '.join(conf.env['XML2PO'])) else: conf.fatal('The program xml2po is mandatory!') if conf.env['IS_WIN32']: xsltproc = conf.find_program('xsltproc', var='XSLTPROC') htmlhelpc = conf.find_program('hhc', var='HTMLHELPC')
def detect_mpi(conf): env = conf.env opt = Options.options conf.env['LIB_MPI'] = '' conf.env['MPI_FOUND'] = False if Options.options.no_mpi: return if Options.options.mpi: conf.env['CPPPATH_MPI'] = Options.options.mpi + '/include' conf.env['LIBPATH_MPI'] = Options.options.mpi + '/lib' else: conf.env['CPPPATH_MPI'] = [ '/usr/include/mpi', '/usr/local/include/mpi', '/usr/include', '/usr/local/include' ] conf.env['LIBPATH_MPI'] = [ '/usr/lib', '/usr/local/lib', '/usr/lib/openmpi' ] res = Configure.find_file('mpi.h', conf.env['CPPPATH_MPI']) conf.check_message('header', 'mpi.h', (res != ''), res) if (res == ''): return 0 conf.env['MPI_FOUND'] = True conf.env['LIB_MPI'] = ['mpi_cxx', 'mpi'] return 1
def pkg_check_modules(conf,uselib_name,expression,mandatory=True): pkg_config=conf.env['PKG_CONFIG'] if not pkg_config: if mandatory: conf.fatal("pkg-config is not available") else: return False argv=[pkg_config,'--cflags','--libs',expression] cmd=subprocess.Popen(argv,stdout=subprocess.PIPE) out,dummy=cmd.communicate() retval=cmd.wait() msg_checking=("pkg-config flags for %s"%(uselib_name,)) if Options.options.verbose: if retval==0: conf.check_message_custom(msg_checking,('(%s)'%expression),out) else: conf.check_message(msg_checking,('(%s)'%expression),False) else: conf.check_message(msg_checking,'',(retval==0),'') conf.log.write('%r: %r (exit code %i)\n'%(argv,out,retval)) if retval==0: config_c.parse_flags(out,uselib_name,conf.env) conf.env[uselib_name]=True return True else: conf.env[uselib_name]=False if mandatory: raise Configure.ConfigurationError('pkg-config check failed') else: return False
def main(): ''' 构造测试集,并用restore之前的模型来进行evaluate ''' # 读取配置文件 config = Configure() # 设置logger logger = get_logger(config['path_log']) # 读取词典 vocab_util = Vocab_Util() # dict[word] = idx vocab_words = vocab_util.load_vocab(config['word_vocab_file']) # dict[char] = idx vocab_chars = vocab_util.load_vocab(config['char_vocab_file']) # dict[tag] = idx vocab_tags = vocab_util.load_vocab(config['tag_vocab_file']) # 将词典封装给模型 vocabs = [vocab_words, vocab_chars, vocab_tags] embeddings = vocab_util.get_trimmed_glove_vectors(config['trimmed_file']) # 对数据进行处理 processing_word = get_processing_word(vocab_words = vocab_words, vocab_chars = vocab_chars, lowercase = True, chars = config['use_chars'], allow_unk = True) processing_tag = get_processing_word(vocab_words = vocab_tags, lowercase = False, allow_unk = False) # 得到训练数据 test_dataset = Dataset(filename = config['test_data'], max_iter = None, processing_word = processing_word, processing_tag = processing_tag) # 构造模型进行训练 model = ner_model(config,logger,vocabs,embeddings) model.build() model.restore_session() model.evaluate(test_dataset)
def CheckDuration(): """ CTFが開催中か確認する """ config = Configure.LoadConfig() start = config['ctf']['duration']['start'] end = config['ctf']['duration']['end'] # 各種時刻を取得 tz = pytz.timezone(config['ctf']['duration']['timezone']) dt_now = datetime.datetime.now(tz=tz) dt_start = datetime.datetime(start['year'], start['month'], start['date'], start['hour'], start['minute'], start['second'], tzinfo=tz) dt_end = datetime.datetime(end['year'], end['month'], end['date'], end['hour'], end['minute'], end['second'], tzinfo=tz) # 開始前かの確認 if dt_now < dt_start: return 1 # 終了後かの確認 if dt_now > dt_end: return 2 return 0
def main(): logger = Logger.logger() sources = Configure.servers(logger) model = ModelStandard.ModelStandard() view = ViewCurses.ViewCurses(model) if "TERM" in os.environ else ViewPrint.ViewPrint(model) manifold = Manifold.Manifold(model, view) body(manifold, sources, sources)
def load_input(__self__): f = filedialog.askopenfilename(title="Open input file", filetypes=[("Input file", "*.dat")]) if f is not "": files, __self__.out = Configure.load_input(f) __self__.temp = [] local_path = os.path.dirname(os.path.abspath(__file__)) ################################################## # Copies all relevant files to working directory # ################################################## for fpath, fname in files: destination = os.path.join(local_path, fname) try: shutil.copy(fpath, destination) __self__.temp.append(destination) files_in_root = 0 except: files_in_root = 1 pass ################################################################# #NOTE: If the input file selected is in the working directory, # # there it no need to create a temporary input file # ################################################################# if not files_in_root: shutil.copy(f, os.path.join(local_path, "temp_input.dat")) __self__.temp.append(os.path.join(local_path, "temp_input.dat")) __self__.launch(__input__="temp_input.dat") else: __self__.launch(__input__=f)
def detect(conf): pocom=conf.find_program('msgfmt') if not pocom: conf.fatal('The program msgfmt (gettext) is mandatory!') conf.env['POCOM']=pocom intltool=conf.find_program('intltool-merge',var='INTLTOOL') if not intltool: if Options.platform=='win32': perl=conf.find_program('perl',var='PERL') if not perl: conf.fatal('The program perl (required by intltool) could not be found') intltooldir=Configure.find_file('intltool-merge',os.environ['PATH'].split(os.pathsep)) if not intltooldir: conf.fatal('The program intltool-merge (intltool, gettext-devel) is mandatory!') conf.env['INTLTOOL']=Utils.to_list(conf.env['PERL'])+[intltooldir+os.sep+'intltool-merge'] conf.check_message('intltool','',True,' '.join(conf.env['INTLTOOL'])) else: conf.fatal('The program intltool-merge (intltool, gettext-devel) is mandatory!') def getstr(varname): return getattr(Options.options,varname,'') prefix=conf.env['PREFIX'] datadir=getstr('datadir') if not datadir:datadir=os.path.join(prefix,'share') conf.define('LOCALEDIR',os.path.join(datadir,'locale')) conf.define('DATADIR',datadir) if conf.env['CC']or conf.env['CXX']: conf.check(header_name='locale.h')
def GetInformation(): """ CTFの詳細情報を取得する """ config = Configure.LoadConfig() ctf = { 'name': config['ctf']['name'], 'brand': config['ctf']['brand'], 'team': config['ctf']['team'], 'over-open': config['ctf']['over-open'] } return ctf
def get_video(mol, molclass=None, traj=None, view=1): if (molclass == None): molclass = queue.getClass(mol) if (traj == None): traj = queue.get_latest_completed_trajectory(mol) log("Showing video " + str([molclass, mol, traj, view])) if (traj == 1): traj = "INIT" traj = str(traj) trajvideo = Configure.molVideosPath( molclass, mol) + mol + "_" + traj + "_view" + str(view) + ".gif" log("Trajvideo is: " + trajvideo) if not os.path.exists(trajvideo): inputfile = Configure.molResultsPath(molclass, mol) if (traj == "INIT"): inputfile = inputfile + "data." + mol else: inputfile = inputfile + mol + "_" + traj + ".lammpstrj" ovitoHandler.videoView(inputfile, view) return trajvideo
def test_missing_configure(self): # white_box test: missing def configure() wscript_contents = """ blddir = 'build' srcdir = '.' """ self._write_wscript(wscript_contents, use_dic=False) self._setup_options() Utils.set_main_module(self._wscript_file_path) conf = Configure.ConfigurationContext() self.failUnlessRaises(Utils.WscriptError, Scripting.configure, conf)
def main(): # 读取配置文件 config = Configure() # 设置logger logger = get_logger(config['path_log']) # 读取词典 vocab_util = Vocab_Util() # dict[word] = idx vocab_words = vocab_util.load_vocab(config['word_vocab_file']) # dict[char] = idx vocab_chars = vocab_util.load_vocab(config['char_vocab_file']) # dict[tag] = idx vocab_tags = vocab_util.load_vocab(config['tag_vocab_file']) # 将词典封装给模型 vocabs = [vocab_words, vocab_chars, vocab_tags] embeddings = vocab_util.get_trimmed_glove_vectors(config['trimmed_file']) # 对数据进行处理 processing_word = get_processing_word(vocab_words=vocab_words, vocab_chars=vocab_chars, lowercase=True, chars=config['use_chars'], allow_unk=True) processing_tag = get_processing_word(vocab_words=vocab_tags, lowercase=False, allow_unk=False) # 得到训练数据 train_dataset = Dataset(filename=config['train_data'], max_iter=None, processing_word=processing_word, processing_tag=processing_tag) # 得到dev数据 dev_dataset = Dataset(filename=config['dev_data'], max_iter=None, processing_word=processing_word, processing_tag=processing_tag) # for data in train_dataset: # print data for x_batch, y_batch in train_dataset.get_minibatch(4): print x_batch print y_batch # 构造模型进行训练 model = ner_model(config, logger, vocabs, embeddings) # 构建模型图 model.build() # 训练 model.train(train_dataset, dev_dataset)
def get_plot(molclass, mol, traj, plot): log(("Showing plot ") + str([molclass, mol, traj, plot])) if (traj == 1): return traj = str(traj) trajplot = Configure.molGraphsPath(molclass, mol) + mol + "_" + plot + ".png" log("Trajplot is: " + trajplot) if not os.path.exists(trajplot): log("Creating plot...") os.system("python " + Configure.Aromodel_Path + "/Analyze_SAM_Traj.py " + molclass + " " + mol + " " + traj) return trajplot
def Query(query, param=None): """ SQLクエリを発行する """ sqlite3.dbapi2.converters['DATETIME'] = sqlite3.dbapi2.converters['TIMESTAMP'] with closing(sqlite3.connect(Configure.GetDatabasePath())) as conn: conn.row_factory = sqlite3.Row cur = conn.cursor() if param: cur.execute(query, param) else: cur.execute(query) result = cur.fetchall() conn.commit() return result
def get_print(mol, molclass=None, traj=None, view=1): if (molclass == None): molclass = queue.getClass(mol) if (traj == None): traj = queue.get_latest_completed_trajectory(mol) log("Showing print " + str([molclass, mol, traj, view])) traj = str(traj) if (traj == "Last"): return get_latest_print(molclass, mol, view) if (traj == "1"): traj = "INIT" traj = str(traj) trajprint = Configure.molPrintsPath( molclass, mol) + mol + "_" + traj + "_view" + str(view) + ".png" if not os.path.exists(trajprint): inputfile = Configure.molResultsPath(molclass, mol) if (traj == "INIT"): inputfile = inputfile + "data." + mol else: inputfile = inputfile + mol + "_" + traj + ".lammpstrj" ovitoHandler.printView(inputfile, view) return trajprint
def test_attr_err_in_configure(self): # white_box test: configure raised AttributeError - don't raise WafError becasue of that wscript_contents = """ blddir = 'build' srcdir = '.' def configure(conf): raise AttributeError """ self._write_wscript(wscript_contents, use_dic=False) self._setup_options() Utils.set_main_module(self._wscript_file_path) conf = Configure.ConfigurationContext() self.failUnlessRaises(AttributeError, Scripting.configure, conf)
def detect(conf): try:test_for_compiler=Options.options.check_cxx_compiler except AttributeError:raise Configure.ConfigurationError("Add set_options(opt): opt.tool_options('compiler_cxx')") for compiler in test_for_compiler.split(): try: conf.check_tool(compiler) except Configure.ConfigurationError,e: debug('compiler_cxx: %r'%e) else: if conf.env['CXX']: conf.check_message(compiler,'',True) conf.env['COMPILER_CXX']=compiler break conf.check_message(compiler,'',False) break
def closeEvent(self, event): event.ignore() close_state = Configure.read_config() if close_state == '0': self.hide_or_display() elif close_state == '2': QtGui.qApp.quit() else: self.close_dialog = CloseDialog(self) self.close_dialog.setModal(False) self.jiajia = self.close_dialog.exec_() Configure.write_config(self.jiajia) if self.jiajia == 0: self.hide_or_display() #self.ask_next_time = False elif self.jiajia == 1: self.hide_or_display() #self.ask_next_time = True elif self.jiajia == 2: self.ask_next_time = False QtGui.qApp.quit() elif self.jiajia == 3: self.ask_next_time = True QtGui.qApp.quit()
def detect(conf): pocom = conf.find_program('msgfmt') if not pocom: # if msgfmt should not be mandatory, catch the thrown exception in your wscript conf.fatal('The program msgfmt (gettext) is mandatory!') conf.env['POCOM'] = pocom # NOTE: it is possible to set INTLTOOL in the environment, but it must not have spaces in it intltool = conf.find_program('intltool-merge', var='INTLTOOL') if not intltool: # if intltool-merge should not be mandatory, catch the thrown exception in your wscript if Options.platform == 'win32': perl = conf.find_program('perl', var='PERL') if not perl: conf.fatal( 'The program perl (required by intltool) could not be found' ) intltooldir = Configure.find_file( 'intltool-merge', os.environ['PATH'].split(os.pathsep)) if not intltooldir: conf.fatal( 'The program intltool-merge (intltool, gettext-devel) is mandatory!' ) conf.env['INTLTOOL'] = Utils.to_list( conf.env['PERL']) + [intltooldir + os.sep + 'intltool-merge'] conf.check_message('intltool', '', True, ' '.join(conf.env['INTLTOOL'])) else: conf.fatal( 'The program intltool-merge (intltool, gettext-devel) is mandatory!' ) def getstr(varname): return getattr(Options.options, varname, '') prefix = conf.env['PREFIX'] datadir = getstr('datadir') if not datadir: datadir = os.path.join(prefix, 'share') conf.define('LOCALEDIR', os.path.join(datadir, 'locale')) conf.define('DATADIR', datadir) if conf.env['CC'] or conf.env['CXX']: # Define to 1 if <locale.h> is present conf.check(header_name='locale.h')
def test_cxx_is_missing(self): # white_box test: 'compiler_cxx' options are essential for its configuration wscript_contents = """ blddir = 'build' srcdir = '.' def configure(conf): conf.check_tool('compiler_cxx') """ self._write_wscript(wscript_contents, use_dic=False) opt_obj = Options.Handler() opt_obj.parse_args() Options.options.prefix = Options.default_prefix Utils.set_main_module(self._wscript_file_path) conf = Configure.ConfigurationContext() self.failUnlessRaises(Utils.WscriptError, Scripting.configure, conf)
def pkg_check_module_variable(conf,module,variable): pkg_config=conf.env['PKG_CONFIG'] if not pkg_config: conf.fatal("pkg-config is not available") argv=[pkg_config,'--variable',variable,module] cmd=subprocess.Popen(argv,stdout=subprocess.PIPE) out,dummy=cmd.communicate() retval=cmd.wait() out=out.rstrip() msg_checking=("pkg-config variable %r in %s"%(variable,module,)) conf.check_message_custom(msg_checking,'',out) conf.log.write('%r: %r (exit code %i)\n'%(argv,out,retval)) if retval==0: return out else: raise Configure.ConfigurationError('pkg-config check failed')
def test_invalid_tool(self): # white_box test: tool not exists wscript_contents = """ blddir = 'build' srcdir = '.' def configure(conf): conf.check_tool('no_way_such_a_tool_exists_gwerghergjekrhgker') """ self._write_wscript(wscript_contents, use_dic=False) opt_obj = Options.Handler() opt_obj.parse_args() Options.options.prefix = Options.default_prefix Utils.set_main_module(self._wscript_file_path) conf = Configure.ConfigurationContext() self.failUnlessRaises(Utils.WscriptError, Scripting.configure, conf)
def GetStartTime(utc=False): """ CTFの開始時刻を文字列で返す """ config = Configure.LoadConfig() start = config['ctf']['duration']['start'] time_format = config['ctf']['duration']['format'] tz = pytz.timezone(config['ctf']['duration']['timezone']) dt_start = datetime.datetime(start['year'], start['month'], start['date'], start['hour'], start['minute'], start['second'], tzinfo=tz) if utc: return dt_start.astimezone(pytz.timezone('UTC')) else: return dt_start.strftime(time_format)
def GetEndTime(utc=False): """ CTFの修了時刻を文字列で返す """ config = Configure.LoadConfig() end = config['ctf']['duration']['end'] time_format = config['ctf']['duration']['format'] tz = pytz.timezone(config['ctf']['duration']['timezone']) dt_end = datetime.datetime(end['year'], end['month'], end['date'], end['hour'], end['minute'], end['second'], tzinfo=tz) if utc: return dt_end.astimezone(pytz.timezone('UTC')) else: return dt_end.strftime(time_format)
def _setup_configure(self, blddir='', srcdir=''): if not blddir: blddir = self._blddir if not blddir: raise ValueError('no blddir argument, no self._blddir !') if not srcdir: blddir = self._test_dir_root if not blddir: raise ValueError( 'no srcdir argument, no self._test_dir_root !') # Configure uses arguments defined by Options opt_obj = Options.Handler() opt_obj.parse_args() Options.options.prefix = Options.default_prefix return Configure.ConfigurationContext(srcdir=srcdir, blddir=blddir)
def pkg_check_modules(conf, uselib_name, expression, mandatory=True): pkg_config = conf.env['PKG_CONFIG'] if not pkg_config: if mandatory: conf.fatal("pkg-config is not available") else: return False if Options.options.verbose: extra_msg = ' (%s)' % expression else: extra_msg = '' conf.start_msg('Checking for pkg-config flags for %s%s' % (uselib_name, extra_msg)) argv = [pkg_config, '--cflags', '--libs', expression] cmd = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = cmd.communicate() retval = cmd.wait() conf.to_log('%r: %r (exit code %i)\n%s' % (argv, out, retval, err)) if retval != 0: conf.end_msg(False) sys.stderr.write(err) else: if Options.options.verbose: conf.end_msg(out) else: conf.end_msg(True) if retval == 0: conf.parse_flags(out, uselib_name, conf.env) conf.env[uselib_name] = True return True else: conf.env[uselib_name] = False if mandatory: raise Configure.ConfigurationError('pkg-config check failed') else: return False
def __init__(self, File_Name, molclass, molName, label=None): # label defaults to molName if not otherwise specified self.label = label if label == None: self.label = molName self.mol_class = molclass self.mol = molName self.SnapShotList = self.readSnapshots(File_Name) self.Num_Snaps = len(self.SnapShotList) self.graphsPath = Configure.molGraphsPath(molclass, molName) if not os.path.exists(self.graphsPath): os.mkdir(self.graphsPath) # TODO: Check numCarbons self.numCarbon = 5670 return
def detect_sdl(conf): env = conf.env opt = Options.options conf.env['LIB_SDL'] = '' conf.env['LIB_SDL_gfx'] = '' conf.env['SDL_FOUND'] = False libPath = '-Wl,-rpath,' if Options.options.sdl: conf.env['CPPPATH_SDL'] = Options.options.sdl + '/include/SDL' conf.env['CPPPATH_SDL_gfx'] = Options.options.sdl + '/include/SDL' conf.env['LIBPATH_SDL'] = Options.options.sdl + '/lib' conf.env['LIBPATH_SDL_gfx'] = Options.options.sdl + '/lib' libPath += (Options.options.sdl + '/lib') else: conf.env['CPPPATH_SDL'] = [ '/usr/include/SDL', '/usr/local/include/SDL', '/usr/include' ] conf.env['CPPPATH_SDL_gfx'] = [ '/usr/include/SDL', '/usr/local/include/SDL', '/usr/include' ] conf.env['LIBPATH_SDL'] = [ '/usr/lib', '/usr/local/lib', '/usr/lib/SDL' ] conf.env['LIBPATH_SDL_gfx'] = [ '/usr/lib', '/usr/local/lib', '/usr/lib/SDL' ] libPath += '/usr/local/lib' res = Configure.find_file('SDL.h', conf.env['CPPPATH_SDL_gfx']) conf.check_message('header', 'SDL.h', (res != ''), res) if (res == ''): return 0 conf.env['CCDEFINES_SDL'] = ['_GNU_SOURCE=1', '_REENTRANT'] conf.env['CCDEFINES_SDL_gfx'] = ['_GNU_SOURCE=1', '_REENTRANT'] conf.env['CXXDEFINES_SDL'] = ['_GNU_SOURCE=1', '_REENTRANT'] conf.env['CXXDEFINES_SDL_gfx'] = ['_GNU_SOURCE=1', '_REENTRANT'] conf.env['SDL_FOUND'] = True conf.env['HAVE_SDL'] = 1 conf.env['HAVE_SDL_gfx'] = 1 conf.env['LIB_SDL'] = ['SDL', 'pthread'] conf.env['LIB_SDL_gfx'] = ['SDL_gfx'] conf.env['LINKFLAGS_SDL'] = [libPath] return 1
def main(): ''' 完成数据的预处理 ''' configure = Configure('./config.cfg') processing_word = get_processing_word(lowercase=True) # 构造dataset train_dataset = Dataset(configure['train_data'], processing_word=processing_word) dev_dataset = Dataset(configure['train_data'], processing_word=processing_word) test_dataset = Dataset(configure['train_data'], processing_word=processing_word) # 构造word和tag的vocab vocab_util = Vocab_Util() vocab_words, vocab_tags = vocab_util.get_vocabs_from_datasets( [train_dataset, dev_dataset, test_dataset]) # 构造词向量中的词 vocab_glove = vocab_util.get_vocabs_from_glove(configure['glove_file']) # 取交集,同时出现在词向量词典和数据集中的词 vocab_words = vocab_words & vocab_glove # 加入UNK和数字NUM vocab_words.add(UNK) vocab_words.add(NUM) # 保存单词和tag的vocab文件 vocab_util.write_vocab(vocab_words, configure['word_vocab_file']) vocab_util.write_vocab(vocab_tags, configure['tag_vocab_file']) # 获取Trim Glove Vectors,并存储 vocab = vocab_util.load_vocab(configure['word_vocab_file']) vocab_util.export_trimmed_glove_vectors(vocab, configure['glove_file'], configure['trimmed_file'], configure['word_embedding_dim']) # 构造char vocab, 并且进行存储 train_dataset = Dataset(configure['train_data']) vocab_chars = vocab_util.get_char_vocab_from_datasets(train_dataset) vocab_util.write_vocab(vocab_chars, configure['char_vocab_file'])
def detect(conf): try: test_for_compiler = Options.options.check_fortran_compiler except AttributeError: raise Configure.ConfigurationError( "Add set_options(opt): opt.tool_options('compiler_fortran')") for compiler in test_for_compiler.split(): try: conf.check_tool(compiler) except Configure.ConfigurationError: pass else: if conf.env['FC']: conf.check_message("%s" % compiler, '', True) conf.env["COMPILER_FC"] = "%s" % compiler return conf.check_message("%s" % fortran_compiler, '', False) break conf.env["COMPILER_FC"] = None
def detect_eigen(conf): env = conf.env opt = Options.options conf.env['LIB_EIGEN'] = '' conf.env['EIGEN_FOUND'] = False if Options.options.no_eigen: return 0 if Options.options.eigen: conf.env['CPPPATH_EIGEN'] = Options.options.eigen conf.env['LIBPATH_EIGEN'] = Options.options.eigen else: conf.env['CPPPATH_EIGEN'] = ['/usr/include/eigen3', '/usr/local/include/eigen3', '/usr/include', '/usr/local/include'] res = Configure.find_file('Eigen/Core', conf.env['CPPPATH_EIGEN']) conf.check_message('header','Eigen/Core', (res != '') , res) if (res == '') : return 0 conf.env['EIGEN_FOUND'] = True return 1
def detect_mpi(conf): env = conf.env opt = Options.options conf.env['LIB_MPI'] = 'mpi' conf.env['MPI_FOUND'] = False if Options.options.no_mpi : return if Options.options.mpi: conf.env['CPPPATH_MPI'] = Options.options.mpi + '/include' conf.env['LIBPATH_MPI'] = [Options.options.mpi + '/lib', Options.options.mpi + '/lib64'] else: conf.env['CPPPATH_MPI'] = ['/usr/include/mpi', '/usr/local/include/mpi', '/usr/include', '/usr/local/include'] conf.env['LIBPATH_MPI'] = ['/usr/lib', '/usr/local/lib'] res = Configure.find_file('mpi.h', conf.env['CPPPATH_MPI'] ) conf.check_message('header','mpi.h', (res != '') , res) if (res == '') : return 0 conf.env['MPI_FOUND'] = True return 1
def detect(conf): pocom = conf.find_program("msgfmt") if not pocom: # if msgfmt should not be mandatory, catch the thrown exception in your wscript conf.fatal("The program msgfmt (gettext) is mandatory!") conf.env["POCOM"] = pocom # NOTE: it is possible to set INTLTOOL in the environment, but it must not have spaces in it intltool = conf.find_program("intltool-merge", var="INTLTOOL") if not intltool: # if intltool-merge should not be mandatory, catch the thrown exception in your wscript if Options.platform == "win32": perl = conf.find_program("perl", var="PERL") if not perl: conf.fatal("The program perl (required by intltool) could not be found") intltooldir = Configure.find_file("intltool-merge", os.environ["PATH"].split(os.pathsep)) if not intltooldir: conf.fatal("The program intltool-merge (intltool, gettext-devel) is mandatory!") conf.env["INTLTOOL"] = Utils.to_list(conf.env["PERL"]) + [intltooldir + os.sep + "intltool-merge"] conf.check_message("intltool", "", True, " ".join(conf.env["INTLTOOL"])) else: conf.fatal("The program intltool-merge (intltool, gettext-devel) is mandatory!") def getstr(varname): return getattr(Options.options, varname, "") prefix = conf.env["PREFIX"] datadir = getstr("datadir") if not datadir: datadir = os.path.join(prefix, "share") conf.define("LOCALEDIR", os.path.join(datadir, "locale")) conf.define("DATADIR", datadir) if conf.env["CC"] or conf.env["CXX"]: # Define to 1 if <locale.h> is present conf.check(header_name="locale.h")
def detect(conf): pocom = conf.find_program('msgfmt') if not pocom: # if msgfmt should not be mandatory, catch the thrown exception in your wscript conf.fatal('The program msgfmt (gettext) is mandatory!') conf.env['POCOM'] = pocom # NOTE: it is possible to set INTLTOOL in the environment, but it must not have spaces in it intltool = conf.find_program('intltool-merge', var='INTLTOOL') if not intltool: # if intltool-merge should not be mandatory, catch the thrown exception in your wscript if Options.platform == 'win32': perl = conf.find_program('perl', var='PERL') if not perl: conf.fatal('The program perl (required by intltool) could not be found') intltooldir = Configure.find_file('intltool-merge', os.environ['PATH'].split(os.pathsep)) if not intltooldir: conf.fatal('The program intltool-merge (intltool, gettext-devel) is mandatory!') conf.env['INTLTOOL'] = Utils.to_list(conf.env['PERL']) + [intltooldir + os.sep + 'intltool-merge'] conf.check_message('intltool', '', True, ' '.join(conf.env['INTLTOOL'])) else: conf.fatal('The program intltool-merge (intltool, gettext-devel) is mandatory!') def getstr(varname): return getattr(Options.options, varname, '') prefix = conf.env['PREFIX'] datadir = getstr('datadir') if not datadir: datadir = os.path.join(prefix,'share') conf.define('LOCALEDIR', os.path.join(datadir, 'locale')) conf.define('DATADIR', datadir) if conf.env['CC'] or conf.env['CXX']: # Define to 1 if <locale.h> is present conf.check(header_name='locale.h')
def detect(conf): # xml2po xml2po = conf.find_program('xml2po', var='XML2PO') if not xml2po: # xml2po: on win32 'xml2po' is not executable thus this hook if conf.env['IS_WIN32']: python = conf.find_program('python', var='PYTHON') if not python: conf.fatal('The program python (required by xml2po) could not be found') xml2podir = Configure.find_file('xml2po', os.environ['PATH'].split(os.pathsep)) if not xml2podir: conf.fatal('The program xml2po is mandatory!') conf.env['XML2PO'] = Utils.to_list(conf.env['PYTHON']) + [xml2podir + os.sep + 'xml2po'] conf.check_message('xml2po', '', True, ' '.join(conf.env['XML2PO'])) else: conf.fatal('The program xml2po is mandatory!') if conf.env['IS_WIN32']: xsltproc = conf.find_program('xsltproc', var='XSLTPROC') htmlhelpc = conf.find_program('hhc', var='HTMLHELPC')
from __future__ import print_function from SensorsResponse import * from PlotUtil import * import Configure as CF from Nh5 import * from cities import dorotea from LogConfig import * """ Code """ if __name__ == '__main__': INFO, CFP = CF.configure(sys.argv[0],sys.argv[1:]) if INFO: print(dorotea) wait() print(""" DOROTEA: 1. Reads an MCRD file produced by NEXUS, which stores TWF1ns waveforms for the PMTs and SiPMs as well as data on geometry, sensors and MC. 2. Simulates the response of the energy plane in the PMTs and outputs PMT TWF25ns e.g., waveforms in bins of 25 ns (and in adc counts) which correspond to the output of the EP FEE.
def run_configure(opts, args): Configure.opts = opts Configure.args = args Configure.main(opts.configfile)
conf.log.write('%r: %r (exit code %i)\n'%(argv,out,retval)) if retval==0: config_c.parse_flags(out,uselib_name,conf.env) conf.env[uselib_name]=True return True else: conf.env[uselib_name]=False if mandatory: raise Configure.ConfigurationError('pkg-config check failed') else: return False def pkg_check_module_variable(conf,module,variable): pkg_config=conf.env['PKG_CONFIG'] if not pkg_config: conf.fatal("pkg-config is not available") argv=[pkg_config,'--variable',variable,module] cmd=subprocess.Popen(argv,stdout=subprocess.PIPE) out,dummy=cmd.communicate() retval=cmd.wait() out=out.rstrip() msg_checking=("pkg-config variable %r in %s"%(variable,module,)) conf.check_message_custom(msg_checking,'',out) conf.log.write('%r: %r (exit code %i)\n'%(argv,out,retval)) if retval==0: return out else: raise Configure.ConfigurationError('pkg-config check failed') Configure.conf(pkg_check_modules) Configure.conf(pkg_check_module_variable)