Exemple #1
0
    def get_resource_from_properties(properties):
        """
        :param properties: JSON items in the form key=value
        :type properties: [str]
        :returns: resource JSON
        :rtype: dict
        """

        if len(properties) == 0:
            example =\
                "E.g. dcos marathon app update your-app-id < app_update.json"
            ResourceReader._assert_no_tty(example)

            return util.load_jsons(sys.stdin.read())

        resource_json = {}
        for prop in properties:
            key, value = jsonitem.parse_json_item(prop, None)

            key = jsonitem.clean_value(key)
            if key in resource_json:
                raise DCOSException(
                    'Key {!r} was specified more than once'.format(key))

            resource_json[key] = value
        return resource_json
Exemple #2
0
def _parse_properties(properties):
    """
    :param properties: JSON items in the form key=value
    :type properties: [str]
    :returns: resource JSON
    :rtype: dict
    """

    if len(properties) == 0:
        if sys.stdin.isatty():
            # We don't support TTY right now. In the future we will start an
            # editor
            raise DCOSException(
                "We currently don't support reading from the TTY. Please "
                "specify an application JSON.\n"
                "E.g. dcos marathon app update your-app-id < app_update.json")
        else:
            return util.load_jsons(sys.stdin.read())

    resource_json = {}
    for prop in properties:
        key, value = jsonitem.parse_json_item(prop, None)

        key = jsonitem.clean_value(key)
        if key in resource_json:
            raise DCOSException(
                'Key {!r} was specified more than once'.format(key))

        resource_json[key] = value
    return resource_json
Exemple #3
0
    def get_resource_from_properties(properties):
        """
        :param properties: JSON items in the form key=value
        :type properties: [str]
        :returns: resource JSON
        :rtype: dict
        """

        if len(properties) == 0:
            example =\
                "E.g. dcos marathon app update your-app-id < app_update.json"
            ResourceReader._assert_no_tty(example)

            return util.load_jsons(sys.stdin.read())

        resource_json = {}
        for prop in properties:
            key, value = jsonitem.parse_json_item(prop, None)

            key = jsonitem.clean_value(key)
            if key in resource_json:
                raise DCOSException(
                    'Key {!r} was specified more than once'.format(key))

            resource_json[key] = value
        return resource_json