{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "7fdcbc99-b408-519d-041d-f02be1698d1e"
      },
      "source": [
        "# Use Google Drive by `drive` command on Colfax Cluster\n",
        "\n",
        "Google Drive is useful for upload and download on Colfax Cluster.  \n",
        "Of course, you can do them by `scp` commands.  \n",
        "But I believe there is an advantage of using Google Drive (e.g. bandwidth).\n",
        "\n",
        "**We should be very careful to task-kill on Colfax.**  \n",
        "\n",
        "[https://github.com/prasmussen/gdrive](https://github.com/prasmussen/gdrive)  \n",
        "Use drive-linux-x64\n",
        "\n",
        "Special Thanks: [\u30b5\u30fc\u30d0\u306e\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30d5\u30a1\u30a4\u30eb\u3092 Google \u30c9\u30e9\u30a4\u30d6\u306b\u9000\u907f\u3055\u305b\u308b | Qiita](http://qiita.com/aviscaerulea/items/53123ce5b79c80e31a71)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "c85fd081-02ca-8399-3b70-6a0382d30023"
      },
      "outputs": [],
      "source": [
        "'''\n",
        "# Download command file\n",
        "$ cd ~\n",
        "$ wget -O gdrive https://drive.google.com/uc?id=0B3X9GlR6Embnb095MGxEYmJhY2c\n",
        "$ chmod 755 ~/gdrive\n",
        "$ mv ~/gdrive ~/.local/bin\n",
        "\n",
        "\n",
        "# Setting\n",
        "# Open url on your local machine, and input verification code\n",
        "\n",
        "$ gdrive\n",
        "\n",
        "# => Go to the following link in your browser:\n",
        "# => https://accounts.google.com/o/oauth2/auth?client_id=xxx.apps.googleusercontent.com...\n",
        "\n",
        "\n",
        "# Download files to Colfax Cluster\n",
        "\n",
        "$ gdrive list | grep .pdf\n",
        "# => Id                                                              Title                                      Size       Created\n",
        "# => 0B2kJp7wSl9SIOUxvdnBxMmNIQXM                                    Intel_Deep_Learing_...ool_User_Guide.pdf   211.0 KB   2017-03-28 04:21:15\n",
        "\n",
        "$ gdrive download -i 0B2kJp7wSl9SIOUxvdnBxMmNIQXM\n",
        "Downloaded 'Intel_Deep_Learing_SDK_Deployment_Tool_User_Guide.pdf' at 211.0 KB/s, total 211.0 KB\n",
        "\n",
        "\n",
        "# Upload files to Google gDrive\n",
        "$ gdrive upload --file test.txt\n",
        "\n",
        "\n",
        "# Extra: Encrypt files (on Colfax Cluster or your local machine)\n",
        "# Check Google policies about file's license: https://www.google.com/policies/terms/\n",
        "# Of course, you can use other encrypt ways, you don't have to encrypt public files.\n",
        "\n",
        "# Encrypt\n",
        "$ openssl aes-256-cbc -e -in input_file.txt -out encrypt_file.txt -pass pass:password0123\n",
        "\n",
        "# Decypt\n",
        "$ openssl aes-256-cbc -d -in encrypt_file.txt -out input_file.txt -pass pass:password0123\n",
        "'''\n",
        "pass"
      ]
    }
  ],
  "metadata": {
    "_change_revision": 0,
    "_is_fork": false,
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}