diff -rupN whyteboard-orig/dependency.py whyteboard-patch/dependency.py --- whyteboard-orig/dependency.py 1969-12-31 19:00:00.000000000 -0500 +++ whyteboard-patch/dependency.py 2010-11-21 14:14:05.999000000 -0500 @@ -0,0 +1,358 @@ +import sys +import os +import subprocess +import urllib +import zipfile +import webbrowser + +def ListValidation( text, validate ): + if text: + print text + + input_text = "[" + + for string in validate: + input_text += string + "/" + + input_text = input_text[:-1] + "]: " + + i = raw_input( input_text ) + + if i in validate: + return i + else: + print "Invalid response" + ListValidation( text, validate ) + +def YesNoValidation( text = "" ): + i = raw_input( text + " [Y/N]: " ) + i = i.lower() + if i[0] in ["y", "n"]: + return i[0] + else: + print "Invalid response" + YesNoValidation( text ) + + +def DistroCompatibilityCheck( input, alternate = False ): + input = input.lower() + + if "suse" in input: + ZypperInstall( input ) + + elif "ubuntu" or "debian" in input: + AptgetInstall( input ) + + elif "redhat" or "fedora" or "rhel" in input: + YumInstall( input ) + + elif "gentoo" in input: + EmergeInstall( input ) + + elif "mandriva" in input: #or "mandrake" in input: + UrpmiInstall( input ) + + elif "slackware" in input: + SlackpkgInstall( input ) + + elif "arch" in input: + PacmanInstall( input ) + + elif "freebsd" in input: + PkgAddInstall( input ) + + elif "foresight" in input: # or "rpath" in input: + ConaryInstall( input ) + + elif not alternate: + print "Could not find disto using lsb-release; is", input, "your distribution?" + cont = YesNoValidation() + if cont == "n": + print "You must not be lsb-release compliant; let's try to find your distribution using another method." + FindDistribution( True ) + else: + print "Please file a bug asking for automatic wxpython installation for", input + + else: + print "Could not find distribution using both cat /etc/*release* and lsb-release -a and/or distribution unsupported." + print "Do you want to attempt to install using Ubuntu/Debian packages? (Use only if you're using a Debian derivate other than Ubuntu)" + cont = YesNoValidation() + if cont == "y": + UbuntuInstall( input, True ) + else: + print "There is one more thing we could try: do you know the name of your distribution's package manager?" + print "Zypper, Apt-get, Yum, Emerge, and Yrpmi are currently supported (so pick one of those, if you know you have one of them)." + cont = ListValidation( "Enter the name of your package manager:", ["zypper", "apt", "yum", "emerge", "urpmi", "none"] ) + if "zypper" in cont: + ZypperInstall( "default" ) + elif "apt" in cont: + AptgetInstall( "default" ) + elif "yum" in cont: + YumInstall( "default" ) + elif "emerge" in cont: + EmergeInstall( "default" ) + elif "urpmi" in cont: + UrpmiInstall( "default" ) + else: + print "Giving up..." + +def FindDistribution( alternate = False ): + if not alternate: + try: + klsb = subprocess.call( ["lsb-release", "-a"], stdout = subprocess.PIPE, stdin = subprocess.PIPE ) + + output = lsb.communicate() + + DistroCompatibilityCheck( output ) + + except OSError: + print "lsb-release not found, let's try cat /etc/*release*" + + FindDistribution( True ) + else: + try: + cat = subprocess.call( ["cat", r"/etc/*release*"], stdout = subprocess.PIPE, stdin = subprocess.PIPE ) + output = cat.communicate() + except: + print "Failed to cat /etc/*release*" + print "We'll have to figure out what to do in this odd case; give up probably" + + if output: + DistroCompatibilityCheck( output, True ) + +def InstallWget( version ): + print "wget not found" + wgetpath = os.path.join( "..", "wget" ) + if not os.path.exists( wgetpath ): + os.mkdir( wgetpath ) + + os.chdir( os.path.join( "..", "wget" ) ) + print "Attempting to retrieve wget for windows using urllib" + urllib.urlretrieve( "http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-bin.zip" ) + urllib.urlretrieve( "http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-dep.zip" ) + zipfile.ZipFile( "wget-1.11.4-1-bin.zip" ).extractall() + zipfile.ZipFile( "wget-1.11.4-1-dep.zip" ).extractall() + + WindowsInstall( version ) + +def WindowsInstall( version ): + file = "http://downloads.sourceforge.net/wxpython/wxPython2.8-win32-unicode-2.8.11.0-py2" + version + ".exe" + + if not os.path.exists( os.path.join( "..", "wget", "wget.exe" ) ): + # Try to run wget globally + try: + subprocess.Popen( ["wget"] ) + except WindowsError: + # wget is not installed globally, so try download it + InstallWget( version ) + else: + os.chdir( os.path.join( "..", "wget" ) ) + + wget = subprocess.Popen( ["wget.exe", file], stdout = subprocess.PIPE, stdin = subprocess.PIPE ) + run = False + while run: + text = wget.communicate()[0] + if text != "": + print text + + if not wget.poll(): + run = False + + print "Download completed, now starting the downloaded installer." + subprocess.call( ["wxPython2.8-win32-unicode-2.8.11.0-py2" + version + ".exe", "/silent"] ) + +def SlackpkgInstall( input, internal = False ): + ##slackpkg install pkg + # + # http://sbopkg.googlecode.com/files/sbopkg-0.34.0-noarch-1_cng.tgz + if not internal: + print "WARNING: I have absolutely no clue from personal experience how Slackware works." + print "Chances are, if you're running Slackware, you probably know how to do this better than I can" + print "The idea, as far as I know, is to installpkg sbopkg and use sbopkg to get a slackbuild of wxpython" + print "If you know how to do this yourself, then please ABORT this script now! Yes, this is supposed to scare you." + print "" + print "This script is about to do the following:" + print "" + print "su -c sbopkg -b wxPython" + print "" + print "And, if neccessary," + print "" + print "su -c installpkg http://sbopkg.googlecode.com/files/sbopkg-0.34.0-noarch-1_cng.tgz" + print "" + print "If you know this is wrong, you definitely should ABORT now." + print "If, however, this is indeed correct, or, if you would like to help correct this, please," + print "do provide your input on https://bugs.launchpad.net/whyteboard/+bug/674319 if you wouldn't mind." + print "" + + if "11.3" not in input: + print 'WARNING: "11.3" was not found in whatever lsb-release and/or cat /etc/*release* returned.' + print "Slackbuilds.org's packages are designed for the head version of slackware." + print "If you know for a fact that you, indeed, aren't running the latest release of slackware, please ABORT." + + cont = YesNoValidation( "Last Chance: Are you ABSOLUTELY sure you want to try to automate this?" ) + + if cont == "y": + try: + print "Attempting to use sbopkg to install the slackbuild of wxPython" + subprocess.call( "su", "-c", "sbopkg", "-b", "wxPython" ) + except OSError: + # Install sbopkg + print "sbopkg not found; installing" + subprocess.call( ["su", "-c", "installpkg", "http://sbopkg.googlecode.com/files/sbopkg-0.34.0-noarch-1_cng.tgz"] ) + SlackpgInstall( input, True ) + +def PacmanInstall( input ): + #pacman -S pkg + print "Arch is not supported at this time" + +def PkgAddInstall( input ): + #pkg_add -r package + print "FreeBSD is not supported at this time" + +def ConaryInstall( input ): + #conary update pkg + print "While Conary/Foresight does look pretty OG, support is not included at this time." + +def UrpmiInstall( input ): + # No idea how this actually is supposed to work; somewhat of a wild guess in the dark + # (but also backed up by the docs on the wiki ;) ) + # This should work for mandriva "rawhide" + subprocess.call( "sudo", "urpmi.addmedia", "--distrib", "--mirrorlist" ) + subprocess.call( "sudo", "urpmi", "wxPython" ) + +def EmergeInstall( input ): + # Looks like gentoo only has 2.8.10.1, for which version (does gentoo have versions?), I don't know + subprocess.call( "su", "-c", "emerge", "wxPython" ) + +def YumInstall( input ): + # Fedora Core 8 through Fedora 14/Trunk and RHEL 5-6+ have 2.8.9.0+ packages built + + supported_versions = range( 8, 15 ) + for index, obj in enumerate( supported_versions ): + supported_versions[index] = str( obj ) + supported_versions.append( "rhel" ) + + # BUG: does not check rhel version (searching would be slightly more complicated + # than I'm willing to implement at this time, since I don't know what exactly + # lsb-release returns on rhel + # BUG: Probably does not allow trunk releases to install, even though packages + # do exist for them. + + version_ok = False + + try: + version_ok = next( s for s in supported_versions if s in input ) + except StopIteration: + print "Your version of Fedora/Core is not supported" + + if version_ok: + subprocess.call( ["su", "-c", "yum", "install", "wxPython"] ) + # Easy enough? + +def AptgetInstall( input, forced = False ): + supported_versions = ["feisty", + "gusty", + "hardy", + "intrepid", + "jaunty", + "karmic", + "lucid", + "etch", + "lenny"] + + if not forced: + version = next( s for s in supported_versions if s in input ) + else: + distrolist = "" + for v in supported_distros: + distrolist += v + " " + print "Wxpython provides whyteboard compatible packages for the following versions of Debian/Ubuntu:" + distrolist + print "Try to guess which one best matches your distro (whichever your fork is derived from)." + print "Hopefully, it will be compatible." + version = ListValidation( None, supported_distros ) + + if not version: + print "Your version of Ubuntu or Debian is not supported." + print "This installer script (and wxpython in general) supports the following only:" + distrolist = "" + for v in supported_distros: + distrolist += v + " " + print distrolist + + executionlist = [ + ["curl", "http://apt.wxwidgets.org/key.asc", "|", "sudo", "apt-key", "add", "-"], + ["sudo", "cat", "\ndeb http://apt.wxwidgets.org/ " + version + "-wx main\n", r"/etc/apt/sources.list"], + ["sudo", "apt-get", "update"], + ["sudo", "apt-get", "install", "python-wxgtk2.8 python-wxtools wx2.8-i18n"]] + + for a in executionlist: + subprocess.call( a ) + +def ZypperInstall( input ): + supported_versions = ["11.1", "11.2", "11.3"] # Just for now; we can probably tack on the 10 series and most definitely 11.0 at least + + version = None + + try: + version = next( s for s in supported_versions if s in input ) + except StopIteration: + if input == "default": + print "It appears you were brought here by opting to try using zypper, whereas openSUSE/SUSE was not detected in your lsb_release" + print "I doubt there are any good SUSE derviatives, but if your sure, and it was derived from either 11.1, 11.2, or 11.3, please enter that now." + + version = ListValidation( None, supported_versions ) + + if version: + executionlist = [ + ["sudo", "zypper", "ar", "http://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_" + version, "wxpython"], + ["sudo", "zypper", "in", "python-wxGTK"]] + + for a in executionlist: + subprocess.call( a ) + +def MacInstall( version ): + # I can probably gaurantee you that this isn't going to work... lets try something a bit different + """ + urllib.urlretrieve("http://downloads.sourceforge.net/wxpython/wxPython2.8-osx-unicode-2.8.11.0-universal-py2." + version + ".dmg") + subprocess.Popen(["wxPython2.8-osx-unicode-2.8.11.0-universal-py2." + version + ".dmg"]) + """ + #Have the user install it themselves... + webbrowser.open( "http://downloads.sourceforge.net/wxpython/wxPython2.8-osx-unicode-2.8.11.0-universal-py2." + version + ".dmg" ) + +def DetectPlatform(): + if sys.platform == "win32": + v = sys.version[0:3] + if v[0] == "3": + print "wxpython does not yet support Python 3; therefore, neither does whyteboard." + print "Please upgrade to Python 2.6" + elif v[0] == "2" and 5 <= int( v[2] ) <= 7: + WindowsInstall( v[2] ) + + elif "linux" in sys.platform: + # Oh, shit, we've got to figure out what distribution we're running + FindDistribution() + + elif sys.platform == "darwin": + v = sys.version[0:3] + if v[0] == "3": + print "wxpython does not yet support Python 3; therefore, neither does whyteboard." + print "Please upgrade to Python 2.6" + elif v[0] == "2" and 5 <= int( v[2] ) <= 7: + MacInstall( v[2] ) + + else: + print "Sorry", sys.platform, "is not supported by this installer; you probably need to build from source anyway" + +def main(): + print "wxPython was not detected in this installation of Python" + print "Would you like to attempt to automagically download and install it?" + print "[Script HIGHLY untested; perhaps you can help? ;)]" + print "If you encouter problems in Windows, please try running as an administrator." + print "In Linux, the script will attempt to elevate permissions where neccessary." + print "And finally, make sure you have internet access before you begin this process." + cont = YesNoValidation() + if cont[0] == "y": + DetectPlatform() + +if __name__ == "__main__": + main() Files whyteboard-orig/dependency.pyc and whyteboard-patch/dependency.pyc differ diff -rupN whyteboard-orig/whyteboard.py whyteboard-patch/whyteboard.py --- whyteboard-orig/whyteboard.py 2010-11-11 23:09:47.127000000 -0500 +++ whyteboard-patch/whyteboard.py 2010-11-11 23:23:01.580000000 -0500 @@ -27,23 +27,28 @@ import sys import webbrowser import locale -locale.setlocale(locale.LC_ALL) +import dependency -if not hasattr(sys, 'frozen'): +locale.setlocale( locale.LC_ALL ) + +if not hasattr( sys, 'frozen' ): WXVER = '2.8.9' - import wxversion - if not wxversion.checkInstalled(WXVER): + try: + import wxversion + except: + dependency.main() + if not wxversion.checkInstalled( WXVER ): import wx - app = wx.App(False) + app = wx.App( False ) - wx.MessageBox(u"The minimum required version of wxPython, \n%s is not installed." % WXVER, - u"wxPython Version Error") + wx.MessageBox( u"The minimum required version of wxPython, \n%s is not installed." % WXVER, + u"wxPython Version Error" ) app.MainLoop() - webbrowser.open(u"http://www.wxpython.org/download.php") - sys.exit() - + if not dependency.main(): + webbrowser.open( "http://wxPython.org/download.php" ) + sys.exit() import wx from whyteboard import WhyteboardApp -WhyteboardApp().MainLoop() \ No newline at end of file +WhyteboardApp().MainLoop() Files whyteboard-orig/whyteboard.pyc and whyteboard-patch/whyteboard.pyc differ