~pieq/checkbox/fix-1484872-env-variables-forced-to-non-international

« back to all changes in this revision

Viewing changes to providers/plainbox-provider-certification-server/manage.py

  • Committer: Zygmunt Krynicki
  • Date: 2014-12-19 12:11:52 UTC
  • mto: This revision was merged to the branch mainline in revision 3516.
  • Revision ID: zygmunt.krynicki@canonical.com-20141219121152-y9vtxajhrd6e1c3l
cep: merge CEPs in to trunk

This patch merges CEPs (aka Checkbox Enhancement Proposals) into trunk.
Those lived on separately for a while as lp:checkbox/cep but in
retrospective nobody knows about them and this should give them some
more exposure. In addition, the move allows new features to land a CEP
document along, making review of complex new features easier to make as
their specification can be seen alongside the patches that implement it.

Due to bazaar limitations in merging separate repositories together I've
discarded history entries (not that there were many) and just added
those files in directly.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python3
 
2
# This file is part of Checkbox.
 
3
#
 
4
# Copyright 2012, 2013, 2014 Canonical Ltd.
 
5
# Written by:
 
6
#   Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
 
7
#
 
8
# Checkbox is free software: you can redistribute it and/or modify
 
9
# it under the terms of the GNU General Public License as published by
 
10
# the Free Software Foundation, either version 3 of the License, or
 
11
# (at your option) any later version.
 
12
#
 
13
# Checkbox is distributed in the hope that it will be useful,
 
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
# GNU General Public License for more details.
 
17
#
 
18
# You should have received a copy of the GNU General Public License
 
19
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
 
20
 
 
21
import shutil
 
22
import os
 
23
 
 
24
from plainbox.provider_manager import InstallCommand
 
25
from plainbox.provider_manager import SourceDistributionCommand
 
26
from plainbox.provider_manager import _logger
 
27
from plainbox.provider_manager import manage_py_extension
 
28
from plainbox.provider_manager import setup, N_, _
 
29
 
 
30
 
 
31
@manage_py_extension
 
32
class SourceDistributionCommandExt(SourceDistributionCommand):
 
33
    # Overridden version of SourceDistributionCommand that handles launcher/
 
34
    __doc__ = SourceDistributionCommand.__doc__
 
35
    _INCLUDED_ITEMS = SourceDistributionCommand._INCLUDED_ITEMS + [
 
36
        'COPYING', 'launcher']
 
37
 
 
38
 
 
39
@manage_py_extension
 
40
class InstallCommandExt(InstallCommand):
 
41
    # Overridden version of InstallCommand that handles launcher/
 
42
    __doc__ = InstallCommand.__doc__
 
43
    name = 'install'
 
44
 
 
45
    def invoked(self, ns):
 
46
        super().invoked(ns)
 
47
        self._copy_launcher(ns)
 
48
 
 
49
    @property
 
50
    def launcher_dir(self):
 
51
        return os.path.join(self.definition.location, 'launcher')
 
52
 
 
53
    def _copy_launcher(self, ns):
 
54
        for name in os.listdir(self.launcher_dir):
 
55
            src_file = os.path.join(self.launcher_dir, name)
 
56
            if os.path.isfile(src_file) and name.endswith('.desktop'):
 
57
                self._copy_desktop_file(ns, src_file)
 
58
            elif os.path.isfile(src_file) and os.access(src_file, os.X_OK):
 
59
                self._copy_executable(ns, src_file)
 
60
            else:
 
61
                _logger.warning(_("unexpected file: %s"), os.path.relpath(
 
62
                    src_file, self.definition.location))
 
63
 
 
64
    def _copy_desktop_file(self, ns, src_file):
 
65
        destdir = ns.root + os.path.join(ns.prefix, 'share', 'applications')
 
66
        os.makedirs(destdir, exist_ok=True)
 
67
        shutil.copy(src_file, destdir)
 
68
 
 
69
    def _copy_executable(self, ns, src_file):
 
70
        destdir = ns.root + os.path.join(ns.prefix, 'bin')
 
71
        os.makedirs(destdir, exist_ok=True)
 
72
        shutil.copy(src_file, destdir)
 
73
 
 
74
    def _copy_all_executables(self, root, prefix, layout, provider):
 
75
        if provider.get_all_executables():
 
76
            super()._copy_all_executables(root, prefix, layout, provider)
 
77
 
 
78
 
 
79
setup(
 
80
    name='2013.com.canonical.certification:certification-server',
 
81
    version="1.0",
 
82
    description=N_("Server Certification provider"),
 
83
    gettext_domain="2013_com_canonical_certification_certification-server",
 
84
)