~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to checkbox-touch/confinement/plainbox_confined_shell.py

  • Committer: Sylvain Pineau
  • Date: 2014-07-29 16:05:54 UTC
  • mto: This revision was merged to the branch mainline in revision 3149.
  • Revision ID: sylvain.pineau@canonical.com-20140729160554-qev8887xbunn9tmi
checkbox-ng:launchers:checkbox-cli: The checkbox-cli launcher

Running the default whitelist (with the suite selection screen skipped)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This file is part of Checkbox.
2
 
#
3
 
# Copyright 2015 Canonical Ltd.
4
 
# Written by:
5
 
#   Maciej Kisielewski <maciej.kisielewski@canonical.com>
6
 
#
7
 
# Checkbox is free software: you can redistribute it and/or modify
8
 
# it under the terms of the GNU General Public License version 3,
9
 
# as published by the Free Software Foundation.
10
 
#
11
 
# Checkbox is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
18
 
 
19
 
import json
20
 
import os
21
 
 
22
 
 
23
 
def obj_to_file(obj, consumer_name, filename):
24
 
    """
25
 
    Stringify object, write it to file and return path to the file.
26
 
 
27
 
    :param object:
28
 
        Object to be stringified
29
 
    :param consumer_name:
30
 
        Name of the app that will consume the generated file
31
 
    :param filename:
32
 
        Name of the file to write to (just the basename)
33
 
    :returns:
34
 
        Path to the written file
35
 
    """
36
 
    s = json.dumps(obj)
37
 
    dir_path = os.path.join(os.environ['XDG_RUNTIME_DIR'], consumer_name)
38
 
    if not os.path.exists(dir_path):
39
 
        os.makedirs(dir_path)
40
 
    out_path = os.path.join(dir_path, filename)
41
 
    with open(out_path, "wt") as f:
42
 
        f.write(s)
43
 
    return out_path