Skip to content
This repository has been 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

Open
dwy6626 opened this issue May 17, 2021 · 0 comments

Comments

@dwy6626
Copy link

dwy6626 commented May 17, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant