|
26 | 26 | import os
|
27 | 27 | import subprocess
|
28 | 28 | import traceback
|
| 29 | +import urllib2 |
29 | 30 |
|
30 | 31 |
|
31 | 32 | _SUBCOMMANDS = {
|
|
113 | 114 | datalab_component = 'datalab'
|
114 | 115 |
|
115 | 116 |
|
| 117 | +# Public file reporting all known version issues. |
| 118 | +version_issues_url = ( |
| 119 | + 'https://storage.googleapis.com/cloud-datalab/version-issues.js') |
| 120 | + |
| 121 | + |
116 | 122 | try:
|
117 | 123 | with open(os.devnull, 'w') as dn:
|
118 | 124 | subprocess.call(['gcloud', '--version'], stderr=dn, stdout=dn)
|
|
121 | 127 | gcloud_cmd = 'gcloud.cmd'
|
122 | 128 |
|
123 | 129 |
|
| 130 | +def report_known_issues(sdk_version, datalab_version): |
| 131 | + try: |
| 132 | + version_issues_resp = urllib2.urlopen(version_issues_url) |
| 133 | + version_issues = json.loads(version_issues_resp.read()) |
| 134 | + except urllib2.HTTPError as e: |
| 135 | + print('Error downloading the version information: {}'.format(e)) |
| 136 | + return |
| 137 | + |
| 138 | + sdk_issues = version_issues.get(sdk_core_component, {}) |
| 139 | + known_sdk_issues = sdk_issues.get(sdk_version, []) |
| 140 | + if known_sdk_issues: |
| 141 | + print('You are using Cloud SDK version "{}", ' |
| 142 | + 'which has the following known issues:\n\t{}'.format( |
| 143 | + sdk_version, |
| 144 | + '\n\t'.join(known_sdk_issues))) |
| 145 | + datalab_issues = version_issues.get(datalab_component, {}) |
| 146 | + known_datalab_issues = datalab_issues.get(datalab_version, []) |
| 147 | + if known_datalab_issues: |
| 148 | + print('You are using the Datalab CLI version "{}", ' |
| 149 | + 'which has the following known issues:\n\t{}'.format( |
| 150 | + datalab_version, |
| 151 | + '\n\t'.join(known_datalab_issues))) |
| 152 | + return |
| 153 | + |
| 154 | + |
124 | 155 | def add_gcloud_verbosity_flag(args, gcloud_cmd):
|
125 | 156 | """Add the appropriate '---verbosity' flag to the given gcloud command.
|
126 | 157 |
|
@@ -361,6 +392,9 @@ def run():
|
361 | 392 | '\n\tCloud SDK: {}\n\tDatalab: {}'.format(
|
362 | 393 | sdk_version, datalab_version))
|
363 | 394 |
|
| 395 | + if utils.print_warning_messages(args): |
| 396 | + report_known_issues(sdk_version, datalab_version) |
| 397 | + |
364 | 398 | gcloud_zone = ""
|
365 | 399 | if args.subcommand == 'beta':
|
366 | 400 | subcommand = _BETA_SUBCOMMANDS[args.beta_subcommand]
|
|
0 commit comments