~ubuntu-branches/ubuntu/quantal/lptools/quantal

« back to all changes in this revision

Viewing changes to lptools/config.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij, Robert Collins, Jelmer Vernooij
  • Date: 2011-09-01 22:47:11 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20110901224711-05u7hwne9anexqq9
Tags: 0.0.1~bzr28-1
[ Robert Collins ]
* Control tweaks.

[ Jelmer Vernooij ]
* New upstream snapshot.
 + Imports a few tools from ubuntu-dev-tools. Breaks/Replaces added.
* Add myself to Uploaders.
* Bump standards version to 3.9.2 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Author: Robert Collins <robert.collins@canonical.com>
 
2
#
 
3
# Copyright 2010 Canonical Ltd.
 
4
#
 
5
# This program is free software: you can redistribute it and/or modify it
 
6
# under the terms of the GNU General Public License version 3, as published
 
7
# by the Free Software Foundation.
 
8
#
 
9
# This program is distributed in the hope that it will be useful, but
 
10
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
12
# PURPOSE.  See the GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License along
 
15
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 
 
17
from __future__ import with_statement
 
18
 
 
19
"""Configuration glue for lptools."""
 
20
 
 
21
__all__ = [
 
22
    "ensure_dir",
 
23
    "get_launchpad",
 
24
    ]
 
25
 
 
26
import os.path
 
27
 
 
28
from launchpadlib.launchpad import Launchpad
 
29
 
 
30
 
 
31
def ensure_dir(dir):
 
32
    """Ensure that dir exists."""
 
33
    if not os.path.isdir(dir):
 
34
        os.makedirs(dir)
 
35
 
 
36
 
 
37
def get_launchpad(appname):
 
38
    """Get a login to launchpad for lptools caching in cachedir.
 
39
    
 
40
    Note that caching is not multiple-process safe in launchpadlib,
 
41
    and the appname parameter is used to create per-app cachedirs.
 
42
 
 
43
    :param appname: The name of the app used to create per-app
 
44
        cachedirs.
 
45
    """
 
46
    return Launchpad.login_with("lptools-%s" % appname, "production")