~chris.macnaughton/mojo/disco-enablement-py3

« back to all changes in this revision

Viewing changes to mojo/__init__.py

  • Committer: Matthew Wedgwood
  • Date: 2013-06-21 23:20:49 UTC
  • Revision ID: matthew.wedgwood@canonical.com-20130621232049-41qz1m0w0yra8q5c
First two mojo tools, init and collect

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import os
 
2
try:
 
3
    from jenkins import (
 
4
        workspace_path,
 
5
    )
 
6
except ImportError:
 
7
    from generic import (
 
8
        workspace_path,
 
9
    )
 
10
 
 
11
 
 
12
def config_dir(workspace):
 
13
    return os.path.join(workspace, "configuration")
 
14
 
 
15
 
 
16
def build_dir(workspace):
 
17
    return os.path.join(workspace, "build")
 
18
 
 
19
 
 
20
def charm_repo_dir(workspace):
 
21
    return os.path.join(workspace, "charms")
 
22
 
 
23
 
 
24
def log_dir(workspace):
 
25
    return os.path.join(workspace, "log")
 
26
 
 
27
 
 
28
class ConfigNotFoundException(Exception):
 
29
    pass
 
30
 
 
31
 
 
32
def get_config_file(workspace, base, envtag=None):
 
33
    config_base = os.path.join(config_dir(workspace), base, base)
 
34
    config_names = [config_base]
 
35
    if envtag:
 
36
        config_names.insert(0, "{}-{}".format(config_base, envtag))
 
37
    for config in config_names:
 
38
        if os.path.exists(config):
 
39
            return config
 
40
    raise ConfigNotFoundException("Config not found: " + ", ".join(config_names))