@@ -38,17 +38,17 @@ def get_repos(logger, project, uri, headers=None, timeout=None):
38
38
"""
39
39
40
40
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 :
46
46
logger .error ("could not get repositories for project '{}': {}" .
47
- format (project , e ))
47
+ format (project , exception ))
48
48
return None
49
49
50
50
ret = []
51
- for line in r .json ():
51
+ for line in res .json ():
52
52
ret .append (line .strip ())
53
53
54
54
return ret
@@ -61,15 +61,15 @@ def get_config_value(logger, name, uri, headers=None, timeout=None):
61
61
Return string with the result on success, None on failure.
62
62
"""
63
63
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 :
68
68
logger .error ("Cannot get the '{}' config value from the web "
69
- "application: {}" .format (name , e ))
69
+ "application: {}" .format (name , exception ))
70
70
return None
71
71
72
- return r .text
72
+ return res .text
73
73
74
74
75
75
def 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):
90
90
local_headers ['Content-type' ] = 'application/text'
91
91
do_api_call ('PUT' , get_uri (uri , 'api' , 'v1' , 'configuration' , name ),
92
92
data = value , headers = local_headers , timeout = timeout )
93
- except Exception as e :
93
+ except Exception as exception :
94
94
logger .error ("Cannot set the '{}' config field to '{}' in the web "
95
- "application: {}" .format (name , value , e ))
95
+ "application: {}" .format (name , value , exception ))
96
96
return False
97
97
98
98
return True
@@ -107,77 +107,77 @@ def get_repo_type(logger, repository, uri, headers=None, timeout=None):
107
107
payload = {'repository' : repository }
108
108
109
109
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 :
114
114
logger .error ("could not get repository type for '{}' from web"
115
- "application: {}" .format (repository , e ))
115
+ "application: {}" .format (repository , exception ))
116
116
return None
117
117
118
- line = r .text
118
+ line = res .text
119
119
120
120
idx = line .rfind (":" )
121
121
return line [idx + 1 :]
122
122
123
123
124
124
def get_configuration (logger , uri , headers = None , timeout = None ):
125
125
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 :
129
129
logger .error ('could not get configuration from web application: {}' .
130
- format (e ))
130
+ format (exception ))
131
131
return None
132
132
133
- return r .text
133
+ return res .text
134
134
135
135
136
136
def set_configuration (logger , configuration , uri , headers = None , timeout = None ):
137
137
try :
138
138
do_api_call ('PUT' , get_uri (uri , 'api' , 'v1' , 'configuration' ),
139
139
data = configuration , headers = headers , timeout = timeout )
140
- except Exception as e :
140
+ except Exception as exception :
141
141
logger .error ('could not set configuration to web application: {}' .
142
- format (e ))
142
+ format (exception ))
143
143
return False
144
144
145
145
return True
146
146
147
147
148
148
def list_projects (logger , uri , headers = None , timeout = None ):
149
149
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 :
154
154
logger .error ("could not list projects from web application: {}" .
155
- format (e ))
155
+ format (exception ))
156
156
return None
157
157
158
- return r .json ()
158
+ return res .json ()
159
159
160
160
161
161
def list_indexed_projects (logger , uri , headers = None , timeout = None ):
162
162
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 :
167
167
logger .error ("could not list indexed projects from web application: {}" .
168
- format (e ))
168
+ format (exception ))
169
169
return None
170
170
171
- return r .json ()
171
+ return res .json ()
172
172
173
173
174
174
def add_project (logger , project , uri , headers = None , timeout = None ):
175
175
try :
176
176
do_api_call ('POST' , get_uri (uri , 'api' , 'v1' , 'projects' ),
177
177
data = project , headers = headers , timeout = timeout )
178
- except Exception as e :
178
+ except Exception as exception :
179
179
logger .error ("could not add project '{}' to web application: {}" .
180
- format (project , e ))
180
+ format (project , exception ))
181
181
return False
182
182
183
183
return True
@@ -188,9 +188,9 @@ def delete_project(logger, project, uri, headers=None, timeout=None):
188
188
do_api_call ('DELETE' , get_uri (uri , 'api' , 'v1' , 'projects' ,
189
189
urllib .parse .quote_plus (project )),
190
190
headers = headers , timeout = timeout )
191
- except Exception as e :
191
+ except Exception as exception :
192
192
logger .error ("could not delete project '{}' in web application: {}" .
193
- format (project , e ))
193
+ format (project , exception ))
194
194
return False
195
195
196
196
return True
0 commit comments