38 Implements applist part of app_manager, which handles listing of 39 currently installed applications. 49 from .app
import load_AppDefinition_by_name
50 from .msg
import App, ClientApp, KeyValue, Icon
51 from .exceptions
import AppException, InvalidAppException, NotFoundException
55 Default directory where applist configuration is stored. 57 return "/etc/robot/apps" 61 for k, v
in d.items():
62 l.append(KeyValue(k, str(v)))
67 if filename ==
None or filename ==
"":
69 basename, extension = os.path.splitext(filename)
70 if extension.lower() ==
".jpg" or extension.lower() ==
".jpeg":
72 elif extension.lower() ==
".png":
77 icon.data = open(filename,
"rb").read()
81 a = App(name=app_definition.name, display_name=app_definition.display_name, icon=
read_Icon_file(app_definition.icon))
83 for c
in app_definition.clients:
84 a.client_apps.append(ClientApp(c.client_type,
91 Models data stored in a .installed file. These files are used to 92 track installation of apps. 105 rospack = rospkg.RosPack()
107 installed_data = yaml.load(f)
108 for reqd
in [
'apps']:
109 if not reqd
in installed_data:
111 for app
in installed_data[
'apps']:
112 for areqd
in [
'app']:
116 available_apps.append(
118 except NotFoundException
as e:
121 except Exception
as e:
136 if platform
is not None:
137 available_apps = filter(
138 lambda app: app.platform
in [platform,
'all'],
140 return available_apps
145 return self.
filename == other.filename
148 return not self.
__eq__(other)
152 def __init__(self, applist_directories, platform=None):
165 for f
in os.listdir(d):
166 if f.endswith(
".installed"):
167 full_path = os.path.abspath(os.path.join(d, f))
168 installed_files.append(full_path)
169 return installed_files
173 installed_files = files
176 invalid_installed_files = []
178 for f
in installed_files:
187 installed_file.update()
188 app_list.extend(installed_file.get_available_apps(platform=self.
platform))
189 rospy.loginfo(
"%d apps found in %s" % (len(installed_file.available_apps), installed_file.filename))
190 except AppException
as e:
191 rospy.logerr(
"ERROR: %s" % (str(e)))
192 invalid_installed_files.append((f, e))
193 except Exception
as e:
194 rospy.logerr(
"ERROR: %s" % (str(e)))
195 invalid_installed_files.append((f, e))
212 if not os.path.exists(directory):
213 raise IOError(
"applist directory %s does not exist." % directory)
214 if directory
in self.applist_directory:
215 raise RuntimeError(
"applist directory %s already exists" % directory)
220 if directory
not in self.applist_directory:
221 raise RuntimeError(
"applist directory %s does not in list" % directory)
222 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 load_AppDefinition_by_name(appname, rospack=None)
def remove_directory(self, directory)
def read_Icon_file(filename)
def get_default_applist_directory()
def __init__(self, filename)
def get_available_apps(self, platform=None)