@@ -195,7 +195,7 @@ def check_for_stored_token(self, tokenfile):
195
195
196
196
#--- Communication with OSF API
197
197
198
- def check_network_accessibility (func ):
198
+ def buffer_network_request (func ):
199
199
""" Decorator function, not to be called directly.
200
200
Checks if network is accessible and buffers the network request so
201
201
that it can be sent again if it fails the first time, due to an invalidated
@@ -205,26 +205,27 @@ def check_network_accessibility(func):
205
205
206
206
@wraps (func )
207
207
def func_wrapper (inst , * args , ** kwargs ):
208
- if not inst .config_mgr .isOnline ():
209
- inst .error_message .emit (
210
- "No network access" ,
211
- _ (u"Your network connection is down or you currently have"
212
- " no Internet access." )
213
- )
214
- return
215
- else :
216
- if inst .logged_in_user :
217
- # Create an internal ID for this request
218
- request_id = uuid .uuid4 ()
219
- current_request = lambda : func (inst , * args , ** kwargs )
220
- # Add tuple with current user, and request to be performed
221
- # to the pending request dictionary
222
- inst .pending_requests [request_id ] = (
223
- inst .logged_in_user ['data' ]['id' ],
224
- current_request )
225
- # Add current request id to kwargs of function being called
226
- kwargs ['_request_id' ] = request_id
227
- return func (inst , * args , ** kwargs )
208
+ # # Not working correctly when packaged, so disable for now
209
+ # if not inst.config_mgr.isOnline():
210
+ # inst.error_message.emit(
211
+ # "No network access",
212
+ # _(u"Your network connection is down or you currently have"
213
+ # " no Internet access.")
214
+ # )
215
+ # return
216
+ # else:
217
+ if inst .logged_in_user :
218
+ # Create an internal ID for this request
219
+ request_id = uuid .uuid4 ()
220
+ current_request = lambda : func (inst , * args , ** kwargs )
221
+ # Add tuple with current user, and request to be performed
222
+ # to the pending request dictionary
223
+ inst .pending_requests [request_id ] = (
224
+ inst .logged_in_user ['data' ]['id' ],
225
+ current_request )
226
+ # Add current request id to kwargs of function being called
227
+ kwargs ['_request_id' ] = request_id
228
+ return func (inst , * args , ** kwargs )
228
229
return func_wrapper
229
230
230
231
def add_token (self , request ):
@@ -276,7 +277,7 @@ def __check_request_parameters(self, url, callback):
276
277
raise TypeError ("callback should be a function or callable." )
277
278
return url
278
279
279
- @check_network_accessibility
280
+ @buffer_network_request
280
281
def get (self , url , callback , * args , ** kwargs ):
281
282
""" Perform a HTTP GET request. The OAuth2 token is automatically added to the
282
283
header if the request is going to an OSF server.
@@ -364,7 +365,7 @@ def get(self, url, callback, *args, **kwargs):
364
365
)
365
366
return reply
366
367
367
- @check_network_accessibility
368
+ @buffer_network_request
368
369
def post (self , url , callback , data_to_send , * args , ** kwargs ):
369
370
""" Perform a HTTP POST request. The OAuth2 token is automatically added to the
370
371
header if the request is going to an OSF server. This request is mainly used to send
@@ -416,7 +417,7 @@ def post(self, url, callback, data_to_send, *args, **kwargs):
416
417
reply = super (ConnectionManager , self ).post (request , final_postdata )
417
418
reply .finished .connect (lambda : self .__reply_finished (callback , * args , ** kwargs ))
418
419
419
- @check_network_accessibility
420
+ @buffer_network_request
420
421
def put (self , url , callback , * args , ** kwargs ):
421
422
""" Perform a HTTP PUT request. The OAuth2 token is automatically added to the
422
423
header if the request is going to an OSF server. This method should be used
@@ -491,7 +492,7 @@ def put(self, url, callback, *args, **kwargs):
491
492
if callable (ulpCallback ):
492
493
reply .uploadProgress .connect (ulpCallback )
493
494
494
- @check_network_accessibility
495
+ @buffer_network_request
495
496
def delete (self , url , callback , * args , ** kwargs ):
496
497
""" Perform a HTTP DELETE request. The OAuth2 token is automatically added to the
497
498
header if the request is going to an OSF server.
0 commit comments