Skip to content

Commit

Permalink
Merge pull request #1325 from wkentaro/support-open-command
Browse files Browse the repository at this point in the history
[jsk_data] Add pubopen subcommand to open GoogleDrive
  • Loading branch information
garaemon committed Dec 28, 2015
2 parents 149b2fa + 1fe6208 commit 0c769cf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion jsk_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ this is fully designed for JSK lab members.

There are following sub commands. See `jsk_data [sub command] --help` for more detail.

* `ls`: List data in the server.
* `ls`: List data on the server.

Usage is `jsk_data ls [OPTIONS] [QUERY]`.

Expand All @@ -28,13 +28,23 @@ There are following sub commands. See `jsk_data [sub command] --help` for more d
[public Google Drive folder](https://drive.google.com/folderview?id=0B9P1L--7Wd2vUGplQkVLTFBWcFE),
so please care about it when you handle secure data.

* `delete`: Delete file on the server.

Usage is `jsk_data delete FILENAME`.
It only supports with `--public` option.
If you want to delete private data, delete it manually by logging in aries via ssh.

* `pubinfo`: Show public data info.

Usage is `jsk_data pubinfo [OPTIONS] FILENAME`.
Downloading large file with `wget` or `curl` from Google Drive can be failed.
(see [here](http://stackoverflow.com/questions/25010369/wget-curl-large-file-from-google-drive))
Please run `sudo pip install gdown` and use it at that time. (`Usage: gdown [URL] -O [FILENAME]`)

* `pubopen`: Open Google Drive Folder where public data is uploaded

Usage is `jsk_data pubopen`.


**Screencast**

Expand Down
6 changes: 6 additions & 0 deletions jsk_data/src/jsk_data/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from jsk_data.gdrive import download_gdrive
from jsk_data.gdrive import info_gdrive
from jsk_data.gdrive import list_gdrive
from jsk_data.gdrive import open_gdrive
from jsk_data.gdrive import upload_gdrive
from jsk_data.ssh import connect_ssh
from jsk_data.ssh import get_user_by_hostname
Expand Down Expand Up @@ -213,3 +214,8 @@ def cmd_delete(public, filename):
filename = selected[0].split()[1]

delete_gdrive(filename=filename)


@cli.command(name='pubopen', help='Go to see files on browser')
def cmd_pubopen():
open_gdrive()
6 changes: 6 additions & 0 deletions jsk_data/src/jsk_data/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
DIR_ID = '0B9P1L--7Wd2vUGplQkVLTFBWcFE'


def open_gdrive():
url = 'https://drive.google.com/drive/u/1/folders/{}'.format(DIR_ID)
cmd = "gnome-open '{url}'".format(url=url)
subprocess.call(cmd, shell=True)


def run_gdrive(args=None, stdout=True):
if args is None:
args = ''
Expand Down

0 comments on commit 0c769cf

Please sign in to comment.