Skip to content

Commit 7b279ff

Browse files
committed
Raise CommandError when there isn't data from the api
Currently it writes to stderr, but the code keeps running and there is an unbound error for `project_data`
1 parent 5bdb2f8 commit 7b279ff

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

readthedocs/projects/management/commands/import_project_from_live.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# -*- coding: utf-8 -*-
2-
31
"""Import project command."""
42

53
import json
64
import os
75

6+
import requests
87
from django.contrib.auth.models import User
98
from django.core.management import call_command
10-
from django.core.management.base import BaseCommand
11-
import requests
9+
from django.core.management.base import BaseCommand, CommandError
1210

1311
from ...models import Project
1412

@@ -57,7 +55,7 @@ def handle(self, *args, **options):
5755
if response_data['count'] == 1:
5856
project_data = response_data['results'][0]
5957
else:
60-
self.stderr.write(
58+
raise CommandError(
6159
'Cannot find {slug} in API. Response was:\n{response}'.format(
6260
slug=slug,
6361
response=json.dumps(response_data),

0 commit comments

Comments
 (0)