Exemplo n.º 1
0
def doimport(paths, palette):
    if not paths or not prefs.package: return False
    pkgpath = glob(join(prefs.xplane, gcustom, prefs.package))[0]
    try:
        files=importpaths(pkgpath, paths)
    except EnvironmentError, e:
        if __debug__: print_exc()
        myMessageBox(str(e.strerror), "Can't import %s" % e.filename, wx.ICON_ERROR|wx.OK, palette.frame)
        return False
Exemplo n.º 2
0
def doimport(paths, palette):
    if not paths or not prefs.package: return False
    pkgpath = glob(join(prefs.xplane, gcustom, prefs.package))[0]
    try:
        files = importpaths(pkgpath, paths)
    except EnvironmentError, e:
        if __debug__: print_exc()
        myMessageBox(str(e.strerror), "Can't import %s" % e.filename,
                     wx.ICON_ERROR | wx.OK, palette.frame)
        return False
Exemplo n.º 3
0
    def onConvert(self, evt):
        dumplib=self.dumplib.GetValue()
        fspath=self.fspath.GetValue().strip()
        lbpath=self.lbpath.GetValue().strip()
        xppath=self.xppath.GetValue().strip()
        if not xppath:
            myMessageBox('You must specify an X-Plane scenery location',
                         "Can't convert.", wx.ICON_ERROR|wx.OK, self)
            return
        xppath=abspath(xppath)

        if not dumplib:
            if not fspath:
                myMessageBox('You must specify a MSFS scenery location',
                             "Can't convert.", wx.ICON_ERROR|wx.OK, self)
                return
            fspath=abspath(fspath)
            if not lbpath:
                lbpath=None
            else:
                lbpath=abspath(lbpath)
            if basename(xppath).lower()=='custom scenery':
                xppath=join(xppath, asciify(basename(fspath)))
        else:
            fspath=None
            if not lbpath:
                myMessageBox('You must specify a MSFS library location',
                             "Can't convert.", wx.ICON_ERROR|wx.OK, self)
                return
            lbpath=abspath(lbpath)
            if basename(xppath).lower()=='custom scenery':
                xppath=join(xppath, asciify(basename(lbpath)))
            
        season=self.season.GetSelection()	# zero-based
        xpver=self.xpver.GetSelection()+8	# zero-based

        try:
            self.logname=abspath(join(xppath, 'summary.txt'))
            if not isdir(dirname(self.logname)):
                mkdir(dirname(self.logname))
            logfile=file(self.logname, 'wt')
            logfile.write("%sTarget:\tX-Plane %d\n\n" % (sysdesc,xpver))
            logfile.close()
        except IOError, e:
            myMessageBox('Can\'t write to folder\n"%s"' % xppath,
                         e.strerror, wx.ICON_ERROR|wx.OK, self)
            return
