Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Bump to 1.1.1
Browse files Browse the repository at this point in the history
- Prevents possible pending actions for a previous experiment still being executed
after opening a new one.
  • Loading branch information
dschreij committed Mar 6, 2017
1 parent 84ee93d commit 00ff7cd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 39 deletions.
88 changes: 50 additions & 38 deletions opensesame_extensions/OpenScienceFramework/OpenScienceFramework.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,47 +704,54 @@ def event_save_experiment(self, path):
def event_open_experiment(self, path):
""" Check if opened experiment is linked to the OSF and set parameters
accordingly """

# Only take action if user is logged in
if self.manager.logged_in_user:
# Check if exp is linked to OSF.
# If so, display this information in the OSF explorer.
if self.experiment.var.has('osf_id'):
self.manager.get_file_info(self.experiment.osf_id,
self.__process_file_info)
else:
# Reset GUI if no osf_id is present
self.set_linked_experiment(None)
if not self.manager.logged_in_user:
# If user is not logged in, issue a warning on opening that a link to
# the OSF has been detected, but no syncing can occur as long is the user
# is not logged in.
if self.experiment.var.has('osf_id') or \
self.experiment.var.has('osf_datanode_id'):
self.notifier.info(_(u'OSF link detected'),
_(u'This experiment is linked to the Open Science Framework. '
'Please login if you want to use the synchronization functionalities'))
self.sync_check_required = True
return

# Check if a node to upload data to has been linked for this experiment
# If so, display this information in the OSF explorer.
if self.experiment.var.has('osf_datanode_id'):
# Ids for root level locations (i.e. the root of repository) differ
# from those of subfolder locations. Both require a different API call
# to get the same kind of information, so construct those accordingly
# A root level location will contain a colon.
if not ":" in self.experiment.var.osf_datanode_id:
self.manager.get_file_info(self.experiment.osf_datanode_id,
self.__process_datafolder_info)
else:
project_id, repo = self.experiment.var.osf_datanode_id.split(':')
# For the OSF
api_call = osf.api_call('repo_files', project_id, repo)
self.__process_datafolder_info(api_call)
# If a new experiment has been opened, cancel any actions that may be
# pending of a previous experiment.
self.manager.clear_pending_requests()

# Check if exp is linked to OSF.
# If so, display this information in the OSF explorer.
if self.experiment.var.has('osf_id'):
self.manager.get_file_info(self.experiment.osf_id,
self.__process_file_info)
else:
# Reset GUI if no osf_id is present
self.set_linked_experiment(None)

# Check if a node to upload data to has been linked for this experiment
# If so, display this information in the OSF explorer.
if self.experiment.var.has('osf_datanode_id'):
# Ids for root level locations (i.e. the root of repository) differ
# from those of subfolder locations. Both require a different API call
# to get the same kind of information, so construct those accordingly
# A root level location will contain a colon.
if not ":" in self.experiment.var.osf_datanode_id:
self.manager.get_file_info(self.experiment.osf_datanode_id,
self.__process_datafolder_info)
else:
# Reset GUI if this data is not present
self.set_linked_experiment_datanode(None)
# Refresh contents of the tree so linked items will be marked.
if not self.project_tree.isRefreshing:
self.project_tree.refresh_contents()
# If user is not logged in, issue a warning on opening that a linkt to
# the OSF has been detected, but no syncing can occur as long is the user
# is not logged in.
elif self.experiment.var.has('osf_id') or \
self.experiment.var.has('osf_datanode_id'):
self.notifier.info(_(u'OSF link detected'),
_(u'This experiment is linked to the Open Science Framework. '
'Please login if you want to use the synchronization functionalities'))
self.sync_check_required = True
project_id, repo = self.experiment.var.osf_datanode_id.split(':')
# For the OSF
api_call = osf.api_call('repo_files', project_id, repo)
self.__process_datafolder_info(api_call)
else:
# Reset GUI if this data is not present
self.set_linked_experiment_datanode(None)
# Refresh contents of the tree so linked items will be marked.
if not self.project_tree.isRefreshing:
self.project_tree.refresh_contents()

def event_process_data_files(self, data_files):
""" See if datafiles need to be saved to OSF """
Expand Down Expand Up @@ -1153,6 +1160,11 @@ def __process_file_info(self, reply):
'{}'.format(e))
return

# If the user doesn't have write access to the experiment, unlink it from
# the OSF. This can be the case if the user opens an experiment from a
# linked repository of another owner to which there is no write access.


self.set_linked_experiment(osf_file_path)
# See if always upload experiment flag has been set in the experiment
if self.experiment.var.has('osf_always_upload_experiment') and \
Expand Down
2 changes: 1 addition & 1 deletion opensesame_extensions/OpenScienceFramework/info.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
label: OSF
version: 1.1.0
version: 1.1.1
author: Daniel Schreij
link : https://github.com/dschreij/opensesame-osf

0 comments on commit 00ff7cd

Please sign in to comment.