Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Cannot display subprocess error, but show TypeError: write() argument must be str, not bytes #2178

@dwy6626

Description

@dwy6626

in #2157, user without compute.instances.list permission run the following command

datalab connect instance-name

will get error:

write() argument must be str, not bytes

When run with --verbosity debug flag, I get errors:

Traceback (most recent call last):
  File "/usr/lib/google-cloud-sdk/platform/datalab-cli/commands/utils.py", line 304, in describe_instance
    gcloud_compute(args, get_cmd, stdout=stdout, stderr=stderr)
  File "/usr/bin/../lib/google-cloud-sdk/platform/datalab-cli/datalab.py", line 201, in gcloud_compute
    cmd, stdin=stdin, stdout=stdout, stderr=stderr)
  File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gcloud', 'compute', '--verbosity=debug', 'instances', 'describe', '--quiet', '--format', 'json(status,tags.items,metadata.items,disks[].licenses)', 'instance-name']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/google-cloud-sdk/platform/datalab-cli/commands/utils.py", line 304, in describe_instance
    gcloud_compute(args, get_cmd, stdout=stdout, stderr=stderr)
  File "/usr/bin/../lib/google-cloud-sdk/platform/datalab-cli/datalab.py", line 201, in gcloud_compute
    cmd, stdin=stdin, stdout=stdout, stderr=stderr)
  File "/usr/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['gcloud', 'compute', '--verbosity=debug', 'instances', 'describe', '--quiet', '--zone', 'us-west1-a', '--format', 'json(status,tags.items,metadata.items,disks[].licenses)', 'instance-name']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/../lib/google-cloud-sdk/platform/datalab-cli/datalab.py", line 434, in run
    sdk_version=sdk_version, datalab_version=datalab_version)
  File "/usr/lib/google-cloud-sdk/platform/datalab-cli/commands/connect.py", line 382, in run
    args, gcloud_compute, instance)
  File "/usr/lib/google-cloud-sdk/platform/datalab-cli/commands/utils.py", line 322, in describe_instance
    args, gcloud_compute, instance)
  File "/usr/lib/google-cloud-sdk/platform/datalab-cli/commands/utils.py", line 316, in describe_instance
    sys.stderr.write(stderr.read())
TypeError: write() argument must be str, not bytes
write() argument must be str, not bytes

Environment:

GCP cloud shell with python 3.7.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions