Support-1.5.7~rc1+cvs.20140424/0000755000175000017500000000000012326221030015341 5ustar moellermoellerSupport-1.5.7~rc1+cvs.20140424/MANIFEST.in0000644000175000017500000000053211033243432017103 0ustar moellermoeller# This list all other files to be included in the distribution # which are not python modules # include, exclude.... which are not described in the setup.py. include MANIFEST.in # list of the non python module to be included in the distribution # include all the CVS directories include Support/CVS/* include version.py include Support/LICENSE Support-1.5.7~rc1+cvs.20140424/setup.py0000644000175000017500000000636510533100076017071 0ustar moellermoeller#!/usr/bin/env python from distutils.core import setup from distutils.command.sdist import sdist from distutils.command.install_data import install_data from glob import glob import os ######################################################################## # Had to overwrite the prunrefile_list method of sdist to not # remove automatically the RCS/CVS directory from the distribution. ######################################################################## class modified_sdist(sdist): def prune_file_list(self): """ Prune off branches that might slip into the file list as created by 'read_template()', but really don't belong there: * the build tree (typically 'build') * the release tree itself (only an issue if we ran 'sdist previously with --keep-temp, or it aborted) """ build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) class modified_install_data(install_data): def run(self): install_cmd = self.get_finalized_command('install') self.install_dir = getattr(install_cmd, 'install_lib') return install_data.run(self) ######################################################################## # list of the python packages to be included in this distribution. # sdist doesn't go recursively into subpackages so they need to be # explicitaly listed. # From these packages only the python modules will be taken packages = ['Support'] # list of the python modules not part of a package. Give the path and the # filename without the extension. i.e you want to add the # test.py module which is located in MyPack/Tests/ you give # 'MyPack/Tests/test' py_modules = [] # list of the files that are not python packages but are included in the # distribution and need to be installed at the proper place by distutils. # The list in MANIFEST.in lists is needed for including those files in # the distribution, data_files in setup.py is needed to install them # at the right place. data_files = [] def getDataFiles(file_list, directory, names): fs = [] for name in names: ext = os.path.splitext(name)[1] #print directory, name, ext, len(ext) if ext !=".py" and ext !=".pyc": fullname = os.path.join(directory,name) if not os.path.isdir(fullname): fs.append(fullname) if len(fs): file_list.append((directory, fs)) os.path.walk("Support", getDataFiles, data_files) # description of what is going to be included in the distribution and # installed. from version import VERSION setup (name = 'Support', version = VERSION, description = "A package providing code for update mechanism of MGLTools", author = 'Molecular Graphics Laboratory', author_email = 'mgltools@scripps.edu', download_url = 'http://mgltools.scripps.edu/downloads', url = 'http://mgltools.scripps.edu/downloads', packages = packages, py_modules = py_modules, data_files = data_files, cmdclass = {'sdist': modified_sdist, 'install_data': modified_install_data }, ) Support-1.5.7~rc1+cvs.20140424/version.py0000644000175000017500000000002011475262444017412 0ustar moellermoellerVERSION="1.5.6" Support-1.5.7~rc1+cvs.20140424/Support/0000755000175000017500000000000012326221031017016 5ustar moellermoellerSupport-1.5.7~rc1+cvs.20140424/Support/LICENSE0000644000175000017500000000436411220770252020040 0ustar moellermoellerThis software is copyrighted by Michel F. Sanner (sanner@scripps.edu) and TSRI. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. MGLTOOLS SOFTWARE LICENSE AGREEMENT. 1. Grant Of Limited License; Software Use Restrictions. The programs received by you will be used only for NON COMMERCIAL purposes. This license is issued to you as an individual. For COMMERCIAL use done with the software please contact Michel F. Sanner for details about commercial usage license agreements. For any question regarding license agreements, please contact Michel Sanner: TSRI, Molecular Biology Department, TCP 26, 10550 North Torrey Pines Road, La Jolla, CA 92037 sanner@scripps.edu tel (858) 784-7742 fax (858) 784-2341 2. COMMERCIAL USAGE is defined as revenues generating activities. These include using this software for consulting activities and selling applications built on top of, or using this software. Scientific research in an academic environment and teaching are considered NON COMMERCIAL. 3. Copying Restrictions. You will not sell or otherwise distribute commercially these programs or derivatives to any other party, whether with or without consideration. 4. Ownership of Software. You will not obtain, and will not attempt to obtain copyright coverage thereon without the express purpose written consent of The Scripps Research Institute and Dr. Sanner. 5. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. Support-1.5.7~rc1+cvs.20140424/Support/__init__.py0000644000175000017500000000040410532703432021134 0ustar moellermoeller# This package provides support for setting up and updating MGLTools. # Author: Sargis Dallakyan (sargis at scripps.edu) $ # $Header: /opt/cvs/Support/__init__.py,v 1.1 2006/11/28 00:47:22 sargis Exp $ # $Id: __init__.py,v 1.1 2006/11/28 00:47:22 sargis Exp $ Support-1.5.7~rc1+cvs.20140424/Support/mktestsummary.py0000644000175000017500000002055112053011662022324 0ustar moellermoellerimport os, sys import time import stat import string mglpacks=[ "DejaVu", "MolKit", "ViewerFramework", "Pmv", "AutoDockTools", "PyBabel", "symserv", "mglutil", "NetworkEditor", "Volume", "Vision","PyAutoDock", "Support", "Scenario2"] def getTestsDirs(file_list, directory, names): if os.path.basename(directory) == "Tests": file_list.append(os.path.dirname(directory)) def getTestSummaryResults(testroot, testreportdir): """Parse the test report files created by tester. testroot - directory containing the MGLTools packages ; testreportdir - directory containing testreports """ #print "testreportdir:", testreportdir assert os.path.exists(testreportdir) assert os.path.exists(testroot) # list of directories containing Tests ( created when the tests ran last for this platform) cwd = os.getcwd() testdirs = [] os.chdir(testroot) for p in mglpacks : os.path.walk(p, getTestsDirs, testdirs) #print "testdirs" ,testdirs os.chdir(cwd) reports = [] for p in testdirs: reports.append(p.replace(os.sep,'.')) # a dictionary containing the names of test reports rantests = {} # a dictionary containing the names of test reports (with -s option) rantestsS = {} # a list of test modules for which we did not get a report noreports= [] modules = [] # string containing time when the directory was last modified reporttime = time.asctime(time.localtime(os.stat(testreportdir)[stat.ST_MTIME])) # remove time (##:##:##) from reporttime string (leave only the date) rd = string.split(reporttime) rd.pop(-2) reportdate = "%s %s %s %s" % tuple(rd) import sys for r in reports: f1 = os.path.join(testroot, testreportdir, "report-" + r + sys.platform + ".txt") f2 = os.path.join(testroot, testreportdir, "sReport-"+ r + sys.platform + ".txt") if os.path.exists(f1): rantests[f1] = r elif os.path.exists(f2): rantestsS[f2] = r else: noreports.append(r) numtests = 0 numerrors = 0 results = {} for file in rantestsS.keys(): test = None ntests = 0 testerrors = 0 f= open(file, "r") st =f.readline() l = string.split(st) if len(l)== 5: if l[0] == "RAN": test = rantestsS[file] ntests = float(l[1]) numtests = numtests + ntests modules.append(test) results[test]={} results[test]['ntests']= ntests txt = f.readlines() f.close() testname = None errlist = [] errtxt = "" for line in txt: if string.find(line, "Tests.test_")> 0: if string.find(line, "ERROR:")== 0 or string.find(line, "FAIL:")==0: errlist.append(line) continue testname = line if len(errlist) >0: errtxt = errtxt + "\n" + testname for err in errlist: errtxt = errtxt + err testerrors = testerrors +len(errlist) errlist = [] continue elif string.find(line, "ERROR:")== 0 or string.find(line, "FAIL:")==0: errlist.append(line) elif line.startswith("RAN "): if test == None: test = rantestsS[file] modules.append(test) results[test]={} #print test, file, ntests, numtests, nt = float(line.split()[1]) ntests = ntests+nt numtests = numtests + nt #print ntests, numtests results[test]['ntests']= ntests #this is for the case when error is in the last test: if len(errlist) >0: errtxt = errtxt + "\n" + testname for err in errlist: errtxt = errtxt + err testerrors = testerrors +len(errlist) errlist = [] if testerrors: numerrors = numerrors + testerrors results[test]['failed'] = testerrors results[test]['errtxt'] = errtxt for file in rantests.keys(): testerrors = 0 f= open(file, "r") st =f.readline() l = string.split(st) if len(l)== 5: if l[0] == "RAN": test = rantests[file] modules.append(test) ntests = float(l[1]) numtests = numtests + ntests results[test]={} results[test]['ntests']= ntests txt = f.readlines() f.close() testname = None errlist = [] errtxt = "" for line in txt: if string.find(line, "FAILED (")==0: if len(errlist) >0: for err in errlist: errtxt = errtxt + err testerrors = testerrors +len(errlist) errlist = [] continue elif string.find(line, "ERROR:")== 0 or string.find(line, "FAIL:")==0: errlist.append(line) if testerrors: numerrors = numerrors + testerrors results[test]['failed'] = testerrors results[test]['errtxt'] = errtxt perc = numerrors/numtests*100.0 if len(noreports): endstr = "No test report for the following module(s) (tests possibly crashed): \n" for f in noreports: endstr = endstr+ "%s \n" % f results['tail']= endstr results['reportdate'] = reportdate results['numtests'] = numtests results['numerrors'] = numerrors results['perc'] = perc return results, modules def mkSummaryHTML(testroot, testreportdir, filename = None): """ create a simple html file with the tests summary""" results, modules = getTestSummaryResults(testroot, testreportdir) if not filename: if sys.platform == "darwin": if os.uname()[-1] == 'Power Macintosh': prt = "powerpc" else: prt = "i386" filename = "testsummary"+sys.platform+ prt+".html" else: filename = "testsummary"+sys.platform+".html" resfile = open(filename, "w") txt = """ Summary of Tests Results ran on %s.
""" % results['reportdate'] resfile.write(txt) for mod in modules: ntests = results[mod]['ntests'] if ntests == 0: continue #resfile.write("%s
\n" % mod) resfile.write("%s     \n" % mod+" ") if results[mod].has_key("failed"): nfailed = results[mod]["failed"] #txt = "
\nRan %d tests: number of failed tests %d \nThe following tests failed: \n" % (ntests, nfailed)
            txt = "Ran %d tests; %d test(s) failed:\n" % (ntests, nfailed)
            resfile.write(txt)
            resfile.write("
")
            resfile.write(results[mod]['errtxt']+ "
\n" ) #resfile.write("
\n-----------------------------------------------------------
\n") else: resfile.write("Ran %d tests: OK
\n" % ntests) #resfile.write("-----------------------------------------------------------
\n") resfile.write("===========================================================
\n") resfile.write("Overall Results(%s): ran %d tests, failed %d (%.2f %s)
\n" % (results['reportdate'], results['numtests'], results['numerrors'], results['perc'], "%") ) if results.has_key('tail'): resfile.write("
\n%s
" % results['tail']) resfile.close() if __name__ == "__main__": args = sys.argv[1:] #print "args" ,args if len(args) == 2: mkSummaryHTML(args[0], args[1]) elif len(args) == 3: mkSummaryHTML(args[0], args[1], args[2]) else: print "mkreport requires 2 or 3 arguments" Support-1.5.7~rc1+cvs.20140424/Support/path.py0000644000175000017500000000251110720666270020341 0ustar moellermoeller# This modules sets MGLTools path # Author: Sargis Dallakyan (sargis at scripps.edu) # $Header: /opt/cvs/Support/path.py,v 1.16 2007/11/20 23:24:40 sargis Exp $ # $Id: path.py,v 1.16 2007/11/20 23:24:40 sargis Exp $ import os, sys from user import home from Support.version import __version__ rc = home + os.sep + ".mgltools" + os.sep + __version__ if rc: updates_rc_dir = rc + os.sep + 'update' else: updates_rc_dir = 'update' tested_rc = updates_rc_dir + os.sep + 'tested' nightly_rc = updates_rc_dir + os.sep + 'nightly' #may or may not be tested release_path = '' path_text = '' def setSysPath(path): """Sets sys.path for MGLTools""" global release_path, path_text sys.path.insert(1,path + os.sep + 'PIL') release_path = path if os.path.exists(tested_rc): p = open(tested_rc).read().split('\t') if os.path.exists(p[0]): if os.listdir(p[0]): sys.path.insert(0, p[0]) path_text = ' Tested '+ p[1]+ ' : ' + p[0] +'\n' + path_text else: os.remove(tested_rc) if os.path.exists(nightly_rc): p = open(nightly_rc).read().split('\t') if os.path.exists(p[0]): if os.listdir(p[0]): sys.path.insert(0, p[0]) path_text = ' Nightly '+ p[1]+ ' : ' + p[0] +'\n' + path_text Support-1.5.7~rc1+cvs.20140424/Support/sitecustomize.py0000644000175000017500000000046011652062330022305 0ustar moellermoeller# specify mglroot here import sys, os path = os.path.join(mglroot, "MGLToolsPckgs") sys.path.append(path) from os import getenv if getenv('MGLPYTHONPATH'): sys.path.insert(0, getenv('MGLPYTHONPATH')) from Support.path import setSysPath setSysPath(path) #sys.path.insert(0,os.path.abspath('.')) Support-1.5.7~rc1+cvs.20140424/Support/unzip.py0000644000175000017500000001163111216031312020535 0ustar moellermoeller#http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252508 """ unzip.py Version: 1.1 Extract a zipfile to the directoryectory provided It first creates the directory structure to house the files then it extracts the files to it. Sample usage: command line unzip.py -p 10 -z c:\testfile.zip -o c:\testoutput python class import unzip un = unzip.unzip() un.extract(r'c:\testfile.zip', 'c:\testoutput') By Doug Tolton """ import sys import zipfile import os import os.path import getopt class unzip: def __init__(self, verbose = False, percent = 10): self.verbose = verbose self.percent = percent def extract(self, file, directory): if not directory.endswith(':') and not os.path.exists(directory): os.mkdir(directory) zf = zipfile.ZipFile(file) # create directoryectory structure to house files self._createstructure(file, directory) num_files = len(zf.namelist()) percent = self.percent divisions = 100 / percent perc = int(num_files / divisions) # extract files to directoryectory structure for i, name in enumerate(zf.namelist()): if self.verbose == True: print "Extracting %s" % name elif perc > 0 and (i % perc) == 0 and i > 0: complete = int (i / perc) * percent print "%s%% complete" % complete if not name.endswith('/'): if os.name == 'nt': #sys.platform =='win32': name1 = name.replace("/","\\") else: name1 = name outfile = open(os.path.join(directory, name1), 'wb') outfile.write(zf.read(name)) outfile.flush() outfile.close() def _createstructure(self, file, directory): self._makedirs(self._listdirs(file), directory) def _makedirs(self, directories, basedirectory): """ Create any directoryectories that don't currently exist """ for directory in directories: if os.name == 'nt': #sys.platform=='win32': dirlist = directory.split('\\') else: dirlist = directory.split('/') curdirectory = basedirectory for direct in dirlist: newdir = os.path.join(curdirectory, direct) if not os.path.exists(newdir): try: os.mkdir(newdir) except OSError: head, tail = os.path.split(newdir) os.mkdir(head) os.mkdir(newdir) curdirectory = newdir def _listdirs(self, file): """ Grabs all the directoryectories in the zip structure This is necessary to create the structure before trying to extract the file to it. """ zf = zipfile.ZipFile(file) directories = {} for name in zf.namelist(): direct, filename = os.path.split(name) if os.name == 'nt': #sys.platform=='win32': direct = direct.replace('/', '\\') try: a = directories[direct] except KeyError: directories[direct] = 1 #if sys.platform == 'win32': # if name.endswith('\\'): # directorys.append(name) #elif name.endswith('/'): # directorys.append(name) directories = directories.keys() directories.sort() return directories def usage(): print """usage: unzip.py -z -o is the source zipfile to extract is the target destination -z zipfile to extract -o target location -p sets the percentage notification -v sets the extraction to verbose (overrides -p) long options also work: --verbose --percent=10 --zipfile= --outdirectory=""" def main(): shortargs = 'vhp:z:o:' longargs = ['verbose', 'help', 'percent=', 'zipfile=', 'outdir='] unzipper = unzip() try: opts, args = getopt.getopt(sys.argv[1:], shortargs, longargs) except getopt.GetoptError: usage() sys.exit(2) zipsource = "" zipdest = "" for o, a in opts: if o in ("-v", "--verbose"): unzipper.verbose = True if o in ("-p", "--percent"): if not unzipper.verbose == True: unzipper.percent = int(a) if o in ("-z", "--zipfile"): zipsource = a if o in ("-o", "--outdir"): zipdest = a if o in ("-h", "--help"): usage() sys.exit() if zipsource == "" or zipdest == "": usage() sys.exit() unzipper.extract(zipsource, zipdest) if __name__ == '__main__': main() Support-1.5.7~rc1+cvs.20140424/Support/update.py0000644000175000017500000007366111345237604020704 0ustar moellermoeller# This modules handels updates for MGLTools # Author: Sargis Dallakyan (sargis at scripps.edu) # $Header: /opt/cvs/Support/update.py,v 1.37 2010/03/08 18:18:44 sargis Exp $ # $Id: update.py,v 1.37 2010/03/08 18:18:44 sargis Exp $ import os, sys, platform, urllib, tarfile, unzip, Tkinter, Pmw from tkFileDialog import * from tkMessageBox import * import pickle, httplib, urllib import webbrowser base_url = 'http://mgltools.scripps.edu/downloads/tars/releases/nightly' import mglutil from mglutil.util.misc import ensureFontCase #Paltform Independent Packages share_packages = ['AutoDockTools', 'mglutil', 'NetworkEditor', 'PyAutoDock', 'symserv', 'Vision', 'DejaVu', 'MolKit', 'Pmv', 'PyBabel', 'ViewerFramework', 'Volume'] #Paltform Dependent Packages packages = ['bhtree', 'cMolKit', 'gle', 'opengltk', 'QSlimLib', 'stride', 'binaries', 'geomutils', 'mslib', 'pyglf', 'sff', 'UTpackages'] def rm_dirs(path): """source http://docs.python.org/lib/os-file-dir.html Delete everything reachable from the directory named in 'top', assuming there are no symbolic links. CAUTION: This is dangerous! For example, if top == '/', it could delete all your disk files.""" for root, dirs, files in os.walk(path, topdown=False): for name in files: try: os.remove(os.path.join(root, name)) except OSError: pass for name in dirs: try: os.rmdir(os.path.join(root, name)) except OSError: pass try: os.removedirs(path) # added to remove path itself except OSError: pass class Update: """ package : Support module : update class : Update description: Provides GUI and command line interface for updating MGLTools """ def __init__(self): if sys.platform == 'linux2': if sys.maxint> 2147483647: #os.popen('uname -m').read() == 'x86_64\n': self.sys_prefix = 'x86_64Linux2' else: self.sys_prefix = 'i86Linux2' self.update_file = self.sys_prefix+'.tar.gz' elif os.name == 'nt': #sys.platform == 'win32': self.sys_prefix = 'win32' self.update_file = self.sys_prefix+'.zip' elif sys.platform == 'darwin': uname = os.uname() if uname[2].startswith('8'): name = '8' else: name = '9' if uname[-1] == "i386": self.sys_prefix = "i86Darwin"+name else: self.sys_prefix = "ppcDarwin"+name self.update_file = self.sys_prefix+'.tar.gz' else: print "Sorry no nightly builds is available for your platform." print sys.platform from user import home from Support.version import __version__ self.rc = home + os.sep + ".mgltools" + os.sep + __version__ self.updates_rc_dir = self.rc + os.sep + 'update' if not os.path.isdir(self.updates_rc_dir): os.mkdir(self.updates_rc_dir) self.latest = 'tested' # or 'nightly' self.master = None self.updates_dir = None from Support.version import __version__ self.Version = __version__ self.baseURL = base_url +'/' + self.Version self.date_latest = None self.date_tested = None self.latestURL = None self.testedURL = None def setUpdatesDir(self): """Gets update directory path from '.mgltools/update/'+self.latest. If this file doesn't exists, updates_dir is set to one directory up from PIL packages directory""" if not self.updates_dir: latest_rc = self.updates_rc_dir + os.sep + 'tested' if os.path.exists(latest_rc): self.updates_dir = open(latest_rc).read() if self.updates_dir: self.updates_dir = self.updates_dir.split('\t')[0] self.updates_dir= os.path.split(self.updates_dir)[0] if not self.updates_dir: latest_rc = self.updates_rc_dir + os.sep + 'nightly' if os.path.exists(latest_rc): self.updates_dir = open(latest_rc).read() if self.updates_dir: self.updates_dir = self.updates_dir.split('\t')[0] self.updates_dir= os.path.split(self.updates_dir)[0] if not self.updates_dir or not os.path.exists(self.updates_dir): path = os.path.split(os.path.split(os.path.abspath(__file__))[0])[0] # to find ../lib/python2.5/site-packages/ self.updates_dir = path + os.sep + 'Updates' def testWritable(self): "Tests if we can open(mgltools.tar.gz,'w') in the Updates directory" if not os.path.isdir(self.updates_dir): try: os.mkdir(self.updates_dir) except Exception, inst: print inst if self.master: showinfo("Could not create "+self.updates_dir, "Please select directory for downloading updates.") self.browseUpdatesDir() else: self.updates_dir = raw_input("Could not create " + self.updates_dir + "\nPlease enter directory path for saving updates\n") if not self.updates_dir: return False else: self.testWritable() try: open(self.updates_dir + os.sep + 'mgltools.tar.gz','w') os.remove(self.updates_dir + os.sep + 'mgltools.tar.gz') except Exception, inst: if self.master: showinfo("Could not create " + self.updates_dir + os.sep + 'mgltools.tar.gz', "Please select directory for downloading updates.") self.browseUpdatesDir() else: self.updates_dir = raw_input("Could not create "+ self.updates_dir + os.sep + "mgltools.tar.gz\n" "Please enter directory path for saving updates\n") if not self.updates_dir: return False else: self.testWritable() return True def getUpdates(self, packages=[]): "Downloads and unpacks updates" self.setUpdatesDir() if not self.testWritable(): print "Updates are not installed!" return if not self.checkRegistration(): print "Updates are not installed!" self.cancel() return regDict = pickle.load(open(self.rc + os.sep + ".registration")) UserID = regDict['UserID'] update_url = self.baseURL if not self.date_latest or not self.date_tested: self.getInfo() date_tested = self.date_tested date_latest = self.date_latest if self.latest == 'tested': update_url = self.testedURL self.clearUpdates() else: if date_tested == date_latest: try: self.clearUpdates() except: pass update_url = self.testedURL self.latest = 'tested' else: latest_rc = self.updates_rc_dir + os.sep + self.latest if os.path.exists(latest_rc): lines = open(latest_rc).readlines() if lines: date = lines[0].split('\t')[1] if date < date_latest: self.updates_dir += os.sep + 'nightly_' self.updates_dir += date_latest.replace('/','_') lines.insert(0,self.updates_dir + "\t" + date_latest +'\n') open(latest_rc,'w').writelines(lines) else: self.updates_dir += os.sep + 'nightly' self.updates_dir += '_' + date_latest.replace('/','_') open(latest_rc,'w').write(self.updates_dir + "\t" + date_latest + '\n') else: self.updates_dir += os.sep + 'nightly' self.updates_dir += '_' + date_latest.replace('/','_') open(latest_rc,'w').write(self.updates_dir + "\t" + date_latest + '\n') update_url = self.latestURL if self.latest == 'tested': if not os.path.isdir(self.updates_dir): os.mkdir(self.updates_dir) self.updates_dir += os.sep + 'tested' if not os.path.isdir(self.updates_dir): os.mkdir(self.updates_dir) tar_file = self.update_file download_file = open(tar_file,'wb') url_file = urllib.FancyURLopener().open(update_url) if self.master: upload_size = url_file.headers['content-length'] per_size = int(upload_size)/99 self.progressBar.configure(labeltext="Progress ...") self.master.update() for i in range(101): if self.updates_dir == 'cancel': return self.progressBar.set(i) self.master.update() tmp = url_file.read(per_size) if tmp: download_file.write(tmp) else: download_file.close() url_file.close() break self.progressBar.canvas.itemconfig(self.progressBar.progressLabel, text=" Please wait...") self.master.update() else: print "Downloading updates from\n" + update_url +"\nPlease wait..." download_file.write(url_file.read()) download_file.close() if os.name != 'nt': #sys.platform != 'win32': tar = tarfile.open(tar_file) for tarinfo in tar: tar.extract(tarinfo, path=self.updates_dir) tar.close() else: unzipper = unzip.unzip() unzipper.extract(tar_file, self.updates_dir) os.remove(tar_file) if self.latest == 'tested': latest_rc = self.updates_rc_dir + os.sep + self.latest open(latest_rc,'w').write(self.updates_dir + "\t" + date_tested) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} update_dict = {} update_dict['UserID'] = UserID update_dict['type'] = self.latest if self.latest == 'tested': update_dict['date'] = date_tested else: update_dict['date'] = date_latest params = urllib.urlencode(update_dict) conn = httplib.HTTPConnection("www.scripps.edu:80") conn.request("POST", "/cgi-bin/sanner/update_mgltools_user.py", params, headers) response = conn.getresponse() conn.close() if self.master: self.finishGUI() def gui(self): "GUI for MGLTools updates" import Tkinter self.master = Tkinter.Tk() self.master.lift() self.master.title("Update MGLTools") self.master.option_add('*font',"Times 12 bold") text = "Update Manager" Tkinter.Label(self.master, text=text, bg='white', font=(ensureFontCase('helvetica'), 16) ).grid(column=0, row=0, columnspan=3, sticky='snew') tested_rc = self.updates_rc_dir + os.sep + "tested" nightly_rc = self.updates_rc_dir + os.sep + "nightly" tested_dir = None nightly_dir = None if os.path.exists(tested_rc): tested_dir = open(tested_rc).read() if os.path.exists(nightly_rc): nightly_dir = open(nightly_rc).readlines() text = "You are running MGLTools " + self.Version if nightly_dir: tmp = nightly_dir[0] text += " with nightly update from " +tmp.split()[1] if len(nightly_dir)>1: text += "\nOlder installed updates:\n" for item in nightly_dir[1:]: text += " nightly " + item.split('\t')[1] +"\n" if tested_dir: text += " tested " + tested_dir.split('\t')[1] elif tested_dir: text += "\nOlder installed updates:\n" text += " tested " + tested_dir.split('\t')[1] elif tested_dir: text += " with tested update from " + tested_dir.split()[1] Tkinter.Label(self.master, text=text, bg='white', justify='left' ).grid(row=1, column=0, columnspan=3, sticky='snew') self.notebook = Pmw.NoteBook(self.master) self.notebook.grid(row=2, column=0, columnspan=3, sticky='snew') webPage = self.notebook.add('Online') self.webPage = webPage self.updateCheckbutton = Tkinter.Checkbutton(webPage, text="Check for Updates", command=self.checkUpdates) self.updateCheckbutton.grid(row=0, column=0, columnspan=3,sticky='nw') self.tk_latest = Tkinter.IntVar() from mglutil.gui.BasicWidgets.Tk.progressBar import ProgressBar self.frame = Tkinter.Frame(self.master, relief='groove') self.frame.grid(row=4, column=0, columnspan=3, sticky='ew') self.progressBar = ProgressBar(master=self.frame, labelside=None, width=200, height=20, mode='percent') self.progressBar.setLabelText('Progress...') self.frame.grid_forget() self.waitTk = Tkinter.IntVar() if tested_dir or nightly_dir: Tkinter.Button(self.master, text="Revert to "+self.Version, command=self.clearUpdatesGUI).grid(row=5, column=0) if nightly_dir: if len(nightly_dir) > 1: Tkinter.Button(self.master, text="Rollback to nightly " + \ nightly_dir[1].split('\t')[1], command=self.rollback).grid(row=5, column=1) elif tested_dir: Tkinter.Button(self.master, text="Rollback to tested " + \ tested_dir.split('\t')[1], command=self.rollback).grid(row=5, column=1) Tkinter.Button(self.master, text="Cancel", command=self.cancel).\ grid(row=5, column=2) self.tested_dir = tested_dir self.nightly_dir = nightly_dir filePage = self.notebook.add('File') self.localLabel = Tkinter.Label(filePage, text="Update from Local File", justify='left', fg='gray45') self.localLabel.grid() self.localButton = Tkinter.Button(filePage, text="Browse...", command=self.updateLocal) self.localButton.grid() self.notebook.setnaturalsize() return self.waitTk def checkUpdates(self): """This command is called when Check for Updates button is pressed""" self.updateCheckbutton.configure(state='disabled') #check to see if self.Version is the latest version = urllib.urlopen(base_url+'/version').read().strip() if self.Version < version: txt = "New version (" + version + ") is available for download." Tkinter.Label(self.webPage, text=txt).\ grid(row=1, column=0, sticky='ew') l = Tkinter.Label(self.webPage, fg='Blue', cursor='hand1', text='http://mgltools.scripps.edu/downloads') l.grid(row=2, column=0, sticky='ew') def openurl(evt=None): webbrowser.open('http://mgltools.scripps.edu/downloads') l.bind(sequence="", func=openurl) self.notebook.setnaturalsize() if not self.date_latest or not self.date_tested: self.getInfo() date_tested = self.date_tested date_latest = self.date_latest updatesLabel = Tkinter.Label(self.webPage, text='Available updates:', justify='left') updatesLabel.grid(row=3, column=0, sticky='w') self.testedButton = None self.nightlyButton = None def getTested(): webbrowser.open_new(self.testedURL) def getNightly(): webbrowser.open_new(self.latestURL) if self.tested_dir and date_tested: if date_tested > self.tested_dir.split()[1]: testedGroup = Tkinter.LabelFrame(self.webPage, padx=5, pady=5, text = "Updates - Tested Builds") testedGroup.grid(row=4, column=0, columnspan=3, sticky='ew') Tkinter.Label(testedGroup, text=date_tested +' ', justify='left').\ grid(row=0, column=0, sticky='w') self.testedButton = Tkinter.Button(testedGroup, text=' Install ', command=self.updateTested) self.testedButton.grid(row=0, column=1, sticky='ew') self.downloadTested = Tkinter.Button(testedGroup, text=' Save to File ', command=getTested) self.downloadTested.grid(row=0, column=2, sticky='ew') elif date_tested: testedGroup = Tkinter.LabelFrame(self.webPage, padx=5, pady=5, text = "Updates - Tested Builds") testedGroup.grid(row=4, column=0, columnspan=3, sticky='ew') Tkinter.Label(testedGroup, text=date_tested+' ',justify='left').\ grid(row=0, column=0, sticky='w') self.testedButton = Tkinter.Button(testedGroup, text=' Install ', command=self.updateTested) self.testedButton.grid(row=0, column=1, sticky='ew') self.downloadTested = Tkinter.Button(testedGroup, text=' Save to File ', command=getTested) self.downloadTested.grid(row=0, column=2, sticky='ew') if self.nightly_dir and date_latest: if date_latest > self.nightly_dir[0].split()[1]: nightlyGroup = Tkinter.LabelFrame(self.webPage, padx=5, pady=5, text = "Updates - Nightly Builds") nightlyGroup.grid(row=5, column=0, columnspan=3, sticky='ew') Tkinter.Label(nightlyGroup, text=date_latest,justify='left').\ grid(row=0, column=0, sticky='w') self.nightlyButton = Tkinter.Button(nightlyGroup, text='Install', command=self.updateNightly) self.nightlyButton.grid(row=0, column=1, sticky='ew') self.downloadNightly = Tkinter.Button(nightlyGroup, text='Save to File', command=getNightly) self.downloadNightly.grid(row=0, column=2, sticky='ew') elif date_latest: if date_latest > date_tested: nightlyGroup = Tkinter.LabelFrame(self.webPage, padx=5, pady=5, text = "Updates - Nightly Builds") nightlyGroup.grid(row=5, column=0, columnspan=3, sticky='ew') Tkinter.Label(nightlyGroup, text=date_latest,justify='left').\ grid(row=0, column=0, sticky='w') self.nightlyButton = Tkinter.Button(nightlyGroup, text='Install', command=self.updateNightly) self.nightlyButton.grid(row=0, column=1, sticky='ew') self.downloadNightly = Tkinter.Button(nightlyGroup, text='Save to File', command=getNightly) self.downloadNightly.grid(row=0, column=2, sticky='ew') # If test results summary is available for current platform (or at least for Linux), # add a button to show it. self.summary_file = "testsummary"+ sys.platform + ".html" if sys.platform == "darwin": if os.uname()[-1] == 'Power Macintosh': prt = "powerpc" else: prt = "i386" self.summary_file = "testsummary"+sys.platform+ prt+".html" date_summary = self.getDate(self.baseURL+'/latest/', self.baseURL+'/latest/'+self.summary_file) if not date_summary: # no test summary for current platform self.summary_file = "testsummarylinux2.html" date_summary = self.getDate(self.baseURL+'/latest/', self.baseURL+'/latest/'+self.summary_file ) #print "date_summary:", date_summary #print "self.summary_file:", self.summary_file if date_summary == date_latest: # add a button to show the report summary Tkinter.Label(nightlyGroup, text='Click to see test summary:', justify='left', fg='gray45').grid(row=1, column=0, columnspan=2, sticky='w' ) self.summaryButton = Tkinter.Button(nightlyGroup, text="Test Summary", command=self.showTestSummary ) self.summaryButton.grid(row=1, column = 2, sticky='ew') if not self.testedButton and not self.nightlyButton: updatesLabel.configure(text="No updates are available at this time.") self.notebook.setnaturalsize() def checkRegistration(self): if not self.rc: return False regfile = self.rc + os.sep + ".registration" if not os.path.exists(regfile): from mglutil.splashregister.register import Register_User register = Register_User(self.Version) while register.master: self.master.update() if not os.path.exists(regfile): return False return True def updateLocal(self): "Updates from local file" fileTypes = [('', '*.zip *.gz')] file = askopenfilename(parent=self.master,title='Choose a file', filetypes=fileTypes) if not file: return self.setUpdatesDir() if not self.testWritable(): print "Updates are not installed!" return self.localButton.configure(state='disabled') self.localLabel.configure(text='Please Wait...') self.master.update() mtime = os.path.getmtime(file) import time mdate = time.localtime(mtime) date_latest = str(mdate[0]) + '/' + str(mdate[1]) + '/' + str(mdate[2]) latest_rc = self.updates_rc_dir + os.sep + 'nightly' if os.path.exists(latest_rc): lines = open(latest_rc).readlines() if lines: self.updates_dir += os.sep + 'nightly_' self.updates_dir += date_latest.replace('/','_') lines.insert(0,self.updates_dir + " " + date_latest +'\n') open(latest_rc,'w').writelines(lines) else: self.updates_dir += os.sep + 'nightly' self.updates_dir += '_' + date_latest.replace('/','_') open(latest_rc,'w').write(self.updates_dir + " " + date_latest + '\n') else: self.updates_dir += os.sep + 'nightly' self.updates_dir += '_' + date_latest.replace('/','_') open(latest_rc,'w').write(self.updates_dir + " " + date_latest + '\n') if not os.path.isdir(self.updates_dir): os.mkdir(self.updates_dir) if file.endswith('.gz'): tar = tarfile.open(file) for tarinfo in tar: tar.extract(tarinfo, path=self.updates_dir) tar.close() else: unzipper = unzip.unzip() unzipper.extract(file, self.updates_dir) if self.master: self.finishGUI() def browseUpdatesDir(self): self.updates_dir = askdirectory() def cancel(self): self.updates_dir = 'cancel' self.finishGUI() def finishGUI(self): self.waitTk.set(1) self.master.destroy() def rollback(self): nighlty_dir = None tested_dir = None nighlty_rc = self.updates_rc_dir + os.sep + 'nightly' if os.path.exists(nighlty_rc): nighlty_dir = open(nighlty_rc).readlines() tested_rc = self.updates_rc_dir + os.sep + 'tested' if os.path.exists(tested_rc): tested_dir = open(tested_rc).read() if nighlty_dir: if len(nighlty_dir) > 1: open(nighlty_rc,'w').writelines(nighlty_dir[1:]) else: os.remove(nighlty_rc) rm_dirs(nighlty_dir[0].split()[0]) elif tested_dir: self.clearUpdates() self.finishGUI() def updateTested(self): self.testedButton.configure(state='disabled') self.frame.grid(row=4, column=0, columnspan=3, sticky='ew') self.progressBar.setLabelText("Downloading Updates. Please wait...") self.master.update() self.latest = 'tested' self.getUpdates() def updateNightly(self): self.nightlyButton.configure(state='disabled') self.frame.grid(row=4, column=0, columnspan=3, sticky='ew') self.progressBar.setLabelText("Downloading Updates. Please wait...") self.master.update() self.latest = 'nightly' self.getUpdates() def clearUpdates(self): "Removes all updates files" updates_rc = [] updates_rc.append(self.updates_rc_dir + os.sep + 'nightly') updates_rc.append(self.updates_rc_dir + os.sep + 'tested') for update in updates_rc: if os.path.exists(update): update_dir = open(update).read() os.remove(update) if update_dir: update_dir = update_dir.split('\t')[0] if update_dir.find('tested') == -1 and update_dir.find('nightly') == -1: print "Refusing to delete " + update_dir print "Please delete " +update_dir +" to clear updates" return if os.path.isdir(update_dir): mgl_dirs = os.listdir(update_dir) for dir in mgl_dirs: dir_path = update_dir + os.sep + dir if os.path.isdir(dir_path): rm_dirs(dir_path) else: os.remove(dir_path) os.rmdir(update_dir) def showTestSummary(self): webbrowser.open_new(self.baseURL+'/latest/'+self.summary_file) def getInfo(self): "Gets info about nighly and tested builds" nightly_url = self.baseURL + '/latest/' f = urllib.urlopen(nightly_url) html = f.read() start = html.find(self.update_file) if start > 0: html = html[start:].split() self.date_latest = html[10].split('')[0] self.latestURL = html[6].split("\"")[1] f.close() nightly_url = self.baseURL + '/latest-tested/' f = urllib.urlopen(nightly_url) html = f.read() start = html.find(self.update_file) if start > 0: html = html[start:].split() self.date_tested = html[10].split('')[0] self.testedURL = html[6].split("\"")[1] f.close() def getDate(self, nightly_url, update_url): "This function is used to extract date from remote directory listing" f = urllib.urlopen(nightly_url) html = f.read() start = html.find(update_url) if start < 0: return None html = html[start:].split() date = html[10].split('')[0] f.close() return date def clearUpdatesGUI(self): try: self.clearUpdates() except: pass self.finishGUI() if __name__ == "__main__": u = Update() u.gui() u.master.mainloop() print u.updates_dir Support-1.5.7~rc1+cvs.20140424/Support/version.py0000644000175000017500000000002711567037273021077 0ustar moellermoeller__version__ = 'latest'