9
9
from .models import AIP
10
10
from .models import Report
11
11
12
-
13
12
UNABLE_TO_CONNECT_ERROR = (
14
13
"Unable to connect to storage service instance at {} (is it running?)"
15
14
)
@@ -43,27 +42,19 @@ def _get_aips(ss_url, ss_user, ss_key, uri=None):
43
42
44
43
if response .status_code == 500 :
45
44
raise StorageServiceError (
46
- 'Storage service at "{}" encountered an internal error while requesting AIPs' .format (
47
- ss_url
48
- )
45
+ f'Storage service at "{ ss_url } " encountered an internal error while requesting AIPs'
49
46
)
50
47
elif response .status_code == 504 :
51
48
raise StorageServiceError (
52
- 'Storage service at "{}" encountered a gateway timeout while requesting AIPs' .format (
53
- ss_url
54
- )
49
+ f'Storage service at "{ ss_url } " encountered a gateway timeout while requesting AIPs'
55
50
)
56
51
elif response .status_code == 401 :
57
52
raise StorageServiceError (
58
- 'Storage service at "{}" failed authentication while requesting AIPs' .format (
59
- ss_url
60
- )
53
+ f'Storage service at "{ ss_url } " failed authentication while requesting AIPs'
61
54
)
62
55
elif response .status_code != 200 :
63
56
raise StorageServiceError (
64
- 'Storage service at "{}" returned {} while requesting AIPs' .format (
65
- ss_url , response .status_code
66
- )
57
+ f'Storage service at "{ ss_url } " returned { response .status_code } while requesting AIPs'
67
58
)
68
59
69
60
results = response .json ()
@@ -113,27 +104,19 @@ def get_single_aip(uuid, ss_url, ss_user, ss_key):
113
104
114
105
if response .status_code == 500 :
115
106
raise StorageServiceError (
116
- 'Storage service at "{}" encountered an internal error while requesting AIP with UUID {}' .format (
117
- ss_url , uuid
118
- )
107
+ f'Storage service at "{ ss_url } " encountered an internal error while requesting AIP with UUID { uuid } '
119
108
)
120
109
elif response .status_code == 504 :
121
110
raise StorageServiceError (
122
- 'Storage service at "{}" encounterd a gateway timeout while requesting AIP with UUID {}' .format (
123
- ss_url , uuid
124
- )
111
+ f'Storage service at "{ ss_url } " encounterd a gateway timeout while requesting AIP with UUID { uuid } '
125
112
)
126
113
elif response .status_code == 401 :
127
114
raise StorageServiceError (
128
- 'Storage service at "{}" failed authentication while requesting AIP with UUID {}' .format (
129
- ss_url , uuid
130
- )
115
+ f'Storage service at "{ ss_url } " failed authentication while requesting AIP with UUID { uuid } '
131
116
)
132
117
if response .status_code != 200 :
133
118
raise StorageServiceError (
134
- 'Storage service at "{}" returned {} while requesting AIP with UUID {}' .format (
135
- ss_url , response .status_code , uuid
136
- )
119
+ f'Storage service at "{ ss_url } " returned { response .status_code } while requesting AIP with UUID { uuid } '
137
120
)
138
121
return response .json ()
139
122
@@ -219,9 +202,7 @@ def scan_aip(
219
202
}
220
203
report = create_report (aip , None , begun , ended , json .dumps (json_report ))
221
204
raise StorageServiceError (
222
- 'A fixity scan could not be started for the AIP with uuid "{}"' .format (
223
- aip .uuid
224
- ),
205
+ f'A fixity scan could not be started for the AIP with uuid "{ aip .uuid } "' ,
225
206
report = report ,
226
207
)
227
208
if response .status_code == 500 :
@@ -233,9 +214,7 @@ def scan_aip(
233
214
}
234
215
report = create_report (aip , None , begun , ended , json .dumps (json_report ))
235
216
raise StorageServiceError (
236
- 'Storage service at "{}" encountered an internal error while scanning AIP {}' .format (
237
- ss_url , aip .uuid
238
- ),
217
+ f'Storage service at "{ ss_url } " encountered an internal error while scanning AIP { aip .uuid } ' ,
239
218
report = report ,
240
219
)
241
220
if response .status_code == 401 :
@@ -247,9 +226,7 @@ def scan_aip(
247
226
}
248
227
report = create_report (aip , None , begun , ended , json .dumps (json_report ))
249
228
raise StorageServiceError (
250
- 'Storage service at "{}" failed authentication while scanning AIP {}' .format (
251
- ss_url , aip .uuid
252
- ),
229
+ f'Storage service at "{ ss_url } " failed authentication while scanning AIP { aip .uuid } ' ,
253
230
report = report ,
254
231
)
255
232
if response .status_code != 200 :
@@ -261,9 +238,7 @@ def scan_aip(
261
238
}
262
239
report = create_report (aip , None , begun , ended , json .dumps (json_report ))
263
240
raise StorageServiceError (
264
- 'Storage service at "{}" returned {} while scanning AIP {}' .format (
265
- ss_url , response .status_code , aip .uuid
266
- ),
241
+ f'Storage service at "{ ss_url } " returned { response .status_code } while scanning AIP { aip .uuid } ' ,
267
242
report = report ,
268
243
)
269
244
0 commit comments