updatev2_1.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # This scripts pull the latest Azure Storage SDK and update this multiapi package accordingly.
  3. workdir=$(cd $(dirname $0); pwd)
  4. cd $workdir
  5. if [ ! -d venv ]; then
  6. python -m virtualenv venv
  7. . venv/bin/activate
  8. pip install azure-storage-file-datalake azure-storage-blob azure-storage-file-share azure-storage-queue -U
  9. fi
  10. src_root=$(cd venv/lib/$(ls venv/lib); pwd)/site-packages/azure/storage
  11. for service in blob fileshare filedatalake queue; do
  12. ver=$(find venv -name 'version.py' | grep $service | xargs grep 'VERSION')
  13. ver=${ver#VERSION = \"}
  14. if [ -z "$ver" ]; then
  15. ver=$(find venv -name '_configuration.py' | grep $service | xargs grep 'version' | head -n 1)
  16. ver=${ver#*self.version = \"}
  17. fi
  18. ver=${ver%\"*}
  19. ver=${ver//-/_}
  20. tgt=../azure/multiapi/storagev2/$service/v$ver
  21. mkdir -p $tgt
  22. src=$src_root/$service
  23. cp -R $src/. $tgt
  24. for f in `find $tgt -name '*.py'`; do
  25. echo Updating $f
  26. # remove BOM
  27. sed -i '1s/^\xEF\xBB\xBF//' $f
  28. if [ "$service" = "filedatalake" ]; then
  29. echo "filedatalake"
  30. default="2019_07_07"
  31. if [[ "$ver" > "$default" ]]; then
  32. default=$ver
  33. fi
  34. sed -i "s/from azure.storage.blob import/from azure.multiapi.storagev2.blob.v$default import/g" $f
  35. sed -i "s/from azure.storage.blob./from azure.multiapi.storagev2.blob.v$default./g" $f
  36. fi
  37. namespace=azure.storage.$service
  38. sed -i "s/from $namespace./from ./g" $f
  39. sed -i "s/from ...core.exceptions/from azure.core.exceptions/g" $f
  40. done
  41. done