Exemplo n.º 4
0
    def __init__(self, parent, id, title):

        self.progress = None	# Current progress dialog (or None)
        self.logname = None
        
        wx.Frame.__init__(self,parent,id,title)

        if platform=='win32':
            self.SetIcon(wx.Icon(executable, wx.BITMAP_TYPE_ICO))
        elif platform.lower().startswith('linux'):	# PNG supported by GTK
            icons=wx.IconBundle()
            icons.AddIconFromFile('Resources/%s.png' % appname, wx.BITMAP_TYPE_PNG)
            icons.AddIconFromFile('Resources/%s-128.png'% appname, wx.BITMAP_TYPE_PNG)
            self.SetIcons(icons)
        elif platform=='darwin':
            # icon pulled from Resources via Info.plist (except for MessageBox icon). Need minimal menu
            menubar = wx.MenuBar()
            helpmenu = wx.Menu()
            helpmenu.Append(wx.ID_HELP, '%s Help\tCtrl-?'  % appname)
            wx.EVT_MENU(self, wx.ID_HELP, self.onHelp)
            helpmenu.Append(wx.ID_ABOUT, 'About %s'  % appname)
            wx.EVT_MENU(self, wx.ID_ABOUT, self.onAbout)
            # ID_EXIT moved to application menu
            helpmenu.Append(wx.ID_EXIT, u'Quit %s\tCtrl-Q' % appname)
            wx.EVT_MENU(self, wx.ID_EXIT, self.onClose)
            menubar.Append(helpmenu, '&Help')
            self.SetMenuBar(menubar)

        panel0 = wx.Panel(self,-1)
        panel1 = wx.Panel(panel0,-1)
        panel2 = wx.Panel(panel0,-1)
        panel3 = wx.Panel(panel0,-1)

        # 1st panel
        self.fspath=wx.TextCtrl(panel1, -1, fspath)
        self.fsbrowse=wx.Button(panel1, FSBROWSE, browse)
        self.lbpath=wx.TextCtrl(panel1, -1, lbpath)
        self.lbbrowse=wx.Button(panel1, LBBROWSE, browse)
        self.xppath=wx.TextCtrl(panel1, -1, xppath)
        self.xpbrowse=wx.Button(panel1, XPBROWSE, browse)
        grid1 = wx.FlexGridSizer(3, 3, 7, 7)
        grid1.AddGrowableCol(1,proportion=1)
        grid1.SetFlexibleDirection(wx.HORIZONTAL)
        grid1.Add(wx.StaticText(panel1, -1, "MSFS scenery location: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.fspath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.fsbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        grid1.Add(wx.StaticText(panel1, -1, "Additional MSFS libraries: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.lbpath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.lbbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        grid1.Add(wx.StaticText(panel1, -1, "X-Plane scenery location: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.xppath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.xpbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        panel1.SetSizer(grid1)

        wx.EVT_BUTTON(self, FSBROWSE, self.onFSbrowse)
        wx.EVT_BUTTON(self, LBBROWSE, self.onLBbrowse)
        wx.EVT_BUTTON(self, XPBROWSE, self.onXPbrowse)

        # 2nd panel
        self.xpver  = wx.RadioBox(panel2,-1, "Minimum X-Plane version:",
                                  choices=["v8", "v9", "v10"])
        self.xpver.SetSelection(2)	# v10 default
        self.season = wx.RadioBox(panel2,-1, "Season:",
                                  choices=["Spring", "Summer",
                                           "Autumn", "Winter"])
        self.dumplib= wx.CheckBox(panel2,-1, "Just extract library objects")
        # use panel and sizer so tab order works normally
        box2 = wx.BoxSizer(wx.HORIZONTAL)
        box2.Add(self.xpver, 0)
        box2.Add(self.season, 0, wx.LEFT, 10)
        box2.Add([0,0], 1, wx.LEFT, 10)	# push following buttons to right
        box2.Add(self.dumplib, 0, wx.TOP|wx.EXPAND, 8)
        panel2.SetSizer(box2)

        wx.EVT_CHECKBOX(self, self.dumplib.GetId(), self.onDump)

        
        # 3rd panel - adjust order of buttons per Windows or Mac conventions
        if platform=='darwin':
            button31=wx.Button(panel3, wx.ID_EXIT)
            button32=wx.Button(panel3, wx.ID_APPLY, "Convert")
            button33=wx.Button(panel3, wx.ID_HELP)
            box3 = wx.BoxSizer(wx.HORIZONTAL)
            box3.Add([24,0], 0)	# cosmetic - balance button31
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button31, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([6,0], 0)	# cosmetic
            box3.Add(button32, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button33, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            button32.SetDefault()
        else:
            button31=wx.Button(panel3, wx.ID_HELP)
            if platform=='win32':
                button32=wx.Button(panel3, wx.ID_EXIT)
            else:
                button32=wx.Button(panel3, wx.ID_CLOSE)
            button33=wx.Button(panel3, wx.ID_APPLY, "Convert")
            box3 = wx.BoxSizer(wx.HORIZONTAL)
            box3.Add(button31, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button32, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([6,0], 0)	# cosmetic
            box3.Add(button33, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            button33.SetDefault()
        panel3.SetSizer(box3)
        
        wx.EVT_BUTTON(self, wx.ID_HELP, self.onHelp)
        wx.EVT_BUTTON(self, wx.ID_APPLY, self.onConvert)
        wx.EVT_BUTTON(self, wx.ID_CLOSE, self.onClose)
        wx.EVT_BUTTON(self, wx.ID_EXIT, self.onClose)


        # Top level
        box0 = wx.BoxSizer(wx.VERTICAL)
        box0.Add(panel1, 0, wx.ALL|wx.EXPAND, 7)
        box0.Add(panel2, 0, wx.ALL|wx.EXPAND, 7)
        box0.Add(panel3, 0, wx.ALL|wx.EXPAND, 7)
        panel0.SetSizer(box0)

        border = wx.BoxSizer()
        border.Add(panel0, 1, wx.EXPAND)
        self.SetSizer(border)

        # Go
        sz=self.GetBestSize()
        if wx.VERSION<(2,6):
            # Hack - Can't get min size to work properly in 2.5
            height=sz.height+42
        else:
            height=sz.height            
        self.SetSize((800, height))
        # +50 is a hack cos I can't work out how to change minsize of TextCtrl
        self.SetSizeHints(sz.width, height, -1, height)
        self.Show(True)

        if platform=='darwin':
            # Change name on application menu. Can't do this in wx.
            try:	# Carbon
                from Carbon import Menu
                Menu.GetMenuHandle(1).SetMenuTitleWithCFString(appname)		# wxMac always uses id 1.
            except:
                try:	# Cocoa
                    import AppKit
                    # doesn't work: AppKit.NSApp.mainMenu().itemAtIndex_(0).submenu().setTitle_(appname)	 http://www.mail-archive.com/[email protected]/msg43196.html
                    AppKit.NSBundle.mainBundle().infoDictionary()['CFBundleName']=appname
                except:
                    if __debug__: print_exc()

        if newfsroot: myMessageBox('Install MSFS sceneries under: \n%s ' % newfsroot, 'Created a fake MSFS installation.', wx.ICON_INFORMATION|wx.OK, self)
Exemplo n.º 5
0
class MainWindow(wx.Frame):
    def __init__(self, parent, id, title):

        self.progress = None	# Current progress dialog (or None)
        self.logname = None
        
        wx.Frame.__init__(self,parent,id,title)

        if platform=='win32':
            self.SetIcon(wx.Icon(executable, wx.BITMAP_TYPE_ICO))
        elif platform.lower().startswith('linux'):	# PNG supported by GTK
            icons=wx.IconBundle()
            icons.AddIconFromFile('Resources/%s.png' % appname, wx.BITMAP_TYPE_PNG)
            icons.AddIconFromFile('Resources/%s-128.png'% appname, wx.BITMAP_TYPE_PNG)
            self.SetIcons(icons)
        elif platform=='darwin':
            # icon pulled from Resources via Info.plist (except for MessageBox icon). Need minimal menu
            menubar = wx.MenuBar()
            helpmenu = wx.Menu()
            helpmenu.Append(wx.ID_HELP, '%s Help\tCtrl-?'  % appname)
            wx.EVT_MENU(self, wx.ID_HELP, self.onHelp)
            helpmenu.Append(wx.ID_ABOUT, 'About %s'  % appname)
            wx.EVT_MENU(self, wx.ID_ABOUT, self.onAbout)
            # ID_EXIT moved to application menu
            helpmenu.Append(wx.ID_EXIT, u'Quit %s\tCtrl-Q' % appname)
            wx.EVT_MENU(self, wx.ID_EXIT, self.onClose)
            menubar.Append(helpmenu, '&Help')
            self.SetMenuBar(menubar)

        panel0 = wx.Panel(self,-1)
        panel1 = wx.Panel(panel0,-1)
        panel2 = wx.Panel(panel0,-1)
        panel3 = wx.Panel(panel0,-1)

        # 1st panel
        self.fspath=wx.TextCtrl(panel1, -1, fspath)
        self.fsbrowse=wx.Button(panel1, FSBROWSE, browse)
        self.lbpath=wx.TextCtrl(panel1, -1, lbpath)
        self.lbbrowse=wx.Button(panel1, LBBROWSE, browse)
        self.xppath=wx.TextCtrl(panel1, -1, xppath)
        self.xpbrowse=wx.Button(panel1, XPBROWSE, browse)
        grid1 = wx.FlexGridSizer(3, 3, 7, 7)
        grid1.AddGrowableCol(1,proportion=1)
        grid1.SetFlexibleDirection(wx.HORIZONTAL)
        grid1.Add(wx.StaticText(panel1, -1, "MSFS scenery location: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.fspath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.fsbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        grid1.Add(wx.StaticText(panel1, -1, "Additional MSFS libraries: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.lbpath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.lbbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        grid1.Add(wx.StaticText(panel1, -1, "X-Plane scenery location: "), 0,
                  wx.ALIGN_CENTER_VERTICAL)
        grid1.Add(self.xppath,     1,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL|wx.EXPAND, pad)
        grid1.Add(self.xpbrowse,   0,
                  wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
        panel1.SetSizer(grid1)

        wx.EVT_BUTTON(self, FSBROWSE, self.onFSbrowse)
        wx.EVT_BUTTON(self, LBBROWSE, self.onLBbrowse)
        wx.EVT_BUTTON(self, XPBROWSE, self.onXPbrowse)

        # 2nd panel
        self.xpver  = wx.RadioBox(panel2,-1, "Minimum X-Plane version:",
                                  choices=["v8", "v9", "v10"])
        self.xpver.SetSelection(2)	# v10 default
        self.season = wx.RadioBox(panel2,-1, "Season:",
                                  choices=["Spring", "Summer",
                                           "Autumn", "Winter"])
        self.dumplib= wx.CheckBox(panel2,-1, "Just extract library objects")
        # use panel and sizer so tab order works normally
        box2 = wx.BoxSizer(wx.HORIZONTAL)
        box2.Add(self.xpver, 0)
        box2.Add(self.season, 0, wx.LEFT, 10)
        box2.Add([0,0], 1, wx.LEFT, 10)	# push following buttons to right
        box2.Add(self.dumplib, 0, wx.TOP|wx.EXPAND, 8)
        panel2.SetSizer(box2)

        wx.EVT_CHECKBOX(self, self.dumplib.GetId(), self.onDump)

        
        # 3rd panel - adjust order of buttons per Windows or Mac conventions
        if platform=='darwin':
            button31=wx.Button(panel3, wx.ID_EXIT)
            button32=wx.Button(panel3, wx.ID_APPLY, "Convert")
            button33=wx.Button(panel3, wx.ID_HELP)
            box3 = wx.BoxSizer(wx.HORIZONTAL)
            box3.Add([24,0], 0)	# cosmetic - balance button31
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button31, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([6,0], 0)	# cosmetic
            box3.Add(button32, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button33, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            button32.SetDefault()
        else:
            button31=wx.Button(panel3, wx.ID_HELP)
            if platform=='win32':
                button32=wx.Button(panel3, wx.ID_EXIT)
            else:
                button32=wx.Button(panel3, wx.ID_CLOSE)
            button33=wx.Button(panel3, wx.ID_APPLY, "Convert")
            box3 = wx.BoxSizer(wx.HORIZONTAL)
            box3.Add(button31, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([0,0], 1)	# push following buttons to right
            box3.Add(button32, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            box3.Add([6,0], 0)	# cosmetic
            box3.Add(button33, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, pad)
            button33.SetDefault()
        panel3.SetSizer(box3)
        
        wx.EVT_BUTTON(self, wx.ID_HELP, self.onHelp)
        wx.EVT_BUTTON(self, wx.ID_APPLY, self.onConvert)
        wx.EVT_BUTTON(self, wx.ID_CLOSE, self.onClose)
        wx.EVT_BUTTON(self, wx.ID_EXIT, self.onClose)


        # Top level
        box0 = wx.BoxSizer(wx.VERTICAL)
        box0.Add(panel1, 0, wx.ALL|wx.EXPAND, 7)
        box0.Add(panel2, 0, wx.ALL|wx.EXPAND, 7)
        box0.Add(panel3, 0, wx.ALL|wx.EXPAND, 7)
        panel0.SetSizer(box0)

        border = wx.BoxSizer()
        border.Add(panel0, 1, wx.EXPAND)
        self.SetSizer(border)

        # Go
        sz=self.GetBestSize()
        if wx.VERSION<(2,6):
            # Hack - Can't get min size to work properly in 2.5
            height=sz.height+42
        else:
            height=sz.height            
        self.SetSize((800, height))
        # +50 is a hack cos I can't work out how to change minsize of TextCtrl
        self.SetSizeHints(sz.width, height, -1, height)
        self.Show(True)

        if platform=='darwin':
            # Change name on application menu. Can't do this in wx.
            try:	# Carbon
                from Carbon import Menu
                Menu.GetMenuHandle(1).SetMenuTitleWithCFString(appname)		# wxMac always uses id 1.
            except:
                try:	# Cocoa
                    import AppKit
                    # doesn't work: AppKit.NSApp.mainMenu().itemAtIndex_(0).submenu().setTitle_(appname)	 http://www.mail-archive.com/[email protected]/msg43196.html
                    AppKit.NSBundle.mainBundle().infoDictionary()['CFBundleName']=appname
                except:
                    if __debug__: print_exc()

        if newfsroot: myMessageBox('Install MSFS sceneries under: \n%s ' % newfsroot, 'Created a fake MSFS installation.', wx.ICON_INFORMATION|wx.OK, self)


    def onDump(self, evt):
        if self.dumplib.GetValue():
            self.fspath.Disable()
            self.fsbrowse.Disable()
        else:
            self.fspath.Enable()
            self.fsbrowse.Enable()

    def onFSbrowse(self, evt):
        style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER
        if 'DD_DIR_MUST_EXIST' in dir(wx): style|=wx.DD_DIR_MUST_EXIST
        dlg=wx.DirDialog(self, "Location of MSFS scenery package:",
                         self.fspath.GetValue(), style)
        dlg.ShowModal()
        self.fspath.SetValue(dlg.GetPath())
        dlg.Destroy()

    def onLBbrowse(self, evt):
        style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER
        if 'DD_DIR_MUST_EXIST' in dir(wx): style|=wx.DD_DIR_MUST_EXIST
        dlg=wx.DirDialog(self,"Location of additional MSFS scenery libraries:",
                         self.lbpath.GetValue(), style)
        dlg.ShowModal()
        self.lbpath.SetValue(dlg.GetPath())
        dlg.Destroy()

    def onXPbrowse(self, evt):
        dlg=wx.DirDialog(self, "Location for new X-Plane scenery package:",
                         self.xppath.GetValue(), wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
        dlg.ShowModal()
        self.xppath.SetValue(dlg.GetPath())
        dlg.Destroy()

    def onClose(self, evt):
        self.Close()

    def onHelp(self, evt):
        viewer(join(curdir,'Resources',appname+'.html'))

    def onAbout(self, evt):
        AboutBox(self)

    def onConvert(self, evt):
        dumplib=self.dumplib.GetValue()
        fspath=self.fspath.GetValue().strip()
        lbpath=self.lbpath.GetValue().strip()
        xppath=self.xppath.GetValue().strip()
        if not xppath:
            myMessageBox('You must specify an X-Plane scenery location',
                         "Can't convert.", wx.ICON_ERROR|wx.OK, self)
            return
        xppath=abspath(xppath)

        if not dumplib:
            if not fspath:
                myMessageBox('You must specify a MSFS scenery location',
                             "Can't convert.", wx.ICON_ERROR|wx.OK, self)
                return
            fspath=abspath(fspath)
            if not lbpath:
                lbpath=None
            else:
                lbpath=abspath(lbpath)
            if basename(xppath).lower()=='custom scenery':
                xppath=join(xppath, asciify(basename(fspath)))
        else:
            fspath=None
            if not lbpath:
                myMessageBox('You must specify a MSFS library location',
                             "Can't convert.", wx.ICON_ERROR|wx.OK, self)
                return
            lbpath=abspath(lbpath)
            if basename(xppath).lower()=='custom scenery':
                xppath=join(xppath, asciify(basename(lbpath)))
            
        season=self.season.GetSelection()	# zero-based
        xpver=self.xpver.GetSelection()+8	# zero-based

        try:
            self.logname=abspath(join(xppath, 'summary.txt'))
            if not isdir(dirname(self.logname)):
                mkdir(dirname(self.logname))
            logfile=file(self.logname, 'wt')
            logfile.write("%sTarget:\tX-Plane %d\n\n" % (sysdesc,xpver))
            logfile.close()
        except IOError, e:
            myMessageBox('Can\'t write to folder\n"%s"' % xppath,
                         e.strerror, wx.ICON_ERROR|wx.OK, self)
            return
        except WindowsError, e:
            myMessageBox('Can\'t write to folder\n"%s"' % xppath,
                         e.strerror, wx.ICON_ERROR|wx.OK, self)
            return
Exemplo n.º 6
0
        try:
            output=Output(fspath, lbpath, xppath, dumplib, season, xpver,
                          status,log,refresh, False)
            output.scanlibs()
            output.process()
            output.proclibs()
            output.procphotos()
            output.export()
            if self.progress:
                self.progress.Destroy()
                self.progress=None
            if output.debug: output.debug.close()
            if exists(self.logname):
                viewer(self.logname)
                myMessageBox('Displaying summary\n"%s"' %(
                    self.logname), 'Done.', wx.ICON_INFORMATION|wx.OK, self)
            else:
                myMessageBox('', 'Done.', wx.ICON_INFORMATION|wx.OK, self)

        except FS2XError, e:
            if exists(self.logname):
                logfile=file(self.logname, 'at')
                logfile.write('%s\n' % e.msg.encode("latin1",'replace'))
                logfile.close()
            myMessageBox(e.msg, 'Error during conversion.', wx.ICON_ERROR|wx.OK, self)

        except:
            logfile=file(self.logname, 'at')
            logfile.write('\nInternal error\n')
            print_exc(None, logfile)
            logfile.close()
Exemplo n.º 7
0

# import files
# returns list of files that need loading into the palette, or True if a full reload is required
def doimport(paths, palette):
    if not paths or not prefs.package: return False
    pkgpath = glob(join(prefs.xplane, gcustom, prefs.package))[0]
    try:
        files=importpaths(pkgpath, paths)
    except EnvironmentError, e:
        if __debug__: print_exc()
        myMessageBox(str(e.strerror), "Can't import %s" % e.filename, wx.ICON_ERROR|wx.OK, palette.frame)
        return False
    except UnicodeError, e:
        if __debug__: print_exc()
        myMessageBox('Filename uses non-ASCII characters.', "Can't import %s." % e.object, wx.ICON_ERROR|wx.OK, palette.frame)
        return False

    existing=[]
    for (src, dst) in files:
        if exists(dst): existing.append(dst[len(pkgpath)+1:])
    sortfolded(existing)
    if existing:
        if len(existing) > 1:
            r = myMessageBox('This scenery package already contains the following files:\n  ' + '\n  '.join(existing) + '\n\nDo you want to replace them?', 'Replace files', wx.ICON_QUESTION|wx.YES_NO|wx.CANCEL, palette.frame)
        else:
            r = myMessageBox('This scenery package already contains the following file:\n  ' + existing[0] + '\n\nDo you want to replace it?', 'Replace files', wx.ICON_QUESTION|wx.YES_NO, palette.frame)
        if r==wx.NO:
            # Strip out existing
            for (src, dst) in list(files):
                if exists(dst): files.remove((src,dst))
Exemplo n.º 8
0
# import files
# returns list of files that need loading into the palette, or True if a full reload is required
def doimport(paths, palette):
    if not paths or not prefs.package: return False
    pkgpath = glob(join(prefs.xplane, gcustom, prefs.package))[0]
    try:
        files = importpaths(pkgpath, paths)
    except EnvironmentError, e:
        if __debug__: print_exc()
        myMessageBox(str(e.strerror), "Can't import %s" % e.filename,
                     wx.ICON_ERROR | wx.OK, palette.frame)
        return False
    except UnicodeError, e:
        if __debug__: print_exc()
        myMessageBox('Filename uses non-ASCII characters.',
                     "Can't import %s." % e.object, wx.ICON_ERROR | wx.OK,
                     palette.frame)
        return False

    existing = []
    for (src, dst) in files:
        if exists(dst): existing.append(dst[len(pkgpath) + 1:])
    sortfolded(existing)
    if existing:
        if len(existing) > 1:
            r = myMessageBox(
                'This scenery package already contains the following files:\n  '
                + '\n  '.join(existing) + '\n\nDo you want to replace them?',
                'Replace files', wx.ICON_QUESTION | wx.YES_NO | wx.CANCEL,
                palette.frame)
        else: