Skip to content

Commit add05a0

Browse files
committed
Remove network checking because it didn't work
1 parent 0135ff9 commit add05a0

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

QOpenScienceFramework/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.0.3"
1+
__version__ = "1.0.4"
22
__author__ = "Daniel Schreij"
33

44
import os

QOpenScienceFramework/manager.py

+26-25
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def check_for_stored_token(self, tokenfile):
195195

196196
#--- Communication with OSF API
197197

198-
def check_network_accessibility(func):
198+
def buffer_network_request(func):
199199
""" Decorator function, not to be called directly.
200200
Checks if network is accessible and buffers the network request so
201201
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):
205205

206206
@wraps(func)
207207
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)
228229
return func_wrapper
229230

230231
def add_token(self, request):
@@ -276,7 +277,7 @@ def __check_request_parameters(self, url, callback):
276277
raise TypeError("callback should be a function or callable.")
277278
return url
278279

279-
@check_network_accessibility
280+
@buffer_network_request
280281
def get(self, url, callback, *args, **kwargs):
281282
""" Perform a HTTP GET request. The OAuth2 token is automatically added to the
282283
header if the request is going to an OSF server.
@@ -364,7 +365,7 @@ def get(self, url, callback, *args, **kwargs):
364365
)
365366
return reply
366367

367-
@check_network_accessibility
368+
@buffer_network_request
368369
def post(self, url, callback, data_to_send, *args, **kwargs):
369370
""" Perform a HTTP POST request. The OAuth2 token is automatically added to the
370371
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):
416417
reply = super(ConnectionManager, self).post(request, final_postdata)
417418
reply.finished.connect(lambda: self.__reply_finished(callback, *args, **kwargs))
418419

419-
@check_network_accessibility
420+
@buffer_network_request
420421
def put(self, url, callback, *args, **kwargs):
421422
""" Perform a HTTP PUT request. The OAuth2 token is automatically added to the
422423
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):
491492
if callable(ulpCallback):
492493
reply.uploadProgress.connect(ulpCallback)
493494

494-
@check_network_accessibility
495+
@buffer_network_request
495496
def delete(self, url, callback, *args, **kwargs):
496497
""" Perform a HTTP DELETE request. The OAuth2 token is automatically added to the
497498
header if the request is going to an OSF server.

0 commit comments

Comments
 (0)