@@ -42,8 +42,9 @@ def get_repos(logger, project, uri, headers=None, timeout=None):
42
42
urllib .parse .quote_plus (project ),
43
43
'repositories' ),
44
44
headers = headers , timeout = timeout )
45
- except Exception :
46
- logger .error ('could not get repositories for ' + project )
45
+ except Exception as e :
46
+ logger .error ("could not get repositories for project '{}': {}" .
47
+ format (project , e ))
47
48
return None
48
49
49
50
ret = []
@@ -63,9 +64,9 @@ def get_config_value(logger, name, uri, headers=None, timeout=None):
63
64
r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'configuration' ,
64
65
urllib .parse .quote_plus (name )),
65
66
headers = headers , timeout = timeout )
66
- except Exception :
67
+ except Exception as e :
67
68
logger .error ("Cannot get the '{}' config value from the web "
68
- "application on {}" .format (name , uri ))
69
+ "application: {}" .format (name , e ))
69
70
return None
70
71
71
72
return r .text
@@ -89,9 +90,9 @@ def set_config_value(logger, name, value, uri, headers=None, timeout=None):
89
90
local_headers ['Content-type' ] = 'application/text'
90
91
do_api_call ('PUT' , get_uri (uri , 'api' , 'v1' , 'configuration' , name ),
91
92
data = value , headers = local_headers , timeout = timeout )
92
- except Exception :
93
+ except Exception as e :
93
94
logger .error ("Cannot set the '{}' config field to '{}' from the web "
94
- "application on {}" .format (name , value , uri ))
95
+ "application: {}" .format (name , value , e ))
95
96
return False
96
97
97
98
return True
@@ -109,9 +110,9 @@ def get_repo_type(logger, repository, uri, headers=None, timeout=None):
109
110
r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'repositories' ,
110
111
'property' , 'type' ), params = payload ,
111
112
headers = headers , timeout = None )
112
- except Exception :
113
- logger .error (' could not get repository type for {} from web'
114
- ' application on {}' .format (repository , uri ))
113
+ except Exception as e :
114
+ logger .error (" could not get repository type for '{}' from web"
115
+ " application: {}" .format (repository , e ))
115
116
return None
116
117
117
118
line = r .text
@@ -124,9 +125,9 @@ def get_configuration(logger, uri, headers=None, timeout=None):
124
125
try :
125
126
r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'configuration' ),
126
127
headers = headers , timeout = timeout )
127
- except Exception :
128
- logger .error ('could not get configuration from web application on {}' .
129
- format (uri ))
128
+ except Exception as e :
129
+ logger .error ('could not get configuration from web application: {}' .
130
+ format (e ))
130
131
return None
131
132
132
133
return r .text
@@ -136,9 +137,9 @@ def set_configuration(logger, configuration, uri, headers=None, timeout=None):
136
137
try :
137
138
do_api_call ('PUT' , get_uri (uri , 'api' , 'v1' , 'configuration' ),
138
139
data = configuration , headers = headers , timeout = timeout )
139
- except Exception :
140
- logger .error ('could not set configuration for web application on {}' .
141
- format (uri ))
140
+ except Exception as e :
141
+ logger .error ('could not set configuration to web application: {}' .
142
+ format (e ))
142
143
return False
143
144
144
145
return True
@@ -149,9 +150,9 @@ def list_projects(logger, uri, headers=None, timeout=None):
149
150
r = do_api_call ('GET' ,
150
151
get_uri (uri , 'api' , 'v1' , 'projects' ),
151
152
headers = headers , timeout = timeout )
152
- except Exception :
153
- logger .error (' could not list projects from web application '
154
- 'on {}' . format (uri ))
153
+ except Exception as e :
154
+ logger .error (" could not list projects from web application: {}" .
155
+ format (e ))
155
156
return None
156
157
157
158
return r .json ()
@@ -162,9 +163,9 @@ def list_indexed_projects(logger, uri, headers=None, timeout=None):
162
163
r = do_api_call ('GET' ,
163
164
get_uri (uri , 'api' , 'v1' , 'projects' , 'indexed' ),
164
165
headers = headers , timeout = timeout )
165
- except Exception :
166
- logger .error (' could not list indexed projects from web application '
167
- 'on {}' . format (uri ))
166
+ except Exception as e :
167
+ logger .error (" could not list indexed projects from web application: {}" .
168
+ format (e ))
168
169
return None
169
170
170
171
return r .json ()
@@ -174,9 +175,9 @@ def add_project(logger, project, uri, headers=None, timeout=None):
174
175
try :
175
176
do_api_call ('POST' , get_uri (uri , 'api' , 'v1' , 'projects' ),
176
177
data = project , headers = headers , timeout = timeout )
177
- except Exception :
178
- logger .error (' could not add project {} for web application on {}' .
179
- format (project , uri ))
178
+ except Exception as e :
179
+ logger .error (" could not add project '{}' for web application on {}: {}" .
180
+ format (project , uri , e ))
180
181
return False
181
182
182
183
return True
@@ -187,9 +188,9 @@ def delete_project(logger, project, uri, headers=None, timeout=None):
187
188
do_api_call ('DELETE' , get_uri (uri , 'api' , 'v1' , 'projects' ,
188
189
urllib .parse .quote_plus (project )),
189
190
headers = headers , timeout = timeout )
190
- except Exception :
191
- logger .error (' could not delete project {} in web application on {}' .
192
- format (project , uri ))
191
+ except Exception as e :
192
+ logger .error (" could not delete project '{}' in web application on {}: {}" .
193
+ format (project , uri , e ))
193
194
return False
194
195
195
196
return True
0 commit comments