4 """Wrapper module for gdrive command""" 12 DIR_ID =
'0B9P1L--7Wd2vUGplQkVLTFBWcFE' 16 url =
'https://drive.google.com/drive/u/1/folders/{}'.format(DIR_ID)
17 cmd =
"gnome-open '{url}'".format(url=url)
18 subprocess.call(cmd, shell=
True)
24 ros_home = os.getenv(
'ROS_HOME', os.path.expanduser(
'~/.ros'))
25 pkg_ros_home = os.path.join(ros_home,
'jsk_data')
26 config = os.path.join(pkg_ros_home,
'.gdrive')
27 cmd =
'rosrun jsk_data drive-linux-x64 --config {config} {args}'\
28 .format(args=args, config=config)
30 return subprocess.check_output(cmd, shell=
True)
32 subprocess.call(cmd, shell=
True)
36 """This should be called before any commands with gdrive""" 37 ros_home = os.getenv(
'ROS_HOME', os.path.expanduser(
'~/.ros'))
38 pkg_ros_home = os.path.join(ros_home,
'jsk_data')
39 config = os.path.join(pkg_ros_home,
'.gdrive')
40 if os.path.exists(os.path.join(config,
'token.json')):
42 if not os.path.exists(pkg_ros_home):
43 os.makedirs(pkg_ros_home)
49 args =
'''list --query " '{id}' in parents" --noheader'''.format(id=DIR_ID)
55 args =
'info --id {id}'.format(id=id)
63 for line
in stdout.splitlines():
64 if line.startswith(
'Title: '):
65 return line.split()[-1]
70 args =
'upload --file {file} --parent {id}'.format(file=filename,
76 if len(filename) > 40:
77 filename = filename[:19] +
'...' + filename[-18:]
79 file_id, title = line.split()[:2]
83 sys.stderr.write(
'file not found: {0}\n'.format(filename))
84 sys.stderr.write(
'Run `jsk_data ls --public` to find files.\n')
91 args =
'download --id {}'.format(file_id)
98 args =
'delete --id {}'.format(file_id)
def info_gdrive(id, only_filename=False)
def delete_gdrive(filename)
def run_gdrive(args=None, stdout=True)
def _info_gdrive_filename(stdout)
def download_gdrive(filename)
def _find_id_by_filename(filename)
def upload_gdrive(filename)