def _load_cut(config_path): config = ConfigFile(config_path) cut = VertexCut() cut.minZ = config.get("minZ", cut.minZ) cut.maxZ = config.get("maxZ", cut.maxZ) cut.minR = config.get("minR", cut.minR) cut.maxR = config.get("maxR", cut.maxR) return cut
def __init__(self, filename): self.config = ConfigFile(filename) dbmapper = { "mysql": ReaderMysql, "oracle": ReaderOracle, "sqlserver": ReaderSqlserver } if not dbmapper.has_key(self.config.source_db_type): raise Exception("Unsupport database type :%s" % self.config.source_db_type) logger.info("server param: source database type is %s" % self.config.source_db_type) dbclass = dbmapper.get(self.config.source_db_type) self.db_reader = dbclass( host=self.config.source_db_host, port=self.config.source_db_port, dbname=self.config.source_db_dbname, username=self.config.source_db_user, password=self.config.source_db_passwd, magic_field_name=DataMigration.magic_field_name) self.db_writer = WriterMysql( host=self.config.destination_mysql_host, port=self.config.destination_mysql_port, dbname=self.config.destination_mysql_dbname, username=self.config.destination_mysql_user, password=self.config.destination_mysql_passwd, magic_field_name=DataMigration.magic_field_name) self.db_reader.connect() self.db_writer.connect()
def __init__(self, filename): self.config = ConfigFile(filename) self.mysql_settings = { 'host': self.config.destination_mysql_host, 'port': self.config.destination_mysql_port, 'user': self.config.destination_mysql_user, 'passwd': self.config.destination_mysql_passwd }
class GlobalSettings(gobject.GObject): dialogs_dir = _unicode_property('dialogs_dir') examples_dir = _unicode_property('examples_dir') config_dir = _unicode_property('config_dir') icon_file = _unicode_property('icon_file') notebooks_dir = _unicode_property('notebooks_dir') mini_mode = gobject.property(type=bool, default=False) main_menu_mode = gobject.property(type=bool, default=False) version = gobject.property(type=str) editor_font_is_custom = _bool_property('editor_font_is_custom', default=False) editor_font_name = _string_property('editor_font_name', default="Monospace 12") doc_tooltip_font_is_custom = _bool_property('doc_tooltip_font_is_custom', default=False) doc_tooltip_font_name = _string_property('doc_tooltip_font_name', default="Sans 11") autocomplete = _bool_property('autocomplete', default=True) def __init__(self): gobject.GObject.__init__(self) if sys.platform == 'win32': self.config_dir = os.path.join( os.getenv('APPDATA').decode('mbcs'), 'Reinteract') else: self.config_dir = os.path.expanduser(u"~/.reinteract") try: # Added in pygobject-2.18 documents_dir = glib.get_user_special_dir( glib.USER_DIRECTORY_DOCUMENTS).decode("UTF-8") except AttributeError, e: # In a shocking example of cross-platform convergence, ~/Documents # is the documents directory on OS X, Windows, and Linux, except # when localized documents_dir = os.path.expanduser(u"~/Documents") self.notebooks_dir = os.path.join(documents_dir, 'Reinteract') if not os.path.isdir(self.notebooks_dir): os.makedirs(self.notebooks_dir) config_location = os.path.join(self.config_dir, 'reinteract.conf') self.config = ConfigFile(config_location) self.__watches = [] self.connect('notify', self.on_notify)
def main(): ap = argparse.ArgumentParser() ap.add_argument('studyname', choices=['shower', 'accIsol', 'shower_nearNom']) ap.add_argument('-d', '--outdir', default=os.getenv('IBDSEL_CONFIGDIR')) ap.add_argument('-i', '--identifier') args = ap.parse_args() if args.outdir is None: print("Need either --outdir or $IBDSEL_CONFIGDIR") sys.exit(1) config = ConfigFile(template_path()) os.system(f"mkdir -p {args.outdir}") eval(args.studyname)(config, args.outdir, args.identifier)
def __init__(self, phase, tag, config, delayed_eff_mode="rel", delayed_eff_impl="add-then-calc", delayed_eff_ref=None, vtx_eff_nom_tagconf=None): self.phase = phase self.tag = tag self.config = config self.delayed_eff_mode = delayed_eff_mode if delayed_eff_impl == "new": delayed_eff_impl = "add-then-calc" self.delayed_eff_impl = delayed_eff_impl self.hardcoded = Hardcoded(phase) self.files, self.results = {}, {} for site in [1, 2, 3]: path = stage2_pbp_path(site, phase, tag, config) self.files[site] = R.TFile(path) results = read_root(path, 'results') for det in dets_for_phase(site, phase): self.results[(site, det)] = \ results.query(f'detector == {det}') cfg_path = configfile_path(tag, config) self.cfg = ConfigFile(cfg_path) if delayed_eff_impl == "old": ref_tag, ref_conf = delayed_eff_ref.split("@") self.delEffCalc = DelayedEffCalc(self.cfg['ibdDelayedEmin'], self.phase, ref_tag, ref_conf) self.promptEffCalc = PromptEffCalc(cfg_path) if vtx_eff_nom_tagconf: nom_tag, nom_conf = vtx_eff_nom_tagconf.split("@") self.vertexEffCalc = VertexEffCalc(self, phase, tag, config, nom_tag, nom_conf) else: self.vertexEffCalc = DummyVertexEffCalc()
def get_config_file() -> ConfigFile: """ Retrieve the path to the configuration file. Retrieved in the following order: * The STB_CONFIG_FILE_PATH enviroment variable if it exists. * User configuration file at ~/.stb/config.toml if it exists. * The default configuration file in the stb module. Returns: A ConfigFile for that path that was found first in the search heirarchy. """ search_hierarchy = [ STB_CONFIG_FILE_ENV_VAR, STB_USER_CONFIG_FILE if STB_USER_CONFIG_FILE.exists() else None, STB_INTERNAL_CONFIG_FILE, ] for path in search_hierarchy: if path: return ConfigFile(path)
def main(): if not appex.is_running_extension(): print( 'Running in Pythonista app. Use via sharing extension with a .zip file instead.' ) exit(1) config = ConfigFile(config_path) if not config.key_exists('FIRST_RUN'): first_run(config) root = config.get('ROOT') dest = config.get('DEST') zip_src = appex.get_file_path() zip_name = zip_src.split(os.sep)[-1] cv = ConfirmView.load_view(dest, zip_name) cv.present() cv.wait_modal() if cv.proceed: new_dest = cv.path clear_first = cv.clearfirst if dest != new_dest: config.set('DEST', new_dest) dest = new_dest config.save() os.chdir(root) if clear_first and os.path.exists(dest): shutil.rmtree(dest) if not os.path.exists(dest): os.makedirs(dest) with ZipFile(zip_src, 'r') as zipo: zipo.extractall(dest) print('Done.') else: print('Cancelled by user.')
def __init__(self, output_file, augmented_site_level_config, execution_id): ConfigFile.__init__(self, output_file, augmented_site_level_config, execution_id)
print('resp_message=' + resp['message']) if resp['done']: self.progressbar.stop() self.progressbar.grid_remove() self.var_message.set(resp['message']) #self.label_message.grid() self.queue.task_done() self.queue.queue.clear() self.thread.join() self.destroy() else: self.var_message.set(resp['message']) if __name__ == "__main__": root = tk.Tk() width = 1000 height = 500 hs = root.winfo_screenheight() ws = root.winfo_screenwidth() root.geometry('%dx%d+%d+%d' % (width, height, (ws - width) // 2, (hs - height) // 2)) dir_gui = os.path.dirname(__file__) dir_root = os.path.dirname(dir_gui) config_path = os.path.join(dir_root, 'config.ini') config_file = ConfigFile(config_path) explorer = data_explorer.DataExplorer(config_file, 'c:/1/vsol.db') parser = vsol_parser.VsolParser(config_file) update_clubs_window = UpdateClubsWindow(800, 160, explorer, parser, False) #update_clubs_window.update_all() update_clubs_window.update_hiddens() root.mainloop()
def __init__(self, location): ConfigFile.__init__(self, location) self.notebook_states = {} self.worksheet_states = {}
def __init__(self, location): ConfigFile.__init__(self, location) self.notebook_states = {} self.worksheet_states = {}
#!/usr/bin/python # -*- coding: utf-8 -*- from config_file import ConfigFile from gui import main_window if __name__ == "__main__": config_file = ConfigFile() main_window.MainWindow(1000, 500, 'logo.ico', 'logo.gif', config_file)
def config_file(self): return ConfigFile(self.client)
def min_energy(tag, config): cfg = ConfigFile(configfile_path(tag, config)) return cfg["ibdPromptEmin"]
def find_files(self): files = finder_utils.glob_project(self.root_path, self.GLOB_PATTERN) files = [filename for filename in files if os.path.isfile(filename)] return [ConfigFile(filename) for filename in files]
def __init__(self, config_path): config = ConfigFile(config_path) self.emin = config["ibdPromptEmin"]
#countries = self.de.get_all_countries() #clubs = self.exporter.get_clubs(countries) #for club in clubs: #self.de.save_club(club["name"], club["vsol_id"], club["country_vsol_id"], club["stadium"], #club["is_hidden"]) #tkinter.messagebox.showinfo("Сообщение", "Информация о клубах обновлена успешно!") upWindow = update_clubs_window.UpdateClubsWindow(800, 160, self.de, self.parser, False) upWindow.update_all() def update_hiddens(self): answer = tkinter.messagebox.askyesno(title="Вопрос", message="Обновить информацию о скрытых клубах?") if answer: upWindow = update_clubs_window.UpdateClubsWindow(800, 160, self.de, self.parser, False) upWindow.update_hiddens() def update_selected_country(self): if not self.selected_country_id: tkinter.messagebox.showinfo("Сообщение", "Страна не выбрана") answer = tkinter.messagebox.askyesno(title="Вопрос", message="Обновить клубы в выбранной стране?") if answer: upWindow = update_clubs_window.UpdateClubsWindow(800, 160, self.de, self.parser, False) upWindow.update_selected_country(self.selected_country_id) if __name__ == "__main__": dir_gui = os.path.dirname(__file__) dir_root = os.path.dirname(dir_gui) config_path = os.path.join(dir_root, 'config.ini') config = ConfigFile(config_path) MainWindow(1000, 500, '../logo.ico', '../logo.gif', config)
#!/usr/bin/env python # -*- coding: utf-8 -*- from flask import Flask from config_file import ConfigFile app = Flask(__name__) conf = ConfigFile.instance() adminmessage = conf.get_property('adminmessage') admindata = conf.get_property('admindata') @app.route("/") def sendbirdtakehome(): # return "Hello SendBird Takehome" # return adminmessage return admindata if __name__ == "__main__": try: service_port = int(conf.get_property('service.port')) except ValueError: service_port = 5000 service_host = conf.get_property('service.host') service_debug = bool(conf.get_property('service.debug')) app.run(host=service_host, port=service_port, debug=service_debug)