Skip to content

Commit 61691e5

Browse files
committed
fixes #13
1 parent 4d0a913 commit 61691e5

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,6 @@ token.json
7878
resources/iconthemes/
7979

8080
# Universal build script
81-
build_all
81+
build_all
82+
83+
.vscode

QOpenScienceFramework/__init__.py

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

44
import os

QOpenScienceFramework/manager.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def buffer_network_request(func):
236236
def func_wrapper(inst, *args, **kwargs):
237237
if inst.logged_in_user:
238238
# Create an internal ID for this request
239-
request_id=uuid.uuid4()
239+
request_id = uuid.uuid4()
240240
current_request = lambda: func(inst, *args, **kwargs)
241241
# Add tuple with current user, and request to be performed
242242
# to the pending request dictionary
@@ -842,10 +842,17 @@ def __reply_finished(self, callback, *args, **kwargs):
842842
self.__close_file_handles(*args, **kwargs)
843843
reply.deleteLater()
844844
return
845+
846+
# Truncate the temp file. This will delete any contents that have been streamed
847+
# to the file during the redirect request.
848+
if 'tmp_file' in kwargs and isinstance(kwargs['tmp_file'], QtCore.QTemporaryFile):
849+
kwargs['tmp_file'].resize(0)
850+
845851
# Perform another request with the redirect_url and pass on the callback
846852
redirect_url = reply.attribute(request.RedirectionTargetAttribute)
847853
# For now, the redirects only work for GET operations (but to my
848854
# knowledge, those are the only operations they occur for)
855+
849856
if reply.operation() == self.GetOperation:
850857
self.get(redirect_url, callback, *args, **kwargs)
851858
else:
@@ -906,8 +913,6 @@ def __download(self, reply, download_url, *args, **kwargs):
906913
size = progressDialog['filesize']
907914
except KeyError as e:
908915
raise KeyError("progressDialog missing field {}".format(e))
909-
icon = QtGui.QIcon()
910-
title = _("Transfer in progress")
911916
progress_indicator = self.__create_progress_dialog(text, size)
912917
kwargs['progressDialog'] = progress_indicator
913918
kwargs['downloadProgress'] = self.__transfer_progress

example.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import logging
1919
import tempfile
2020
logging.basicConfig(level=logging.INFO)
21+
from dotenv import load_dotenv
22+
load_dotenv()
2123

2224
# Required QT classes
2325
from qtpy import QtWidgets, QtCore
@@ -29,8 +31,8 @@
2931
from QOpenScienceFramework.compat import *
3032

3133
####### CONFIGURE THE CLIENT ID AND REDIRECT URI HERE. REGISTER AT OSF.IO ######
32-
client_id = "<YOUR_CLIENT_ID_HERE>"
33-
redirect_uri = "<YOUR_REDIRECT_URI_HERE>"
34+
client_id = os.getenv("CLIENT_ID", "<YOUR_CLIENT_ID_HERE>")
35+
redirect_uri = os.getenv("REDIRECT_URI", "<YOUR_REDIRECT_URI_HERE>")
3436
################################################################################
3537

3638
class InvalidateButton(QtWidgets.QWidget):

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'python-fileinspector',
2828
'requests-oauthlib>=0.6',
2929
'qtawesome',
30+
'python-dotenv'
3031
],
3132
include_package_data=True,
3233
packages = ['QOpenScienceFramework'],

0 commit comments

Comments
 (0)