Uh oh!
There was an error while loading. Please reload this page.
Get project ID from JSON credentials file - #1813
Conversation
jgeewax
commented
May 23, 2016
Do we have tests that make sure the In other words, we need to follow the same policy of grabbing project IDs, trying the following in order to grab project ID from...
(I think that's the right order at least...) |
| import os | ||
| import tempfile | ||
| with tempfile.NamedTemporaryFile() as credential_file: | ||
| credential_file.write('{"project_id": "test-project-id"}') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
daspecster
commented
May 23, 2016
To get this to work with the happy path that @jgeewax mentioned( |
dhermes
commented
May 23, 2016
I'm not sure. @jgeewax do we have a As for putting it with |
daspecster
commented
May 23, 2016
I can do the Ok cool, thanks @dhermes! I'll make a configuration doc. |
170dc66 to
5125599Compare| :rtype: str or ``NoneType`` | ||
| :returns: Project-ID from ``gcloud info`` else ``None`` | ||
| """ | ||
| command = subprocess.Popen(['gcloud info'], |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
daspecster
commented
May 27, 2016
@dhermes@tseaver@jonparrott |
dhermes
commented
May 27, 2016
Not sure either.
$ cat keyfile.json
{
"type": "service_account",
"project_id": "PROJECT",
"private_key_id": "...",
"private_key": "-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----\n",
"client_email": "foo@PROJECT.iam.gserviceaccount.com",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/foo%40PROJECT.iam.gserviceaccount.com"
} |
daspecster
commented
May 27, 2016
@dhermes, so the only issue with grabbing it from Also, is that default file location the same for windows and linux both? I saw
So I wasn't sure what the story was there. But I think using _get_well_known_file might be the best option if it works after |
@daspecster There should be a cascade of checks here just like there is for credentials. (i.e. so the absence of |
43157db to
4c686beCompareAlso using |
daspecster
commented
May 27, 2016
Also, if I look back at #1792, the flow that happened there, I can add that to the list of places to check but I think we're back to pulling it from the |
dhermes
commented
May 27, 2016
The current project-check cascade is:
I'm suggesting you inject two more checks in there (not sure about the order yet):
For reference the cascade for credentials is:
|
daspecster
commented
May 27, 2016
Ok I will do that! Thanks again @dhermes! |
daspecster
commented
Jun 7, 2016
| >>> from gcloud import bigquery | ||
| >>> client = bigquery.Client() | ||
| - :class:`Client <gcloud.client.Client>` objects hold both a ``project`` |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
8c3b234 to
d7b1951Comparedaspecster
commented
Jun 14, 2016
tseaver
commented
Jun 14, 2016
Sorry, I was AFK waiting on a contractor. Looking this evening. |
| (?P<nanos>\d{1,9}) # nanoseconds, maybe truncated | ||
| Z # Zulu | ||
| """, re.VERBOSE) | ||
| DEFAULT_CONFIGURATION_PATH = '~/.config/gcloud/configurations/config_default' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tseaver
commented
Jun 15, 2016
LGTM whichever way you answer my question about passing the Windows config path in addition to the Unix-y one. |
daspecster
commented
Jun 15, 2016
@tseaver I added it! win32_config_path=os.path.join(os.getenv('APPDATA', ''),
'gcloud\configurations\config_default')I don't have a windows machine to test on though. Is there a way that we test gcloud-python on windows in general? |
tseaver
commented
Jun 15, 2016
@daspecster pylint doesn't like your backsplashes. I believe you could use forward-slashes there.
We could look (again) into adding Appveyor CI. |
63444c2 to
3f408c1Compare@tseaver I think I got it this time! I just let python pick the slashes. win32_config_path=os.path.join(os.getenv('APPDATA', ''),
'gcloud', 'configurations',
'config_default') |
daspecster
commented
Jun 15, 2016
@tseaver if this looks good to you, I'll merge. |
tseaver
commented
Jun 16, 2016
LGTM |
dhermes
commented
Jun 16, 2016
@tseaver RE: AppVeyor, we've had a build running for 4+ months. I can add you guys as admins if needed. |
* chore: update owners * remove yoshi
This commit introduces unit tests for the `get_uid_stream` method in the `SequentialUIDGenerator` class. Fixes internal issue 416487613 Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This is a possible resolution to #1792, making it easier to follow along with the documentation.
I looked for a way to clarify the documentation for this but it looks like this should make it work in the way that the documentation shows already.