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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#!/bin/bash
# This scripts pull the latest Azure Storage SDK and update this multiapi package accordingly.
workdir=$(cd $(dirname $0); pwd)
cd $workdir
if [ ! -d venv ]; then
python -m virtualenv venv
. venv/bin/activate
pip install azure-storage-file-datalake azure-storage-blob azure-storage-file-share azure-storage-queue -U
fi
src_root=$(cd venv/lib/$(ls venv/lib); pwd)/site-packages/azure/storage
for service in blob fileshare filedatalake queue; do
ver=$(find venv -name '_serialize.py' | grep $service | xargs grep '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}' | tail -n 1 | cut -d \' -f 2)
ver=${ver//-/_}
tgt=../azure/multiapi/storagev2/$service/v$ver
mkdir -p $tgt
src=$src_root/$service
cp -R $src/. $tgt
for f in `find $tgt -name '*.py'`; do
echo Updating $f
# remove BOM
sed -i '1s/^\xEF\xBB\xBF//' $f
if [ "$service" = "filedatalake" ]; then
echo "filedatalake"
default="2019_07_07"
if [[ "$ver" > "$default" ]]; then
default=$ver
fi
sed -i "s/from azure.storage.blob import/from azure.multiapi.storagev2.blob.v$default import/g" $f
sed -i "s/from azure.storage.blob./from azure.multiapi.storagev2.blob.v$default./g" $f
fi
namespace=azure.storage.$service
sed -i "s/from $namespace./from ./g" $f
sed -i "s/from ...core.exceptions/from azure.core.exceptions/g" $f
done
done
|