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.items():
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 available_apps = filter(
134 lambda app: app.platform
in [platform,
'all'],
136 return available_apps
141 return self.
filename == other.filename
144 return not self.
__eq__(other)
148 def __init__(self, applist_directories, platform=None):
161 for f
in os.listdir(d):
162 if f.endswith(
".installed"):
163 full_path = os.path.abspath(os.path.join(d, f))
164 installed_files.append(full_path)
165 return installed_files
169 installed_files = files
171 installed_files = self.installed_files.keys()
172 invalid_installed_files = []
174 for f
in installed_files:
183 installed_file.update()
184 app_list.extend(installed_file.get_available_apps(platform=self.
platform))
185 rospy.loginfo(
"%d apps found in %s" % (len(installed_file.available_apps), installed_file.filename))
186 except AppException
as e:
187 rospy.logerr(
"ERROR: %s" % (str(e)))
188 invalid_installed_files.append((f, e))
189 except Exception
as e:
190 rospy.logerr(
"ERROR: %s" % (str(e)))
191 invalid_installed_files.append((f, e))
202 if not os.path.exists(directory):
203 raise IOError(
"applist directory %s does not exist." % directory)
204 if directory
in self.applist_directory:
205 raise RuntimeError(
"applist directory %s already exists" % directory)
206 self.applist_directories.append(directory)
210 if directory
not in self.applist_directory:
211 raise RuntimeError(
"applist directory %s does not in list" % directory)
212 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)