~james-w/udd/management-commands

« back to all changes in this revision

Viewing changes to udd/paths.py

  • Committer: James Westby
  • Date: 2011-12-13 21:09:23 UTC
  • mfrom: (557.1.1 drop_email_failures)
  • Revision ID: james.westby@canonical.com-20111213210923-tfrirlx3xbwmi70u
Merged drop_email_failures into management-commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
 
3
 
 
4
 
class Paths(object):
5
 
    # The explanations file contains tracebacks - these are highly sensitive to
6
 
    # changes in the code, so are kept alongside the code.
7
 
    explanations_file = os.path.join(os.path.dirname(__file__),
8
 
                                     '..', 'explanations')
9
 
 
10
 
    @property
11
 
    def base_dir(self):
12
 
        from udd import iconfig
13
 
        return iconfig.Iconfig().get('pkgimport.base_dir')
14
 
 
15
 
    # Paths relative to the base_dir
16
 
 
17
 
    def __getattr__(self, name):
18
 
        return os.path.join(self.base_dir, getattr(self, "_" + name))
19
 
 
20
 
    # Common across multiple components:
21
 
    _sqlite_file = "meta.db"
22
 
    _sqlite_package_file = "packages.db"
23
 
    _sqlite_history_file = "history.db"
24
 
 
25
 
    # FIXME: This is needed for tests and tests may be run in various dirs,
26
 
    # creating a new credentials file for any random branch is not optimal :-)
27
 
    # -- vila 20110219
28
 
    # FIXME: Keeping a local credentials file doesn't feel right, when we have a
29
 
    # newer launchpadlib, we should try to offload this to relying on its APIs.
30
 
    # --maxb 20110615
31
 
    _lp_creds_file = "lp_creds.txt"
32
 
 
33
 
    # Used by mass_import.py:
34
 
    _stop_file = "STOP_PLEASE"
35
 
    _max_threads_file = "max_threads"
36
 
 
37
 
    # Used by import_package.py:
38
 
    _lists_dir = "lists"
39
 
    _locks_dir = "locks"
40
 
    _updates_dir = "updates"
41
 
    _download_cache_dir = "download-cache"
42
 
    _localbranches_dir = "localbranches"
43
 
    _debian_diffs_dir = os.path.join("www", "diffs")
44
 
    _ubuntu_merge_dir = os.path.join("www", "merges")
45
 
 
46
 
    # Used by categorize_failures.py:
47
 
    _web_base_dir = "www"
48
 
    _web_status_dir = os.path.join("www", "status")
49
 
 
50
 
    _override_root_dir = None
51
 
 
52
 
    # The directory that the udd code lives in.
53
 
    def get_root_dir(self):
54
 
        override_root_dir = getattr(self, '_override_root_dir', None)
55
 
        if override_root_dir is not None:
56
 
            return override_root_dir
57
 
        return os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
58
 
 
59
 
 
60
 
    def set_root_dir(self, new_dir):
61
 
        self._override_root_dir = new_dir
62
 
 
63
 
    root_dir = property(get_root_dir, set_root_dir)
64
 
 
65
 
 
66
 
    def static_file_path(self, filename):
67
 
        """Return the path to the static resource file, 'filename'."""
68
 
        return os.path.join(self.root_dir, filename)
69
 
 
70
 
 
71
 
paths = Paths()