Source

trac-ticketlinks / scripts / trac-postinstall.py

# Post installation script for the Windows installer
# This script is needed to create the trac/siteconfig.py file containing various
# global default directories

import os.path
import sys
from distutils import sysconfig
import trac

def install():
    print 'Setting up default directories...'
    site_packages = os.path.join(sysconfig.get_config_var('BINLIBDEST'),
                                 'site-packages')
    prefix = sysconfig.get_config_var('prefix')

    templates_dir = os.path.join(prefix, 'share', 'trac', 'templates')
    htdocs_dir = os.path.join(prefix, 'share', 'trac', 'htdocs')
    wiki_dir = os.path.join(prefix, 'share', 'trac', 'wiki-default')

    siteconfig = os.path.join(site_packages, 'trac', 'siteconfig.py')
    fd = open(siteconfig, 'w')
    fd.write("""
# PLEASE DO NOT EDIT THIS FILE!
# This file was autogenerated when installing Trac %(version)s.
#
__default_templates_dir__ = %(templates)r
__default_htdocs_dir__ = %(htdocs)r
__default_wiki_dir__ = %(wiki)r

""" % {'version': trac.__version__, 'templates': templates_dir,
       'htdocs': htdocs_dir, 'wiki': wiki_dir})
    fd.close()

    file_created(siteconfig)
    print 'Done.'

def remove():
    pass


if __name__ == '__main__':
    mode = sys.argv[1]
    if mode == '-install':
        install()
    elif mode == '-remove':
        remove()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.