app_list.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # License: BSD
00004 #   https://raw.github.com/robotics-in-concert/rocon_app_platform/master/rocon_appmanager/LICENSE
00005 #
00006 ##############################################################################
00007 # Overview
00008 ##############################################################################
00009 '''
00010  App lists store the apps that are being managed by the app manager. These
00011  can be preinstalled, installed or available apps from an app store.
00012 
00013  Note: very much a work in progress (not currently used). Pull code from our
00014  old willow app manager:
00015 
00016  https://github.com/robotics-in-concert/rocon_linux_app_platform/blob/master/willow_app_manager/src/willow_app_manager/app_list.py
00017 '''
00018 ##############################################################################
00019 # Imports
00020 ##############################################################################
00021 
00022 import os
00023 import rospy
00024 import yaml
00025 from .app import App
00026 
00027 ##############################################################################
00028 # Class
00029 ##############################################################################
00030 
00031 
00032 class AppListFile(object):
00033     """
00034     Models data stored in a .apps file.  These files are used to
00035     track apps available for the app manager. The apps file is
00036     just a single key 'apps' containing a list of 'xxx/yyy' strings
00037     where 'xxx' represents the package name and 'yyy' is the app name.
00038     """
00039 
00040     def __init__(self, filename):
00041         '''
00042           Just configures the container with basic parameters.
00043 
00044           @param filename : file path to the .apps file.
00045           @type str
00046         '''
00047         self.filename = filename
00048         self.available_apps = []
00049         self._file_mtime = None
00050         self.update()
00051 
00052     def _load(self):
00053         available_apps = []
00054         rospy.loginfo("App Manager : loading apps file [%s]" % self.filename)
00055         with open(self.filename) as f:
00056             apps_yaml = yaml.load(f)
00057             if not 'apps' in apps_yaml:
00058                 rospy.logerr("App Manager : apps file [%s] is missing required key [%s]" % (self.filename, 'apps'))
00059             for app_resource_name in apps_yaml['apps']:
00060                 app = App(app_resource_name)
00061                 available_apps.append(app)
00062         self.available_apps = available_apps
00063 
00064     def update(self):
00065         """
00066         Update app list
00067         """
00068         s = os.stat(self.filename)
00069         if s.st_mtime != self._file_mtime:
00070             self._load()
00071             self._file_mtime = s.st_mtime
00072 
00073 
00074 class AppList(object):
00075 
00076     def __init__(self, applist_directories):
00077         self._applist_directories = applist_directories
00078         self.installed_files = {}
00079         self.invalid_installed_files = []
00080         self.app_list = []
00081 
00082         self._applist_directory_mtime = None
00083         self.update()
00084 
00085     def add_directory(self, directory):
00086         self._applist_directories.append(directory)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


rocon_appmanager
Author(s): Jihoon
autogenerated on Tue Jan 22 2013 12:59:53