| 55 | return resources, base_path |
| 56 | |
| 57 | def get_size_bytes(resources): |
| 58 | total_bytes = 0 |
| 59 | |
| 60 | for res in resources: |
| 61 | try: |
| 62 | if os.path.isdir(res): |
| 63 | for dirpath, _, filenames in os.walk(res): |
| 64 | for f in filenames: |
| 65 | fp = os.path.join(dirpath, f) |
| 66 | if not os.path.islink(fp): |
| 67 | total_bytes += os.path.getsize(fp) |
| 68 | elif os.path.isfile(res): |
| 69 | total_bytes += os.path.getsize(res) |
| 70 | except Exception as e: |
| 71 | logger.warn("Cannot get size: {}".format(str(e))) |
| 72 | |
| 73 | return total_bytes |
| 74 | |
| 75 | class TaskSizeSerializer(serializers.Serializer): |
| 76 | assets = serializers.CharField(help_text="One of: [all,backup,custom]") |