Browse Source

Search '/usr/share/gitstats/' for static files as well.

The first path to be searched is the directory of the binary, then
/usr/share/gitstats/. This is so that you can have both a "global" gitstats
version and a user-specific checkout installed, and the static files should be
taken from the matching place.

This change is done in preparation for Debian packaging.

Vincent Fourmond <fourmond@debian.org> is planning to package gitstats for
debian (RFP #440392).
Heikki Hokkanen 16 years ago
parent
commit
6397a94b30
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      gitstats

+ 8
- 2
gitstats View File

478
 		self.title = data.projectname
478
 		self.title = data.projectname
479
 
479
 
480
 		# copy static files if they do not exist
480
 		# copy static files if they do not exist
481
+		basedirs = [os.path.dirname(os.path.abspath(__file__)), '/usr/share/gitstats']
481
 		for file in ('gitstats.css', 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif'):
482
 		for file in ('gitstats.css', 'sortable.js', 'arrow-up.gif', 'arrow-down.gif', 'arrow-none.gif'):
482
-			basedir = os.path.dirname(os.path.abspath(__file__))
483
-			shutil.copyfile(basedir + '/' + file, path + '/' + file)
483
+			for base in basedirs:
484
+				src = base + '/' + file
485
+				if os.path.exists(src):
486
+					shutil.copyfile(src, path + '/' + file)
487
+					break
488
+			else:
489
+				print 'Warning: "%s" not found, so not copied (searched: %s)' % (file, basedirs)
484
 
490
 
485
 		f = open(path + "/index.html", 'w')
491
 		f = open(path + "/index.html", 'w')
486
 		format = '%Y-%m-%d %H:%M:%S'
492
 		format = '%Y-%m-%d %H:%M:%S'