Example #1
0
    def _sanity_check(self):
        """Check to see if the current directory matches what is created by PblProjectCreator.run.

        Raises an InvalidProjectException or an OutdatedProjectException if everything isn't quite right.
        """

        if self.project_type not in ('native', 'package'):
            if self.project_type == 'pebblejs':
                raise InvalidProjectException(
                    "Pebble.js is not part of the pebble SDK, and so the SDK can't build it.\n"
                    "Either use CloudPebble or follow the instructions at "
                    "https://github.com/pebble/pebblejs/blob/master/README.md#getting-started"
                )
            else:
                raise InvalidProjectException(
                    "Unsupported project type '%s'." % self.project_type)

        if os.path.islink(os.path.join(self.project_dir, 'pebble_app.ld')) \
                or os.path.exists(os.path.join(self.project_dir, 'resources/src/resource_map.json')) \
                or not os.path.exists(os.path.join(self.project_dir, 'wscript')):
            raise OutdatedProjectException(
                "This project is very outdated, and cannot be handled by this SDK."
            )

        if self.sdk_version != SDK_VERSION:
            if sdk_version() != '2.9':
                raise OutdatedProjectException(
                    "This projected is outdated (try 'pebble convert-project' or"
                    "'pebble sdk install 2.9')")
Example #2
0
    def check_project_directory(project_dir):
        """Check to see if the current directory matches what is created by PblProjectCreator.run.

        Raises an InvalidProjectException or an OutdatedProjectException if everything isn't quite right.
        """

        if not os.path.isdir(os.path.join(project_dir, 'src')):
            raise InvalidProjectException("This is not a project directory.")

        try:
            with open(os.path.join(project_dir, "appinfo.json"), "r") as f:
                try:
                    app_info = json.load(f)
                except ValueError as ex:
                    raise InvalidJSONException(
                        "Could not parse appinfo.json because of the following error: %s"
                        % ex)
        except IOError:
            raise InvalidProjectException("Couldn't open project info.")

        if os.path.islink(os.path.join(project_dir, 'pebble_app.ld')) \
                or os.path.exists(os.path.join(project_dir, 'resources/src/resource_map.json')) \
                or not os.path.exists(os.path.join(project_dir, 'wscript')):
            raise OutdatedProjectException(
                "This project is very outdated, and cannot be handled by this SDK."
            )
        if app_info.get("sdkVersion", None) != SDK_VERSION:
            if sdk_version() != '2.9':
                raise OutdatedProjectException(
                    "This projected is outdated (try 'pebble convert-project' or"
                    "'pebble sdk install 2.9')")
Example #3
0
    def _parse_project(self):
        with open(os.path.join(self.project_dir, 'package.json')) as f:
            self.project_info = json.load(f)

        self.appinfo = self.project_info['pebble']
        self.short_name = self.project_info['name']
        self.company_name = self.project_info['author']
        self.version = self.project_info['version']
        self.sdk_version = self.appinfo.get('sdkVersion', 2)
        self.target_platforms = self.appinfo.get('targetPlatforms', pebble_platforms)
        self.enable_multi_js = self.appinfo.get('enableMultiJS', False)
        self.capabilities = self.appinfo.get('capabilities', [])
        self.project_type = self.appinfo.get('projectType', 'native')
        self.dependencies = self.project_info.get('dependencies', {})
        self.dependencies.update(self.project_info.get('devDependencies', {}))
        self.resources = self.appinfo.get('resources', {})
        self.message_keys = self.appinfo.get('messageKeys', {})
        if self.project_type != 'package':
            if 'uuid' not in self.appinfo:
                raise InvalidProjectException("This project doesn't have a UUID, but appears to be an app. "
                                              "Did you miss a 'projectType'?")
            self.long_name = self.appinfo.get('displayName', self.short_name)
            self.uuid = uuid.UUID(self.appinfo['uuid'])
            watchapp = self.appinfo.get('watchapp', {})
            self.is_watchface = watchapp.get('watchface', False)
            self.is_hidden = watchapp.get('hiddenApp', False)
            self.is_shown_only_on_communication = watchapp.get('onlyShownOnCommunication', False)
        else:
            self.uuid = None
            self.is_watchface = False
            self.is_hidden = False
            self.is_shown_only_on_communication = False
            self.long_name = self.short_name
Example #4
0
    def check_project_directory(project_dir):
        """Check to see if the current directory matches what is created by PblProjectCreator.run.

        Raises an InvalidProjectException or an OutdatedProjectException if everything isn't quite right.
        """

        if not os.path.isdir(os.path.join(project_dir, 'src')):
            raise InvalidProjectException("This is not a project directory.")

        try:
            with open(os.path.join(project_dir, "appinfo.json"), "r") as f:
                try:
                    json.load(f)
                except ValueError as e:
                    raise InvalidJSONException("Could not parse appinfo.json: %s" % e)
        except IOError:
            raise InvalidProjectException("Couldn't open project info.")
Example #5
0
    def check_project_directory(project_dir):
        """Check to see if the current directory matches what is created by PblProjectCreator.run.

        Raises an InvalidProjectException or an OutdatedProjectException if everything isn't quite right.
        """

        try:
            with open(os.path.join(project_dir, "package.json"), "r") as f:
                try:
                    app_info = json.load(f)
                except ValueError as e:
                    raise InvalidJSONException("Could not parse package.json: %s" % ex)
                if 'pebble' not in app_info:
                    raise InvalidProjectException("package.json doesn't have a 'pebble' key.")
        except IOError:
            if not os.path.isdir(os.path.join(project_dir, 'src')):
                raise InvalidProjectException("This is not a project directory.")
            raise InvalidProjectException("Couldn't open project info.")