From 0b6e1c3564f203a3a1f4225c3fce27f83bf831d8 Mon Sep 17 00:00:00 2001 From: ddalton10 Date: Thu, 23 Feb 2012 13:09:58 +0000 Subject: [PATCH] Installation script didn't work on debian since the new dir being used doesn't exist. So provide a list of dirs in the script to try. This introduced some other problems with the UI side and also meant we needed a loop. It's a little messy sorry. --- install.py | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/install.py b/install.py index 98d256f..c38ac96 100644 --- a/install.py +++ b/install.py @@ -23,35 +23,51 @@ pyver=python_version ()[:3] # the version of python print "Found python version %s" % (pyver) -outdir="/usr/lib/python"+pyver+"/site-packages/latex_access/" +outdir=("/usr/lib/python"+pyver+"/dist-packages/latex_access/", "/usr/lib/python"+pyver+"/site-packages/latex_access/") +failed=False if len(sys.argv) == 2: if sys.argv[1] == '-h' or sys.argv[1] == '--help': print usage exit () else: - outdir = sys.argv[1] + outdir = [sys.argv[1]] -try: - if not os.path.exists (outdir): - os.mkdir (outdir) - print "Created directory, %s" % (outdir) -except: - print "Couldn't create directory %s." % (outdir) +for dirname in outdir: + if os.path.exists (dirname): + break + if not os.path.exists (dirname): + try: + os.mkdir (dirname) + print "Created directory, %s" % (dirname) + break + except: + continue +if not os.path.exists (dirname): + print "Couldn't create directory %s." % (dirname) print "Installation failed." exit (-1) -print "Installing to %s." % (outdir) +print "Installing to %s." % (dirname) try: for filename in os.listdir("latex_access/"): # copy the files into our path try: - if filename[-3:] == '.py' or filename[-6:] == '.table': # we only want to install .py and .table files - shutil.copyfile (os.path.join("latex_access/",filename), os.path.join(outdir, filename)) - print "Copying %s" % (filename) + if filename[-3:] == '.py' or filename[-6:] == '.table': # we only want to install .py and .table files + try: + shutil.copyfile (os.path.join("latex_access/",filename), os.path.join(dirname, filename)) + print "Copying %s" % (filename) + except: + failed=True + break except: continue - print "Copied files to %s." % (outdir) except: - print "Couldn't install latex-access to %s, perhaps you don't have permission?" % (outdir) + print "Couldn't install latex-access to %s, perhaps you don't have permission?" % (dirname) exit (-1) + +if failed: + print "Couldn't copy files to %s, maybe you don't have permission" % (dirname) + exit (-1) + +print "Copied files to %s." % (dirname)