Exemplo n.º 1
0
    def _parse_info(self, info_file):
        cp = ConfigParser()
        cp.readfp(info_file)

        section = 'Activity'

        if cp.has_option(section, 'bundle_id'):
            self._bundle_id = cp.get(section, 'bundle_id')
        else:
            raise MalformedBundleException(
                'Activity bundle %s does not specify a bundle id' % self._path)

        if cp.has_option(section, 'name'):
            self._name = cp.get(section, 'name')
        else:
            raise MalformedBundleException(
                'Activity bundle %s does not specify a name' % self._path)

        if cp.has_option(section, 'exec'):
            self.bundle_exec = cp.get(section, 'exec')
        else:
            raise MalformedBundleException(
                'Activity bundle %s must specify either class or exec' %
                self._path)

        if cp.has_option(section, 'mime_types'):
            mime_list = cp.get(section, 'mime_types').strip(';')
            self._mime_types = [mime.strip() for mime in mime_list.split(';')]

        if cp.has_option(section, 'show_launcher'):
            if cp.get(section, 'show_launcher') == 'no':
                self._show_launcher = False

        if cp.has_option(section, 'tags'):
            tag_list = cp.get(section, 'tags').strip(';')
            self._tags = [tag.strip() for tag in tag_list.split(';')]

        if cp.has_option(section, 'icon'):
            self._icon = cp.get(section, 'icon')

        if cp.has_option(section, 'activity_version'):
            version = cp.get(section, 'activity_version')
            try:
                NormalizedVersion(version)
            except InvalidVersionError:
                raise MalformedBundleException(
                    'Activity bundle %s has invalid version number %s' %
                    (self._path, version))
            self._activity_version = version

        if cp.has_option(section, 'summary'):
            self._summary = cp.get(section, 'summary')
Exemplo n.º 2
0
    def __init__(self, path, translated=True):
        Bundle.__init__(self, path)
        self.activity_class = None
        self.bundle_exec = None

        self._name = None
        self._icon = None
        self._bundle_id = None
        self._mime_types = None
        self._show_launcher = True
        self._tags = None
        self._activity_version = '0'
        self._summary = None
        self._single_instance = False
        self._max_participants = 0

        info_file = self.get_file('activity/activity.info')
        if info_file is None:
            raise MalformedBundleException('No activity.info file')
        self._parse_info(info_file)

        if translated:
            linfo_file = self._get_linfo_file()
            if linfo_file:
                self._parse_linfo(linfo_file)

        _bundle_instances[path] = self
Exemplo n.º 3
0
    def __init__(self, path):
        Bundle.__init__(self, path)

        self._locale = None
        self._name = None
        self._icon = None
        self._library_version = '0'
        self._activity_start = 'index.html'
        self._global_name = None

        info_file = self.get_file('library/library.info')
        if info_file is None:
            raise MalformedBundleException('No library.info file')
        self._parse_info(info_file)

        if self.get_file(self._activity_start) is None:
            raise MalformedBundleException(
                'Content bundle %s does not have start page %s' %
                (self._path, self._activity_start))
Exemplo n.º 4
0
    def _parse_info(self, info_file):
        cp = ConfigParser()
        cp.readfp(info_file)

        section = 'Library'

        if cp.has_option(section, 'name'):
            self._name = cp.get(section, 'name')
        else:
            raise MalformedBundleException(
                'Content bundle %s does not specify a name' % self._path)

        if cp.has_option(section, 'library_version'):
            version = cp.get(section, 'library_version')
            try:
                NormalizedVersion(version)
            except InvalidVersionError:
                raise MalformedBundleException(
                    'Content bundle %s has invalid version number %s' %
                    (self._path, version))
            self._library_version = version

        if cp.has_option(section, 'locale'):
            self._locale = cp.get(section, 'locale')

        if cp.has_option(section, 'global_name'):
            self._global_name = cp.get(section, 'global_name')

        if cp.has_option(section, 'icon'):
            self._icon = cp.get(section, 'icon')

        # Compatibility with old content bundles
        if self._global_name is not None \
                and cp.has_option(section, 'bundle_class'):
            self._global_name = cp.get(section, 'bundle_class')

        if cp.has_option(section, 'activity_start'):
            self._activity_start = cp.get(section, 'activity_start')

        if self._global_name is None:
            raise MalformedBundleException(
                'Content bundle %s must specify global_name' % self._path)
Exemplo n.º 5
0
 def _read_metadata(self, bundle_dir):
     metadata_path = os.path.join(bundle_dir, '_metadata.json')
     if not os.path.exists(metadata_path):
         raise MalformedBundleException(
             'Bundle must contain the file "_metadata.json"')
     f = open(metadata_path, 'r')
     try:
         json_data = f.read()
     finally:
         f.close()
     return json.loads(json_data)
Exemplo n.º 6
0
    def _parse_info(self, info_file):
        cp = ConfigParser()
        cp.readfp(info_file)

        section = 'Activity'

        if cp.has_option(section, 'bundle_id'):
            self._bundle_id = cp.get(section, 'bundle_id')
        else:
            if cp.has_option(section, 'service_name'):
                self._bundle_id = cp.get(section, 'service_name')
                logging.error('ATTENTION: service_name property in the '
                              'activity.info file is deprecated, should be '
                              ' changed to bundle_id')
            else:
                raise MalformedBundleException(
                    'Activity bundle %s does not specify a bundle id' %
                    self._path)

        if ' ' in self._bundle_id:
            raise MalformedBundleException('Space in bundle_id')

        if cp.has_option(section, 'name'):
            self._name = cp.get(section, 'name')
        else:
            raise MalformedBundleException(
                'Activity bundle %s does not specify a name' % self._path)

        if cp.has_option(section, 'exec'):
            self.bundle_exec = cp.get(section, 'exec')
        else:
            raise MalformedBundleException(
                'Activity bundle %s must specify either class or exec' %
                self._path)

        if cp.has_option(section, 'mime_types'):
            mime_list = cp.get(section, 'mime_types').strip(';')
            self._mime_types = [mime.strip() for mime in mime_list.split(';')]

        if cp.has_option(section, 'show_launcher'):
            if cp.get(section, 'show_launcher') == 'no':
                self._show_launcher = False

        if cp.has_option(section, 'tags'):
            tag_list = cp.get(section, 'tags').strip(';')
            self._tags = [tag.strip() for tag in tag_list.split(';')]

        if cp.has_option(section, 'icon'):
            self._icon = cp.get(section, 'icon')

        if cp.has_option(section, 'activity_version'):
            version = cp.get(section, 'activity_version')
            try:
                NormalizedVersion(version)
            except InvalidVersionError:
                raise MalformedBundleException(
                    'Activity bundle %s has invalid version number %s' %
                    (self._path, version))
            self._activity_version = version

        if cp.has_option(section, 'summary'):
            self._summary = cp.get(section, 'summary')

        if cp.has_option(section, 'single_instance'):
            if cp.get(section, 'single_instance') == 'yes':
                self._single_instance = True

        if cp.has_option(section, 'max_participants'):
            max_participants = cp.get(section, 'max_participants')
            try:
                self._max_participants = int(max_participants)
            except ValueError:
                raise MalformedBundleException(
                    'Activity bundle %s has invalid max_participants %s' %
                    (self._path, max_participants))