Skip to content

Commit fd084d5

Browse files
committed
Fixing lint error in system test scripts.
Also making pep8_on_repo exit with the correct status code. This was a bug introduced in googleapis#1348.
1 parent 6f0b59d commit fd084d5

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

scripts/pep8_on_repo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import os
2323
import subprocess
24+
import sys
2425

2526

2627
def main():
@@ -32,7 +33,8 @@ def main():
3233
python_files = python_files.strip().split()
3334

3435
pep8_command = ['pep8'] + python_files
35-
subprocess.call(pep8_command)
36+
status_code = subprocess.call(pep8_command)
37+
sys.exit(status_code)
3638

3739

3840
if __name__ == '__main__':

system_tests/clear_datastore.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
'Post',
3434
]
3535
TRANSACTION_MAX_GROUPS = 5
36-
if os.getenv('GCLOUD_NO_PRINT') == 'true':
37-
PRINT_FUNC = lambda msg: None
38-
else:
39-
PRINT_FUNC = print
36+
37+
38+
def print_func(message):
39+
if os.getenv('GCLOUD_NO_PRINT') != 'true':
40+
print(message)
4041

4142

4243
def fetch_keys(kind, client, fetch_max=FETCH_MAX, query=None, cursor=None):
@@ -72,8 +73,8 @@ def remove_kind(kind, client):
7273
delete_outside_transaction = False
7374
with client.transaction():
7475
# Now that we have all results, we seek to delete.
75-
PRINT_FUNC('Deleting keys:')
76-
PRINT_FUNC(results)
76+
print_func('Deleting keys:')
77+
print_func(results)
7778

7879
ancestors = get_ancestors(results)
7980
if len(ancestors) > TRANSACTION_MAX_GROUPS:
@@ -94,10 +95,11 @@ def remove_all_entities(client=None):
9495

9596

9697
if __name__ == '__main__':
97-
PRINT_FUNC('This command will remove all entities for the following kinds:')
98-
PRINT_FUNC('\n'.join(['- ' + val for val in ALL_KINDS]))
98+
print_func('This command will remove all entities for '
99+
'the following kinds:')
100+
print_func('\n'.join(['- ' + val for val in ALL_KINDS]))
99101
response = input('Is this OK [y/n]? ')
100102
if response.lower() == 'y':
101103
remove_all_entities()
102104
else:
103-
PRINT_FUNC('Doing nothing.')
105+
print_func('Doing nothing.')

system_tests/populate_datastore.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
from gcloud.environment_vars import TESTS_DATASET
2626

2727

28-
if os.getenv('GCLOUD_NO_PRINT') == 'true':
29-
PRINT_FUNC = lambda msg: None
30-
else:
31-
PRINT_FUNC = print
32-
3328
ANCESTOR = ('Book', 'GoT')
3429
RICKARD = ANCESTOR + ('Character', 'Rickard')
3530
EDDARD = RICKARD + ('Character', 'Eddard')
@@ -88,6 +83,11 @@
8883
]
8984

9085

86+
def print_func(message):
87+
if os.getenv('GCLOUD_NO_PRINT') != 'true':
88+
print(message)
89+
90+
9191
def add_characters(client=None):
9292
if client is None:
9393
# Get a client that uses the test dataset.
@@ -100,7 +100,7 @@ def add_characters(client=None):
100100
entity = datastore.Entity(key=client.key(*key_path))
101101
entity.update(character)
102102
xact.put(entity)
103-
PRINT_FUNC('Adding Character %s %s' % (character['name'],
103+
print_func('Adding Character %s %s' % (character['name'],
104104
character['family']))
105105

106106

0 commit comments

Comments
 (0)