Skip to content

Commit

Permalink
appveyor: minor improvement to dropbox upload script to prevent failu…
Browse files Browse the repository at this point in the history
…res on PRs based on master
  • Loading branch information
swistakm committed Feb 8, 2017
1 parent 78d7290 commit fc0d89b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ init:
- "%PYTHON%\\python.exe --version"

install:
- set
# python requirements needed to create distribution
- "%PYTHON%\\python.exe -m pip install wheel"

Expand Down
31 changes: 18 additions & 13 deletions ci/dropbox_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@
import dropbox
import dropbox.files

dropbox_token = os.environ.get('DROPBOX_TOKEN')

dbx = dropbox.Dropbox(dropbox_token)
if __name__:
dropbox_token = os.environ.get('DROPBOX_TOKEN', None)

if dropbox_token is None:
print("Not configured to upload! Set DROPBOX_TOKEN env variable!")
exit()

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
dbx = dropbox.Dropbox(dropbox_token)

with open(local_path, 'rb') as f:
print("uploading %s" % local_path)
dbx.files_upload(
f.read(), dropbox_path,
dropbox.files.WriteMode('overwrite')
)
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')
)

0 comments on commit fc0d89b

Please sign in to comment.