-
Notifications
You must be signed in to change notification settings - Fork 0
/
dropbox_upload.py
35 lines (26 loc) · 1.03 KB
/
dropbox_upload.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
31
32
33
34
35
# -*- coding: utf-8 -*-
"""
Script for uploading securely built distributions (artifacts) to private
Dropbox directory.
Dropbox authorization token should be provided only as environment variable
in a secure form. In case of CI systems (AppVeyor, Travis CI) this should
be provided as encrypted value in CI configuration file.
We prefer to use this method instead of native artifacts collection routine
provided by given CI system because it is more consistent.
"""
import os
import dropbox
import dropbox.files
dropbox_token = os.environ.get('DROPBOX_TOKEN')
dbx = dropbox.Dropbox(dropbox_token)
for root, dirs, files in os.walk('dist'):
for filename in files:
local_path = os.path.join(root, filename)
relative_path = os.path.relpath(local_path, 'dist')
dropbox_path = "/" + relative_path
with open(local_path, 'rb') as f:
print("uploading %s" % local_path)
dbx.files_upload(
f.read(), dropbox_path,
dropbox.files.WriteMode('overwrite')
)