

def _get_resource(resource):
    '\n    :param resource: optional filename or http(s) url\n    for the application or group resource\n    :type resource: str\n    :returns: resource\n    :rtype: dict\n    '
    if (resource is not None):
        if os.path.isfile(resource):
            with util.open_file(req) as resource_file:
                return util.load_json(resource_file)
        else:
            try:
                http.silence_requests_warnings()
                req = http.get(resource)
                if (req.status_code == 200):
                    data = b''
                    for chunk in req.iter_content(1024):
                        data += chunk
                    return util.load_jsons(data.decode('utf-8'))
                else:
                    raise Exception
            except Exception:
                logger.exception('Cannot read from resource %s', resource)
                raise DCOSException("Can't read from resource: {0}.\nPlease check that it exists.".format(resource))
    if sys.stdin.isatty():
        raise DCOSException("We currently don't support reading from the TTY. Please specify an application JSON.\nE.g.: dcos marathon app add < app_resource.json")
    return util.load_json(sys.stdin)

dataset/ETHPy150Open dcos/dcos-cli/cli/dcoscli/marathon/main.py _get_resource/VarMisuse@39/109 `resource`->`req`