Skip to content

Commit

Permalink
Installation script didn't work on debian since the new dir being used
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danieldalton10 committed Feb 23, 2012
1 parent d36e3c8 commit 0b6e1c3
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 0b6e1c3

Please sign in to comment.