| 1 | #!/usr/bin/env python |
| 2 | #--------------------------------------------------------------------------- |
| 3 | |
| 4 | import sys, os, glob |
| 5 | import wx |
| 6 | from wx.tools import helpviewer |
| 7 | |
| 8 | |
| 9 | # Figure out the path where this app is located |
| 10 | if __name__ == '__main__': |
| 11 | basePath = os.path.dirname(sys.argv[0]) |
| 12 | else: |
| 13 | basePath = os.path.dirname(__file__) |
| 14 | if not basePath: |
| 15 | basePath = '.' |
| 16 | |
| 17 | |
| 18 | # test for write access |
| 19 | if os.access(basePath, os.W_OK): |
| 20 | |
| 21 | # setup the args |
| 22 | args = ['', |
| 23 | '--cache='+basePath, |
| 24 | os.path.join(basePath, 'wx.zip'), |
| 25 | ] |
| 26 | |
| 27 | # add any other .zip files found |
| 28 | for file in glob.glob(os.path.join(basePath, "*.zip")): |
| 29 | if file not in args: |
| 30 | args.append(file) |
| 31 | |
| 32 | # launch helpviewer |
| 33 | helpviewer.main(args) |
| 34 | |
| 35 | else: |
| 36 | app = wx.PySimpleApp() |
| 37 | dlg = wx.MessageDialog(None, |
| 38 | "The wxDocs need to be located in a directory that is writable by you. " |
| 39 | "I am unable to start the viewer in its current location.", |
| 40 | "Error!", wx.OK|wx.ICON_EXCLAMATION) |
| 41 | dlg.ShowModal() |
| 42 | dlg.Destroy() |
| 43 | app.MainLoop() |
| 44 | |
| 45 | #--------------------------------------------------------------------------- |
| 46 | |