|
@@ -14,8 +14,8 @@ EXCLUDES = [
|
14
|
14
|
|
15
|
15
|
import time, os, os.path, re, sys, tarfile
|
16
|
16
|
|
17
|
|
-if len(sys.argv) != 2:
|
18
|
|
- print "Usage: %s path_to_profile" % sys.argv[0]
|
|
17
|
+if len(sys.argv) != 2 and len(sys.argv) != 4:
|
|
18
|
+ print "Usage: %s path_to_profile [filedropper_username filedropper_password]" % sys.argv[0]
|
19
|
19
|
sys.exit(1)
|
20
|
20
|
|
21
|
21
|
profile_path = sys.argv[1]
|
|
@@ -23,6 +23,11 @@ profile_name = os.path.basename(profile_path)
|
23
|
23
|
date = time.strftime("%Y%m%d_%H%M%S")
|
24
|
24
|
archive_name = "%s-%s.tar.bz2" % (profile_name, date)
|
25
|
25
|
|
|
26
|
+fd_user = None
|
|
27
|
+fd_pass = None
|
|
28
|
+if len(sys.argv) == 4:
|
|
29
|
+ fd_user, fd_pass = sys.argv[2], sys.argv[3]
|
|
30
|
+
|
26
|
31
|
# Compile exclusion regexps
|
27
|
32
|
EXCLUDES_RE = []
|
28
|
33
|
for regexp in EXCLUDES:
|
|
@@ -52,3 +57,32 @@ tar.close()
|
52
|
57
|
# Display archive name and sizes
|
53
|
58
|
print "Profile saved to %s" % archive_name
|
54
|
59
|
print "%.1f MB --> %.1f MB" % (total_size/(1024**2), os.path.getsize(archive_name)/(1024**2))
|
|
60
|
+
|
|
61
|
+# Upload to FileDropper if needed
|
|
62
|
+if fd_user is not None and fd_pass is not None:
|
|
63
|
+ import FileDropper
|
|
64
|
+
|
|
65
|
+ fd = FileDropper.FileDropper()
|
|
66
|
+ fd.login(fd_user, fd_pass)
|
|
67
|
+
|
|
68
|
+ # Upload the file
|
|
69
|
+ url = fd.upload(archive_name)
|
|
70
|
+
|
|
71
|
+ # Get the file ID
|
|
72
|
+ lst = fd.list()
|
|
73
|
+ file_id = -1
|
|
74
|
+ for line in lst:
|
|
75
|
+ if line[6] == url:
|
|
76
|
+ file_id = line[1]
|
|
77
|
+ break
|
|
78
|
+ if file_id == -1:
|
|
79
|
+ # File not found in list!
|
|
80
|
+ raise Exception("Error in upload, could not get file ID, permissions not set")
|
|
81
|
+
|
|
82
|
+ # Set the permissions
|
|
83
|
+ fd.set_perm(file_id, FileDropper.FD_PERM_PRIVATE)
|
|
84
|
+
|
|
85
|
+ # Logout
|
|
86
|
+ fd.logout()
|
|
87
|
+
|
|
88
|
+ print "File uploaded to FileDropper: %s" % url
|