update pd script the script now checks if dropbox is done syncing and then stops it once its done
Prithu Goswami prithugoswami524@gmail.com
Wed, 18 Apr 2018 16:48:06 +0530
1 files changed,
32 insertions(+),
0 deletions(-)
jump to
M
scripts/pd
→
scripts/pd
@@ -9,7 +9,33 @@ import sys
import tempfile import subprocess, shlex + file_path = r'/home/prithu/Dropbox/Tasker/pd.txt' + +# This script keeps checking for the dropbox status every 10s and +# runs 'dropbox stop' and exits once dropbox is done with its +# syncing. this shell script should be in the PATH. +exitdrop=( +""" +#!/bin/bash +stat=$(dropbox status) +if [ "$stat" = "Dropbox isn't running!" ] +then + echo $stat + exit 0 +fi +while : +do + if [ "$stat" = "Up to date" ] + then + dropbox stop + exit 0 + fi + stat=$(dropbox status) +done +""") + + entry = None with tempfile.NamedTemporaryFile(suffix='.pdtemp') as temp: command = "vim {}".format(temp.name)@@ -29,3 +55,9 @@ fp.write('\n\n\n===============================\n' + date_and_time + '\n')
fp.write(entry) subprocess.run(['dropbox', 'start']) + +with open('/tmp/exitdrop.sh', 'w') as tmp: + tmp.write(exitdrop) + tmp.close() + subprocess.run(['chmod', '+x', '/tmp/exitdrop.sh']) + subprocess.run(['sh', '/tmp/exitdrop.sh'])