What You'll Need
First:
- brew
- python
- pip
Then:
- virtualenv
- virtualenwrapper
- imagemagick
- dcraw
Also:
- EditThisCookie Chrome extension
- A UVaBox account
If you're completely new to using python or the command line, these instructions assume you're working on MacOS.
1. Create a password for your UVaBox account
Final result: A password
This will let the importer access your account. It can't do this if you're exclusively using NetBadge.
- Log in at https://virginia.app.box.com
- Click on your initials in the top right corner, then choose Account Settings
- Create your new password in the Authentication section
Keep this password somewhere safe. You'll need it when you start the import.
2. Use EditThisCookie to get the key you need to access Mandala Images
Final result: A KEY and VALUE
- Using Chrome, log in to https://images.shanti.virginia.edu
- On the Images page, open Chrome developer tools (View > Developer > Developer Tools)
The developer tools will open at the bottom of the page
- Open the EditThisCookie tab in the developer tool
- Look for a row where:
- The name that starts SESS, and
- The 'Secure' column is checked off
- Copy and paste the first two cells of the row
- The first cell (SESSXXXXXXXXXXXXXXXXX) is your KEY
- The second cell (a string of random digits) is your VALUE
Keep your KEY and VALUE somewhere safe. You'll need them when you start the import.
3. Set up your package installers and python
Final result: python, pip, and brew installed on your computer
These instructions assume you've never worked with the MacOS Terminal app, or any Unix-based system, or any command line interface.
Terminal is a command line interface for your Mac. Instead of clicking on buttons to accomplish what you need, you'll send small snippits of texts instructions to your computer. You'll need to learn the basics of using this interface to run the importer. (Don't worry, if you just copy and paste commands from this document, you should probably be fine...)
Open Terminal
- Open your applications
- Open the Utilities folder, then click Terminal
You should see the terminal now. It will look something like this:
Last login: Wed Feb 6 08:11:10 on ttys000 Veronicas-MacBook-Pro:~ veronicakuhn$
Install Homebrew
Copy and paste the following code into the terminal, then press Return.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
The terminal may ask you to hit Return again to confirm the installation, then will request your Mac password. Enter it, then hit Return one last time.
Install Python
Copy and paste the following code into the terminal, then press Return.
brew install python
(You can do this because you installed homebrew in the previous step. Woohoo.)
Install Pip
The command to install python should have already installed pip, but let's make sure. Copy and paste the following code into the terminal, then press Return.
pip --version
You should see the version of pip that's been installed.
4. Install other stuff you need
Final result: These packages installed onto your computer
- virtualenv
- virtualenwrapper
- imagemagick
- dcraw
Virtualenv
Run the following :
pip install virtualenv
virtualenwrapper
Run the following:
pip install virtualenvwrapper
imagemagick
Run the following:
brew install imagemagick
dcraw
Run the following:
brew install dcraw
5. Create a directory for the importation code
Using the Terminal, you can create and move into 'directories'. This is just creating and moving into folders on your computer using the command line. For simplicity's sake, we're going to create a folder directly in your documents called bhutan-import.
First, navigate into your Documents folder by running the following command in the Terminal:
cd Documents
Now make your new directory, bhutan-import, by running:
mkdir bhutan-import
Now navigate into the new directory:
cd bhutan-import
If you open up Finder, you'll see there's a folder called 'bhutan-import' in your Documents.
6. Get the importation code and XML files
Run this code to clone the importation code into bhutan-import.
git clone https://github.com/samchrisinger/mandala-bii.git
A folder called mandala-bii will show up in bhutan-import once the code is cloned.
Contact Sam Chrisinger, who will link you to an .xml file from Box. Download the file, then put it inside the mandala-bii folder that you created in the previous step. You can use the good ol' click and drag method, no need to use the Terminal!
Save the file name for later.
7. Set up the virtual environments
Back in the Terminal, run:
virtualenv venv
Then run:
source venv/bin/activate
8. Set up the importation code
Enter the mandala-bii directory by running the following:
cd mandala-bii
Then run:
pip install -r requirements.txt
9. Run the importer
Use the following code, with some substitutions:
- XML File Name is the name of the file you downloaded in step 6.
- KEY and VALUE are codes you obtained in step 2.
- YOUR_BOX_USER is your box username, which should be your UVa email address
- YOUR_BOX_PASS is the password you created in step 1.
python import.py -s MediaPro -x "XML File Name.xml" -c KEY=VALUE -i "/Image Uploads/Bhutan/Bhutan Year 5/XML File Name" -u https://images.shanti.virginia.edu/admin/content/bulk_image_import/api -v -cid 619101 -cv -cw ImageMagick --ftp --ftp_user YOUR_BOX_USER --ftp_pass YOUR_BOX_PASS