Exemplo n.º 1
0
    def OnSave(self, event):
        self.pathname = self.locField.GetValue()

        self.pathname = os.path.abspath(
            os.path.expanduser(os.path.expandvars(self.pathname)))

        if not os.path.isdir(self.pathname):
            wx.MessageBox(
                parent=self,
                message=
                "Product-file directory location is not a valid directory.",
                caption="Error",
                style=wx.OK | wx.ICON_ERROR | wx.STAY_ON_TOP)
            return

        coda.set_option_filter_record_fields(
            not self.filterRecordFields.GetValue())
        coda.set_option_perform_conversions(self.performConversions.GetValue())

        self.config.Write('DirectoryLocation/Products', self.pathname)
        self.config.WriteBool('ProductBrowser/ShowByteSize',
                              self.showByteSize.GetValue())
        self.config.WriteBool('CODA/PerformConversions',
                              coda.get_option_perform_conversions())
        self.config.WriteBool('CODA/FilterRecordFields',
                              coda.get_option_filter_record_fields())
        self.config.Flush()

        self.EndModal(wx.ID_OK)
Exemplo n.º 2
0
Arquivo: app.py Projeto: stcorp/visan
    def OnInit(self):

        # Make sure the file location for our preferences exists
        userDataDir = wx.StandardPaths.Get().GetUserDataDir()
        if not os.path.exists(userDataDir):
            os.mkdir(userDataDir)

        self.productdir = wx.StandardPaths.Get().GetDocumentsDir()

        # Initialize preferences
        configStyle = wx.CONFIG_USE_LOCAL_FILE
        if wx.Platform == '__WXGTK__':
            configStyle |= wx.CONFIG_USE_SUBDIR
        config = wx.Config(appName='visan', style=configStyle)
        config.SetRecordDefaults()
        wx.Config.Set(config)

        # Set some global defaults
        config.Read('UserMode', 'EndUser')
        config.Read('DirectoryLocation/Export', wx.StandardPaths.Get().GetDocumentsDir())
        config.Read('DirectoryLocation/Products', self.productdir)
        config.Read('DirectoryLocation/Scripts', self.exampledir)
        # datadir is not something that the user should change, but it is usefull to be able to get
        # to this parameter using the Config system, so that is why we set it here explicitly
        config.Write('DirectoryLocation/ApplicationData', self.datadir)
        # since icons are platform specific we store the appropriate icon to use in the config
        if wx.Platform == '__WXGTK__':
            config.Write('IconFile', os.path.join(self.datadir, "visan32.ico"))
        else:
            config.Write('IconFile', os.path.join(self.datadir, "visan.ico"))

        if config.Read('UserMode') == 'Developer':
            # allows you to pop up a window with an overview of all the widgets in VISAN
            # the shortcut for this is Ctrl-Alt-I (or Cmd-Alt-I on Mac)
            InspectionMixin.Init(self)

        self.filehistory = wx.FileHistory()
        self.recentfiles = False

        coda.set_option_perform_conversions(config.ReadBool('CODA/PerformConversions', True))
        coda.set_option_filter_record_fields(config.ReadBool('CODA/FilterRecordFields', True))

        self.frame = VisanFrame(self, "VISAN " + VERSION, WindowHandler.GetNextPosition((800, 640)), (800, 640))
        self.SetTopWindow(self.frame)
        self.shell = self.frame.shell

        self._PrefsToFileHistory()

        self._SetupLogging()

        wx.py.dispatcher.connect(receiver=self.CheckForExit, signal='Interpreter.push')

        self.frame.Show(True)

        if wx.Config.Get().ReadBool('ShowIntroFrame', True):
            self.ShowIntro()

        self._CreateSplashScreen()

        if len(sys.argv) > 1:
            # don't treat macos -psn arguments as a startup script
            if not (wx.Platform == '__WXMAC__' and sys.argv[1].startswith('-psn_')):
                self._ExecuteScript(sys.argv[1])

        return True
Exemplo n.º 3
0
                print_data(cursor)
                print ""

            if i < num_fields - 1:
                coda.cursor_goto_next_record_field(cursor)

        coda.cursor_goto_parent(cursor)


if __name__ == "__main__":

    if len(sys.argv) != 2:
        print >> sys.stderr, "Usage: %s <envisat file>" % sys.argv[0]
        sys.exit(1)
        
    coda.set_option_perform_conversions(0)

    pf = coda.open(sys.argv[1])
    product_class = coda.get_product_class(pf)
    if not product_class.startswith("ENVISAT"):
        print >>sys.stderr, "Error: file %s is not an ENVISAT product file (product class = %s)" % (sys.argv[1], product_class)
        sys.exit(1)

    cursor = coda.Cursor()
    coda.cursor_set_product(cursor, pf)

    print "  MPH :"
    coda.cursor_goto_record_field_by_name(cursor, "mph")
    print_record(cursor)
    coda.cursor_goto_parent(cursor)