Edgewall Software

Changeset 14638


Ignore:
Timestamp:
Mar 25, 2016, 6:22:36 PM (10 years ago)
Author:
Ryan J Ollos
Message:

1.2dev: Merge [14637] from 1.0-stable

Refs #12410.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/trac/admin/web_ui.py

    r14614 r14638  
    502502                              "egg"))
    503503
    504         target_path = os.path.join(self.env.path, 'plugins', plugin_filename)
     504        target_path = os.path.join(self.env.plugins_dir, plugin_filename)
    505505        if os.path.isfile(target_path):
    506506            raise TracError(_("Plugin %(name)s already installed",
     
    528528        if not plugin_filename:
    529529            return
    530         plugin_path = os.path.join(self.env.path, 'plugins', plugin_filename)
     530        plugin_path = os.path.join(self.env.plugins_dir, plugin_filename)
    531531        if not os.path.isfile(plugin_path):
    532532            return
     
    599599        data = {
    600600            'plugins': plugins, 'show': req.args.get('show'),
    601             'readonly': not os.access(self.env.get_plugins_dir(),
     601            'readonly': not os.access(self.env.plugins_dir,
    602602                                      os.F_OK + os.W_OK),
    603603            'safe_wiki_to_html': safe_wiki_to_html,
  • trunk/trac/env.py

    r14614 r14638  
    557557        if not os.path.exists(self.path):
    558558            os.mkdir(self.path)
    559         os.mkdir(self.get_log_dir())
    560         os.mkdir(self.get_htdocs_dir())
    561         os.mkdir(os.path.join(self.path, 'plugins'))
     559        os.mkdir(self.log_dir)
     560        os.mkdir(self.htdocs_dir)
     561        os.mkdir(self.plugins_dir)
    562562
    563563        # Create a few files
     
    568568
    569569        # Setup the default configuration
    570         os.mkdir(os.path.join(self.path, 'conf'))
     570        os.mkdir(self.conf_dir)
    571571        create_file(self.config_file_path + '.sample')
    572572        config = Configuration(self.config_file_path)
     
    641641    def config_file_path(self):
    642642        """Path of the trac.ini file."""
    643         return os.path.join(self.path, 'conf', 'trac.ini')
     643        return os.path.join(self.conf_dir, 'trac.ini')
    644644
    645645    def _get_path_to_dir(self, dir):
     
    647647        return os.path.normcase(os.path.realpath(path))
    648648
     649    @lazy
     650    def conf_dir(self):
     651        """Absolute path to the conf directory.
     652
     653        :since: 1.0.11
     654        """
     655        return self._get_path_to_dir('conf')
     656
     657    @lazy
     658    def htdocs_dir(self):
     659        """Absolute path to the htdocs directory.
     660
     661        :since: 1.0.11
     662        """
     663        return self._get_path_to_dir('htdocs')
     664
     665    def get_htdocs_dir(self):
     666        """Return absolute path to the htdocs directory.
     667
     668        :since 1.0.11: Deprecated and will be removed in 1.3.1. Use the
     669                       `htdocs_dir` property instead.
     670        """
     671        return self._get_path_to_dir('htdocs')
     672
     673    @lazy
     674    def log_dir(self):
     675        """Absolute path to the log directory.
     676
     677        :since: 1.0.11
     678        """
     679        return self._get_path_to_dir('log')
     680
     681    def get_log_dir(self):
     682        """Return absolute path to the log directory.
     683
     684        :since 1.0.11: Deprecated and will be removed in 1.3.1. Use the
     685                       `log_dir` property instead.
     686        """
     687        return self._get_path_to_dir('log')
     688
     689    @lazy
     690    def plugins_dir(self):
     691        """Absolute path to the plugins directory.
     692
     693        :since: 1.0.11
     694        """
     695        return self._get_path_to_dir('plugins')
     696
     697    @lazy
     698    def templates_dir(self):
     699        """Absolute path to the templates directory.
     700
     701        :since: 1.0.11
     702        """
     703        return self._get_path_to_dir('templates')
     704
    649705    def get_templates_dir(self):
    650         """Return absolute path to the templates directory."""
     706        """Return absolute path to the templates directory.
     707
     708        :since 1.0.11: Deprecated and will be removed in 1.3.1. Use the
     709                       `templates_dir` property instead.
     710        """
    651711        return self._get_path_to_dir('templates')
    652 
    653     def get_htdocs_dir(self):
    654         """Return absolute path to the htdocs directory."""
    655         return self._get_path_to_dir('htdocs')
    656 
    657     def get_log_dir(self):
    658         """Return absolute path to the log directory."""
    659         return self._get_path_to_dir('log')
    660 
    661     def get_plugins_dir(self):
    662         """Return absolute path to the plugins directory."""
    663         return self._get_path_to_dir('plugins')
    664712
    665713    def setup_log(self):
     
    668716        logfile = self.log_file
    669717        if logtype == 'file' and not os.path.isabs(logfile):
    670             logfile = os.path.join(self.get_log_dir(), logfile)
     718            logfile = os.path.join(self.log_dir, logfile)
    671719        format = self.log_format
    672720        logid = 'Trac.%s' % hashlib.sha1(self.path).hexdigest()
  • trunk/trac/loader.py

    r14614 r14638  
    102102    """Return the path to the `plugins` directory of the environment.
    103103
    104     :since 1.0.11: Deprecated and will be removed in 1.3.1. Use
    105                    Environment.get_plugins_dir() instead."""
    106     return env.get_plugins_dir()
     104    :since 1.0.11: Deprecated and will be removed in 1.3.1. Use the
     105                   Environment.plugins_dir property instead."""
     106    return env.plugins_dir
    107107
    108108
     
    110110                                                   load_py_files())):
    111111    """Load all plugin components found on the given search path."""
    112     plugins_dir = env.get_plugins_dir()
     112    plugins_dir = env.plugins_dir
    113113    search_path = [plugins_dir]
    114114    if extra_path:
     
    139139        return dist
    140140
    141     plugins_dir = env.get_plugins_dir()
     141    plugins_dir = env.plugins_dir
    142142    plugins = {}
    143143    from trac.core import ComponentMeta
  • trunk/trac/tests/functional/testcases.py

    r14306 r14638  
    5555        env.config.set('components', 'RaiseExceptionPlugin.*', 'enabled')
    5656        env.config.save()
    57         create_file(os.path.join(env.path, 'plugins',
    58                                  'RaiseExceptionPlugin.py'),
     57        create_file(os.path.join(env.plugins_dir, 'RaiseExceptionPlugin.py'),
    5958"""\
    6059from trac.core import Component, implements
     
    9998        """Test for regression of the plugin reload fix in r6017"""
    10099        # Setup the DeleteTicket plugin
     100        env = self._testenv.get_trac_environment()
    101101        plugin = open(os.path.join(self._testenv.trac_src,
    102102                                   'sample-plugins', 'workflow',
    103103                                   'DeleteTicket.py')).read()
    104         open(os.path.join(self._testenv.tracdir, 'plugins',
    105                           'DeleteTicket.py'), 'w').write(plugin)
    106         env = self._testenv.get_trac_environment()
     104        plugin_path = os.path.join(env.plugins_dir, 'DeleteTicket.py')
     105        open(plugin_path, 'w').write(plugin)
    107106        prevconfig = env.config.get('ticket', 'workflow')
    108107        env.config.set('ticket', 'workflow',
     
    123122            env.config.save()
    124123            for ext in ('py', 'pyc', 'pyo'):
    125                 filename = os.path.join(self._testenv.tracdir, 'plugins',
     124                filename = os.path.join(env.plugins_dir,
    126125                                        'DeleteTicket.%s' % ext)
    127126                if os.path.exists(filename):
     
    132131    def runTest(self):
    133132        """Test for regression of http://trac.edgewall.org/ticket/3833 a"""
     133        env = self._testenv.get_trac_environment()
    134134        # Assume the logging is already set to debug.
    135         traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
    136                                         'trac.log'))
     135        traclogfile = open(os.path.join(env.log_dir, 'trac.log'))
    137136        # Seek to the end of file so we only look at new log output
    138137        traclogfile.seek(0, 2)
     138
    139139        # Verify that logging is on initially
    140         env = self._testenv.get_trac_environment()
    141 
    142140        env.log.debug("RegressionTestTicket3833 debug1")
    143141        debug1 = traclogfile.read()
     
    152150        # Turn logging off, try to log something, and verify that it does
    153151        # not show up.
    154         traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
    155                                         'trac.log'))
     152        env = self._testenv.get_trac_environment()
     153        traclogfile = open(os.path.join(env.log_dir, 'trac.log'))
    156154        # Seek to the end of file so we only look at new log output
    157155        traclogfile.seek(0, 2)
    158         env = self._testenv.get_trac_environment()
    159156
    160157        env.config.set('logging', 'log_level', 'INFO')
     
    176173        # Turn logging back on, try to log something, and verify that it
    177174        # does show up.
    178         traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
    179                                         'trac.log'))
     175        env = self._testenv.get_trac_environment()
     176        traclogfile = open(os.path.join(env.log_dir, 'trac.log'))
    180177        # Seek to the end of file so we only look at new log output
    181178        traclogfile.seek(0, 2)
    182         env = self._testenv.get_trac_environment()
    183179
    184180        env.config.set('logging', 'log_level', 'DEBUG')
     
    318314        env.config.set('components', 'RaiseExceptionPlugin.*', 'enabled')
    319315        env.config.save()
    320         create_file(os.path.join(env.path, 'plugins', 'RaiseExceptionPlugin.py'),
     316        create_file(os.path.join(env.plugins_dir, 'RaiseExceptionPlugin.py'),
    321317"""\
    322318from trac.core import Component, implements
  • trunk/trac/tests/functional/testenv.py

    r13994 r14638  
    337337            filename = 'authz-' + \
    338338                       hashlib.md5(str(authz_content)).hexdigest()[:9]
    339         authz_file = os.path.join(self.tracdir, 'conf', filename)
     339        env = self.get_trac_environment()
     340        authz_file = os.path.join(env.conf_dir, filename)
    340341        if os.path.exists(authz_file):
    341342            wait_for_file_mtime_change(authz_file)
     
    353354            with open(authz_file, 'w') as f:
    354355                parser.write(f)
    355         env = self.get_trac_environment()
    356356        permission_policies = env.config.get('trac', 'permission_policies')
    357357        env.config.set('trac', 'permission_policies',
  • trunk/trac/ticket/tests/functional/main.py

    r14481 r14638  
    143143        env.config.set('components', plugin_name + '.*', 'enabled')
    144144        env.config.save()
    145         create_file(os.path.join(env.path, 'plugins', plugin_name + '.py'),
     145        create_file(os.path.join(env.plugins_dir, plugin_name + '.py'),
    146146"""\
    147147from genshi.builder import tag
     
    12571257        plugin = open(os.path.join(self._testenv.trac_src, 'sample-plugins',
    12581258                                   'workflow', 'DeleteTicket.py')).read()
    1259         open(os.path.join(self._testenv.tracdir, 'plugins',
    1260                           'DeleteTicket.py'), 'w').write(plugin)
    12611259        env = self._testenv.get_trac_environment()
     1260        plugin_path = os.path.join(env.plugins_dir, 'DeleteTicket.py')
     1261        open(plugin_path, 'w').write(plugin)
    12621262        prevconfig = env.config.get('ticket', 'workflow')
    12631263        env.config.set('ticket', 'workflow',
     
    12851285        self._testenv.get_trac_environment()  # reload environment
    12861286        for ext in ('py', 'pyc', 'pyo'):
    1287             filename = os.path.join(self._testenv.tracdir, 'plugins',
    1288                                     'DeleteTicket.%s' % ext)
     1287            filename = os.path.join(env.plugins_dir, 'DeleteTicket.%s' % ext)
    12891288            if os.path.exists(filename):
    12901289                os.unlink(filename)
  • trunk/trac/web/chrome.py

    r14510 r14638  
    737737        return [('common', pkg_resources.resource_filename('trac', 'htdocs')),
    738738                ('shared', self.shared_htdocs_dir),
    739                 ('site', self.env.get_htdocs_dir())]
     739                ('site', self.env.htdocs_dir)]
    740740
    741741    def get_templates_dirs(self):
    742742        return filter(None, [
    743             self.env.get_templates_dir(),
     743            self.env.templates_dir,
    744744            self.shared_templates_dir,
    745745            pkg_resources.resource_filename('trac', 'templates'),
     
    11881188        files = {}
    11891189        # Collect templates list
    1190         site_templates = list_dir(self.env.get_templates_dir(), '.html')
     1190        site_templates = list_dir(self.env.templates_dir, '.html')
    11911191        shared_templates = list_dir(Chrome(self.env).shared_templates_dir,
    11921192                                    '.html')
    11931193
    11941194        # Collect static resources list
    1195         site_htdocs = list_dir(self.env.get_htdocs_dir())
     1195        site_htdocs = list_dir(self.env.htdocs_dir)
    11961196        shared_htdocs = list_dir(Chrome(self.env).shared_htdocs_dir)
    11971197
  • trunk/trac/wiki/tests/functional.py

    r14131 r14638  
    8888        env.config.set('components', plugin_name + '.*', 'enabled')
    8989        env.config.save()
    90         create_file(os.path.join(env.path, 'plugins',
    91                                  plugin_name + '.py'), """\
     90        create_file(os.path.join(env.plugins_dir, plugin_name + '.py'), """\
    9291from genshi.builder import tag
    9392from trac.core import Component, implements
Note: See TracChangeset for help on using the changeset viewer.