This is a library for writing Python applications that make use of Dataverse Network (DVN) APIs. The code started as a "proof of concept" in the dvn/swordpoc repo and the intent is to publish the python client on https://pypi.python.org.
The proof of concept README.md has some tips that have not been incorporated in to this readme yet.
We have been trying to target Python 2.6 because that's the version that ships
with the latest version (6) of Red Hat Enterprise Linux (RHEL) and CentOS. For
testing backward compatibility with Python 2.6, this repo includes a Vagrant
environment. Please note that before you run vagrant up
you'll need to run
git submodule init
and git submodule update
once after cloning this repo.
You will need:
- Python 2.6+
- pip
- gcc compiler (For OSX you will need xcode + command line tools, or standalone install)
- Dataverse account
Once you have satisfied the above requirements, try the following commands.
$ git clone https://github.com/IQSS/dvn-client-python.git
$ cd dvn-client-python
$ virtualenv venv
$ source venv/bin/activate
$ pip install -r dvn_client/src/requirements.txt
You may wish to manage virtualenvs using virtualenvwrapper instead.
Copy config.py
to local.py
and fill out the config elements as appropriate. Do not commit this file.
DEFAULT_USERNAME = ""
DEFAULT_PASSWORD = ""
DEFAULT_HOST = "dvn-demo.iq.harvard.edu"
DEFAULT_CERT = "dvn_client/resources/dvn-4.hmdc.harvard.edu" #see below for info on the cert
- Navigate to
dvn-client-python/dvn-client/src/test/
- Edit test data in
tests.py
as appropriate - Run the client
python dvn_client.py
- To run all of the tests, run
python test_dvn.py
(for more options see unittest)
If you are using a self-signed certificate, you may see an SSL error when you try to hit the server. In that case, follow these instructions.
- Open private/incognito window (in case you have already added a security exception) in FireFox (instructions will be slightly different for other browsers)
- Go to: https://{SERVER}/dvn/api/data-deposit/swordv2/service-document
- Add Exception > View > Details > Export
- Save the PEM to the “resources” folder of the dvn_client project
- When calling
Dataverse.connect()
orDataverse()
constructor, pass a path to this file ascert=[PATH_TO_CERTIFICATE]