38 Implements applist part of app_manager, which handles listing of 39 currently installed applications. 47 from .app
import load_AppDefinition_by_name
48 from .msg
import App, ClientApp, KeyValue, Icon
49 from .exceptions
import AppException, InvalidAppException, NotFoundException
53 Default directory where applist configuration is stored. 55 return "/etc/robot/apps" 59 for k, v
in d.iteritems():
60 l.append(KeyValue(k, str(v)))
65 if filename ==
None or filename ==
"":
67 basename, extension = os.path.splitext(filename)
68 if extension.lower() ==
".jpg" or extension.lower() ==
".jpeg":
70 elif extension.lower() ==
".png":
75 icon.data = open(filename,
"rb").read()
79 a = App(name=app_definition.name, display_name=app_definition.display_name, icon=
read_Icon_file(app_definition.icon))
81 for c
in app_definition.clients:
82 a.client_apps.append(ClientApp(c.client_type,
89 Models data stored in a .installed file. These files are used to 90 track installation of apps. 104 installed_data = yaml.load(f)
105 for reqd
in [
'apps']:
106 if not reqd
in installed_data:
107 raise InvalidAppException(
"installed file [%s] is missing required key [%s]"%(self.
filename, reqd))
108 for app
in installed_data[
'apps']:
109 for areqd
in [
'app']:
111 raise InvalidAppException(
"installed file [%s] app definition is missing required key [%s]"%(self.
filename, areqd))
114 except NotFoundException
as e:
117 except Exception
as e:
132 if platform
is not None:
133 return filter(
lambda app: app.platform == platform,
139 return self.
filename == other.filename
142 return not self.
__eq__(other)
146 def __init__(self, applist_directories, platform=None):
159 for f
in os.listdir(d):
160 if f.endswith(
".installed"):
161 full_path = os.path.abspath(os.path.join(d, f))
162 installed_files.append(full_path)
163 return installed_files
167 installed_files = files
169 installed_files = self.installed_files.keys()
170 invalid_installed_files = []
172 for f
in installed_files:
181 installed_file.update()
182 app_list.extend(installed_file.get_available_apps(platform=self.
platform))
183 rospy.loginfo(
"%d apps found in %s" % (len(installed_file.available_apps), installed_file.filename))
184 except AppException
as e:
185 rospy.logerr(
"ERROR: %s" % (str(e)))
186 invalid_installed_files.append((f, e))
187 except Exception
as e:
188 rospy.logerr(
"ERROR: %s" % (str(e)))
189 invalid_installed_files.append((f, e))
200 if not os.path.exists(directory):
201 raise IOError(
"applist directory %s does not exist." % directory)
202 if directory
in self.applist_directory:
203 raise RuntimeError(
"applist directory %s already exists" % directory)
204 self.applist_directories.append(directory)
208 if directory
not in self.applist_directory:
209 raise RuntimeError(
"applist directory %s does not in list" % directory)
210 self.applist_directory.remove(directory)
def __init__(self, applist_directories, platform=None)
def add_directory(self, directory)
def _find_installed_files(self)
def AppDefinition_to_App(app_definition)
def remove_directory(self, directory)
def read_Icon_file(filename)
def get_default_applist_directory()
def load_AppDefinition_by_name(appname)
def __init__(self, filename)
def get_available_apps(self, platform=None)