def run(): """ Run HDFCompass. Handles all command-line arguments, etc. """ import os.path as op app = CompassApp(False) load_plugins() urls = sys.argv[1:] for url in urls: if "://" not in url: # assumed to be file path url = utils.path2url(op.abspath(url)) if not open_store(url): log.warning('Failed to open "%s"; no handlers' % url) f = frame.InitFrame() if utils.is_darwin: wx.MenuBar.MacSetCommonMenuBar(f.GetMenuBar()) else: f.Show() app.MainLoop()
def run(): """ Run BAG Explorer. Handles all command-line arguments, etc.""" try: import faulthandler faulthandler.enable() except ImportError: pass import sys import os.path as op app = BagExplorerApp(False) load_plugins() urls = sys.argv[1:] for url in urls: if "://" not in url: # assumed to be file path url = utils.path2url(op.abspath(url)) if not open_store(url): log.warning('Failed to open "%s"; no handlers' % url) f = frame.InitFrame() if utils.is_darwin: wx.MenuBar.MacSetCommonMenuBar(f.GetMenuBar()) else: f.Show() app.MainLoop()
def on_file_open(self, evt): """ Request to open a file via the Open entry in the File menu """ def make_filter_string(): """ Make a wxPython dialog filter string segment from dict """ filter_string = [] hdf_filter_string = [] # put HDF filters in the front for store in compass_model.get_stores(): if len(store.file_extensions) == 0: continue for key in store.file_extensions: s = "{name} ({pattern_c})|{pattern_sc}".format( name=key, pattern_c=",".join(store.file_extensions[key]), pattern_sc=";".join(store.file_extensions[key])) if s.startswith("HDF"): hdf_filter_string.append(s) else: filter_string.append(s) filter_string = hdf_filter_string + filter_string filter_string.append('All Files (*.*)|*.*') pipe = "|" return pipe.join(filter_string) wc_string = make_filter_string() dlg = wx.FileDialog(self, "Open Local File", wildcard=wc_string, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if dlg.ShowModal() != wx.ID_OK: return path = dlg.GetPath() url = path2url(path) self.open_url(url)
def on_file_open(self, evt): """ Request to open a file via the Open entry in the File menu """ def make_filter_string(): """ Make a wxPython dialog filter string segment from dict """ filter_string = [] hdf_filter_string = [] # put HDF filters in the front for store in compass_model.get_stores(): if len(store.file_extensions) == 0: continue for key in store.file_extensions: s = "{name} ({pattern_c})|{pattern_sc}".format( name=key, pattern_c=",".join(store.file_extensions[key]), pattern_sc=";".join(store.file_extensions[key]) ) if s.startswith("BAG"): hdf_filter_string.append(s) else: filter_string.append(s) filter_string = hdf_filter_string + filter_string filter_string.append('All Files (*.*)|*.*') pipe = "|" return pipe.join(filter_string) wc_string = make_filter_string() dlg = wx.FileDialog(self, "Open Local File", wildcard=wc_string, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if dlg.ShowModal() != wx.ID_OK: return path = dlg.GetPath() url = utils.path2url(path) self.open_url(url)
def on_open_samples(self, evt): """ Request to open a file via the Open entry in the File menu """ def make_filter_string(): """ Make a wxPython dialog filter string segment from dict """ filter_string = [] hdf_filter_string = [] # put HDF filters in the front for store in compass_model.get_stores(): if len(store.file_extensions) == 0: continue for key in store.file_extensions: s = "{name} ({pattern_c})|{pattern_sc}".format( name=key, pattern_c=",".join(store.file_extensions[key]), pattern_sc=";".join(store.file_extensions[key])) if s.startswith("BAG"): hdf_filter_string.append(s) else: filter_string.append(s) filter_string = hdf_filter_string + filter_string filter_string.append('All Files (*.*)|*.*') pipe = "|" return pipe.join(filter_string) wc_string = make_filter_string() samples_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), os.pardir, "bag", "samples")) if os.path.exists(samples_dir): logger.debug("samples folder: %s" % samples_dir) else: logger.warning("missing samples folder: %s" % samples_dir) dlg = wx.FileDialog(self, "Open Samples Folder", defaultDir=samples_dir, wildcard=wc_string, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if dlg.ShowModal() != wx.ID_OK: return path = dlg.GetPath() url = utils.path2url(path) self.open_url(url)
def on_open_samples(self, evt): """ Request to open a file via the Open entry in the File menu """ def make_filter_string(): """ Make a wxPython dialog filter string segment from dict """ filter_string = [] hdf_filter_string = [] # put HDF filters in the front for store in compass_model.get_stores(): if len(store.file_extensions) == 0: continue for key in store.file_extensions: s = "{name} ({pattern_c})|{pattern_sc}".format( name=key, pattern_c=",".join(store.file_extensions[key]), pattern_sc=";".join(store.file_extensions[key]) ) if s.startswith("BAG"): hdf_filter_string.append(s) else: filter_string.append(s) filter_string = hdf_filter_string + filter_string filter_string.append('All Files (*.*)|*.*') pipe = "|" return pipe.join(filter_string) wc_string = make_filter_string() samples_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "bag", "samples")) if os.path.exists(samples_dir): logger.debug("samples folder: %s" % samples_dir) else: logger.warning("missing samples folder: %s" % samples_dir) dlg = wx.FileDialog(self, "Open Samples Folder", defaultDir=samples_dir, wildcard=wc_string, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if dlg.ShowModal() != wx.ID_OK: return path = dlg.GetPath() url = utils.path2url(path) self.open_url(url)