Skip to content

Commit fb7e543

Browse files
author
Sophie Fitzpatrick
committed
error fixing
1 parent 5a97117 commit fb7e543

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

marvelcli/project/project_commands.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,15 +149,18 @@ def get_personal_projects(auth: str):
149149
"""List all projects owned by you"""
150150
query = project_queries.get_all_personal_projects_query
151151
r, json_data = utils.make_request(auth, query)
152-
data = json_data['data']['user']['projects']['edges']
153152

154-
urls = []
155-
for d in data:
156-
url = d['node']['prototypeUrl']
157-
urls.append(url)
153+
if r.status_code != 200:
154+
click.echo('\n' + 'Your personal projects could not be returned at this time."' + '\n')
155+
else:
156+
data = json_data['data']['user']['projects']['edges']
157+
urls = []
158+
for d in data:
159+
url = d['node']['prototypeUrl']
160+
urls.append(url)
158161

159-
project_count = len(json_data['data']['user']['projects']['edges'])
160-
click.echo('\nYou have %s project(s)' % project_count)
162+
project_count = len(json_data['data']['user']['projects']['edges'])
163+
click.echo('\nYou have %s project(s)' % project_count)
161164

162-
for url in urls:
163-
click.echo(url)
165+
for url in urls:
166+
click.echo(url)

marvelcli/user/user_commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def about_user(auth: str):
4646
query = user_queries.about_user_query
4747
r, json_data = utils.make_request(auth, query)
4848

49-
user = json_data['data']['user']
50-
last_active = user['lastActiveAt']
51-
last_active = datetime.datetime(int(last_active[0:4]), int(last_active[5:7]), int(last_active[8:10]), 0, 0)
52-
5349
if r.status_code != 200:
5450
click.echo("\nWe could not retrieve the data at this time, possibly due to a ratelimit. Try again in a few minutes\n")
5551
else:
52+
user = json_data['data']['user']
53+
last_active = user['lastActiveAt']
54+
last_active = datetime.datetime(int(last_active[0:4]), int(last_active[5:7]), int(last_active[8:10]), 0, 0)
55+
5656
click.echo(utils.colour.BOLD + '\nYour Account: \n' + utils.colour.END)
5757
click.echo('Email: %s' % user['email'])
5858
click.echo('Last Active: %s' % last_active)

0 commit comments

Comments
 (0)