Skip to content

Commit 2800ce6

Browse files
author
Glenn Snyder
authored
Merge pull request #107 from ericyame/fix-int
Add error handling in case the projects are not in Hub server
2 parents e7ce002 + 99ed7f3 commit 2800ce6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

examples/delete_projects.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@
3535
print("Projects in maintain json file: ", d['clean_project'])
3636
for proj in d['clean_project']:
3737
now = arrow.now()
38-
clean_time = now.to('local').shift(days=-args.age)
38+
clean_time = now.to('local').shift(days=-int(args.age))
3939
project = hub.get_project_by_name(proj)
40+
if not project:
41+
print("Project", proj, "doesn't exist in server. Skip.")
42+
continue
4043

4144
if clean_time > arrow.get(project['createdAt']).to('local'):
4245
print("Project ", project['name'], ' last for more than 3 days. Will be backup abd deleted.')

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ twine
1818

1919
#For some reporting libraries
2020
pandas
21+
22+
# For easy date/time operations
23+
arrow

0 commit comments

Comments
 (0)