@@ -38,17 +38,17 @@ def get_repos(logger, project, uri, headers=None, timeout=None):
3838 """
3939
4040 try :
41- r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'projects' ,
42- urllib .parse .quote_plus (project ),
43- 'repositories' ),
44- headers = headers , timeout = timeout )
45- except Exception as e :
41+ res = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'projects' ,
42+ urllib .parse .quote_plus (project ),
43+ 'repositories' ),
44+ headers = headers , timeout = timeout )
45+ except Exception as exception :
4646 logger .error ("could not get repositories for project '{}': {}" .
47- format (project , e ))
47+ format (project , exception ))
4848 return None
4949
5050 ret = []
51- for line in r .json ():
51+ for line in res .json ():
5252 ret .append (line .strip ())
5353
5454 return ret
@@ -61,15 +61,15 @@ def get_config_value(logger, name, uri, headers=None, timeout=None):
6161 Return string with the result on success, None on failure.
6262 """
6363 try :
64- r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'configuration' ,
65- urllib .parse .quote_plus (name )),
66- headers = headers , timeout = timeout )
67- except Exception as e :
64+ res = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'configuration' ,
65+ urllib .parse .quote_plus (name )),
66+ headers = headers , timeout = timeout )
67+ except Exception as exception :
6868 logger .error ("Cannot get the '{}' config value from the web "
69- "application: {}" .format (name , e ))
69+ "application: {}" .format (name , exception ))
7070 return None
7171
72- return r .text
72+ return res .text
7373
7474
7575def set_config_value (logger , name , value , uri , headers = None , timeout = None ):
@@ -90,9 +90,9 @@ def set_config_value(logger, name, value, uri, headers=None, timeout=None):
9090 local_headers ['Content-type' ] = 'application/text'
9191 do_api_call ('PUT' , get_uri (uri , 'api' , 'v1' , 'configuration' , name ),
9292 data = value , headers = local_headers , timeout = timeout )
93- except Exception as e :
93+ except Exception as exception :
9494 logger .error ("Cannot set the '{}' config field to '{}' in the web "
95- "application: {}" .format (name , value , e ))
95+ "application: {}" .format (name , value , exception ))
9696 return False
9797
9898 return True
@@ -107,77 +107,77 @@ def get_repo_type(logger, repository, uri, headers=None, timeout=None):
107107 payload = {'repository' : repository }
108108
109109 try :
110- r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'repositories' ,
111- 'property' , 'type' ), params = payload ,
112- headers = headers , timeout = None )
113- except Exception as e :
110+ res = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'repositories' ,
111+ 'property' , 'type' ), params = payload ,
112+ headers = headers , timeout = timeout )
113+ except Exception as exception :
114114 logger .error ("could not get repository type for '{}' from web"
115- "application: {}" .format (repository , e ))
115+ "application: {}" .format (repository , exception ))
116116 return None
117117
118- line = r .text
118+ line = res .text
119119
120120 idx = line .rfind (":" )
121121 return line [idx + 1 :]
122122
123123
124124def get_configuration (logger , uri , headers = None , timeout = None ):
125125 try :
126- r = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'configuration' ),
127- headers = headers , timeout = timeout )
128- except Exception as e :
126+ res = do_api_call ('GET' , get_uri (uri , 'api' , 'v1' , 'configuration' ),
127+ headers = headers , timeout = timeout )
128+ except Exception as exception :
129129 logger .error ('could not get configuration from web application: {}' .
130- format (e ))
130+ format (exception ))
131131 return None
132132
133- return r .text
133+ return res .text
134134
135135
136136def set_configuration (logger , configuration , uri , headers = None , timeout = None ):
137137 try :
138138 do_api_call ('PUT' , get_uri (uri , 'api' , 'v1' , 'configuration' ),
139139 data = configuration , headers = headers , timeout = timeout )
140- except Exception as e :
140+ except Exception as exception :
141141 logger .error ('could not set configuration to web application: {}' .
142- format (e ))
142+ format (exception ))
143143 return False
144144
145145 return True
146146
147147
148148def list_projects (logger , uri , headers = None , timeout = None ):
149149 try :
150- r = do_api_call ('GET' ,
151- get_uri (uri , 'api' , 'v1' , 'projects' ),
152- headers = headers , timeout = timeout )
153- except Exception as e :
150+ res = do_api_call ('GET' ,
151+ get_uri (uri , 'api' , 'v1' , 'projects' ),
152+ headers = headers , timeout = timeout )
153+ except Exception as exception :
154154 logger .error ("could not list projects from web application: {}" .
155- format (e ))
155+ format (exception ))
156156 return None
157157
158- return r .json ()
158+ return res .json ()
159159
160160
161161def list_indexed_projects (logger , uri , headers = None , timeout = None ):
162162 try :
163- r = do_api_call ('GET' ,
164- get_uri (uri , 'api' , 'v1' , 'projects' , 'indexed' ),
165- headers = headers , timeout = timeout )
166- except Exception as e :
163+ res = do_api_call ('GET' ,
164+ get_uri (uri , 'api' , 'v1' , 'projects' , 'indexed' ),
165+ headers = headers , timeout = timeout )
166+ except Exception as exception :
167167 logger .error ("could not list indexed projects from web application: {}" .
168- format (e ))
168+ format (exception ))
169169 return None
170170
171- return r .json ()
171+ return res .json ()
172172
173173
174174def add_project (logger , project , uri , headers = None , timeout = None ):
175175 try :
176176 do_api_call ('POST' , get_uri (uri , 'api' , 'v1' , 'projects' ),
177177 data = project , headers = headers , timeout = timeout )
178- except Exception as e :
178+ except Exception as exception :
179179 logger .error ("could not add project '{}' to web application: {}" .
180- format (project , e ))
180+ format (project , exception ))
181181 return False
182182
183183 return True
@@ -188,9 +188,9 @@ def delete_project(logger, project, uri, headers=None, timeout=None):
188188 do_api_call ('DELETE' , get_uri (uri , 'api' , 'v1' , 'projects' ,
189189 urllib .parse .quote_plus (project )),
190190 headers = headers , timeout = timeout )
191- except Exception as e :
191+ except Exception as exception :
192192 logger .error ("could not delete project '{}' in web application: {}" .
193- format (project , e ))
193+ format (project , exception ))
194194 return False
195195
196196 return True
0 commit comments