@@ -42,8 +42,9 @@ def get_repos(logger, project, uri, headers=None, timeout=None):
4242 urllib .parse .quote_plus (project ),
4343 'repositories' ),
4444 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 ))
4748 return None
4849
4950 ret = []
@@ -63,9 +64,9 @@ def get_config_value(logger, name, uri, headers=None, timeout=None):
6364 r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'configuration' ,
6465 urllib .parse .quote_plus (name )),
6566 headers = headers , timeout = timeout )
66- except Exception :
67+ except Exception as e :
6768 logger .error ("Cannot get the '{}' config value from the web "
68- "application on {}" .format (name , uri ))
69+ "application: {}" .format (name , e ))
6970 return None
7071
7172 return r .text
@@ -89,9 +90,9 @@ def set_config_value(logger, name, value, uri, headers=None, timeout=None):
8990 local_headers ['Content-type' ] = 'application/text'
9091 do_api_call ('PUT' , get_uri (uri , 'api' , 'v1' , 'configuration' , name ),
9192 data = value , headers = local_headers , timeout = timeout )
92- except Exception :
93+ except Exception as e :
9394 logger .error ("Cannot set the '{}' config field to '{}' from the web "
94- "application on {}" .format (name , value , uri ))
95+ "application: {}" .format (name , value , e ))
9596 return False
9697
9798 return True
@@ -109,9 +110,9 @@ def get_repo_type(logger, repository, uri, headers=None, timeout=None):
109110 r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'repositories' ,
110111 'property' , 'type' ), params = payload ,
111112 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 ))
115116 return None
116117
117118 line = r .text
@@ -124,9 +125,9 @@ def get_configuration(logger, uri, headers=None, timeout=None):
124125 try :
125126 r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'configuration' ),
126127 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 ))
130131 return None
131132
132133 return r .text
@@ -136,9 +137,9 @@ def set_configuration(logger, configuration, uri, headers=None, timeout=None):
136137 try :
137138 do_api_call ('PUT' , get_uri (uri , 'api' , 'v1' , 'configuration' ),
138139 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 ))
142143 return False
143144
144145 return True
@@ -149,9 +150,9 @@ def list_projects(logger, uri, headers=None, timeout=None):
149150 r = do_api_call ('GET' ,
150151 get_uri (uri , 'api' , 'v1' , 'projects' ),
151152 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 ))
155156 return None
156157
157158 return r .json ()
@@ -162,9 +163,9 @@ def list_indexed_projects(logger, uri, headers=None, timeout=None):
162163 r = do_api_call ('GET' ,
163164 get_uri (uri , 'api' , 'v1' , 'projects' , 'indexed' ),
164165 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 ))
168169 return None
169170
170171 return r .json ()
@@ -174,9 +175,9 @@ def add_project(logger, project, uri, headers=None, timeout=None):
174175 try :
175176 do_api_call ('POST' , get_uri (uri , 'api' , 'v1' , 'projects' ),
176177 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 ))
180181 return False
181182
182183 return True
@@ -187,9 +188,9 @@ def delete_project(logger, project, uri, headers=None, timeout=None):
187188 do_api_call ('DELETE' , get_uri (uri , 'api' , 'v1' , 'projects' ,
188189 urllib .parse .quote_plus (project )),
189190 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 ))
193194 return False
194195
195196 return True
0 commit comments