Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c4010d5

Browse filesBrowse files
author
daniel
committed
Fix KeyError exception when project has no logs
1 parent c7a3957 commit c4010d5
Copy full SHA for c4010d5

File tree

Expand file treeCollapse file tree

1 file changed

+4
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-0
lines changed

‎cloud_logging/api/list_logs.py

Copy file name to clipboardExpand all lines: cloud_logging/api/list_logs.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
# [START all]
2727
import argparse
28+
import sys
2829

2930
from googleapiclient import discovery
3031
from oauth2client.client import GoogleCredentials
@@ -36,6 +37,9 @@ def list_logs(project_id, logging_service):
3637

3738
while request:
3839
response = request.execute()
40+
if len(response)==0:
41+
print "No logs found in project {0}".format(project_id)
42+
sys.exit(1)
3943
for log in response['logs']:
4044
print(log['name'])
4145

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.