-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
30 lines (23 loc) · 1.13 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#****************************************************************
#uploads multiple files to Dropbox using Dropbox SDK and API
#input is canonical paths to files/directories that
#need to get uploaded
#****************************************************************
from subprocess import call
import os
import re
#directory where files will uploaded to Dropbox
dirname = '/home/Documents/'
#local files that are to be uploaded
#take input from user
localfiles = input('Enter the canonical paths to files/directories you want to upload(like'
' /home/username/file), seperated by commas:\n').split(',')
no_of_dirs = 0
localfiles = [files.replace('~', os.environ['HOME']) for files in localfiles]
for files in localfiles:
#if files is actually a directory, invoke shell script zipit.sh
#there will be only one zip archive, directories will be added
if os.path.exists(files): #checking if the path exists
if os.path.isdir(files): #if exists, check if it's a file or a dir
no_of_dirs += 1
call(["bash", "zipit.sh", re.sub(r'[\s+]', r'\ ', files)]) # in case path contains whitespaces