Main Page
Namespaces
Classes
Files
File List
src
launchman
app.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# Software License Agreement (BSD License)
3
#
4
# Copyright (c) 2008, Willow Garage, Inc.
5
# All rights reserved.
6
#
7
# Redistribution and use in source and binary forms, with or without
8
# modification, are permitted provided that the following conditions
9
# are met:
10
#
11
# * Redistributions of source code must retain the above copyright
12
# notice, this list of conditions and the following disclaimer.
13
# * Redistributions in binary form must reproduce the above
14
# copyright notice, this list of conditions and the following
15
# disclaimer in the documentation and/or other materials provided
16
# with the distribution.
17
# * Neither the name of Willow Garage, Inc. nor the names of its
18
# contributors may be used to endorse or promote products derived
19
# from this software without specific prior written permission.
20
#
21
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
# POSSIBILITY OF SUCH DAMAGE.
33
#
34
# Revision $Id$
35
36
import
sys
37
import
yaml
38
import
subprocess
39
import
os.path
40
41
def
getPackagePath
(pkg):
42
cmd = [
"rospack"
,
"find"
, pkg]
43
pkgpath = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].strip()
44
return
pkgpath
45
46
class
App
:
47
app_keys_lists = (
'provides'
,
'depends'
)
48
app_keys = (
'name'
,
'package'
,
'launch_file'
,
'description'
,
49
'icon'
) + app_keys_lists
50
def
__init__
(self, taskid):
51
if
not
taskid.endswith(
".app"
):
52
taskid = taskid +
".app"
53
self.
taskid
= taskid
54
self.package, self.
app_file
= self.taskid.split(
'/'
, 1)
55
self.
path
=
None
56
57
def
fn
(self):
58
if
self.
path
:
return
self.
path
59
self.
path
=
getPackagePath
(self.package)
60
fn = os.path.join(self.
path
, self.
app_file
)
61
return
fn
62
63
def
load_yaml
(self):
64
fn = self.
fn
()
65
# TODO catch file system exception
66
doc = yaml.load(open(fn))
67
return
doc
68
69
def
load
(self):
70
doc = self.
load_yaml
()
71
try
:
72
for
key
in
self.
app_keys
:
73
if
doc.has_key(key):
74
val = doc[key]
75
if
val
is
not
None
:
76
if
type(val) != list:
77
val = val.strip()
78
if
key
in
self.
app_keys_lists
:
79
if
type(val) == list:
80
val.sort()
81
val = tuple(val)
82
else
:
83
val = tuple([val])
84
setattr(self, key, val)
85
except
KeyError:
86
print
"Invalid YAML file"
87
launchman.app.getPackagePath
def getPackagePath(pkg)
Definition:
app.py:41
launchman.app.App.app_keys
tuple app_keys
Definition:
app.py:48
launchman.app.App.taskid
taskid
Definition:
app.py:53
launchman.app.App.path
path
Definition:
app.py:55
launchman.app.App.load
def load(self)
Definition:
app.py:69
launchman.app.App.load_yaml
def load_yaml(self)
Definition:
app.py:63
launchman.app.App
Definition:
app.py:46
launchman.app.App.app_file
app_file
Definition:
app.py:54
launchman.app.App.app_keys_lists
tuple app_keys_lists
Definition:
app.py:47
launchman.app.App.__init__
def __init__(self, taskid)
Definition:
app.py:50
launchman.app.App.fn
def fn(self)
Definition:
app.py:57
launchman
Author(s): Scott Noob Hassan
autogenerated on Mon Jun 10 2019 15:51:09