Simplified files_make_public_t management command.
'except Exception: pass' is always bad.
This commit is contained in:
@@ -687,26 +687,27 @@ def files_make_public_t():
|
|||||||
from gcloud.exceptions import InternalServerError
|
from gcloud.exceptions import InternalServerError
|
||||||
from application.utils.gcs import GoogleCloudStorageBucket
|
from application.utils.gcs import GoogleCloudStorageBucket
|
||||||
files_collection = app.data.driver.db['files']
|
files_collection = app.data.driver.db['files']
|
||||||
|
|
||||||
for f in files_collection.find({'backend': 'gcs'}):
|
for f in files_collection.find({'backend': 'gcs'}):
|
||||||
if 'variations' in f:
|
if 'variations' not in f:
|
||||||
variation_t = next((item for item in f['variations'] \
|
continue
|
||||||
if item['size'] == 't'), None)
|
|
||||||
if variation_t:
|
variation_t = next((item for item in f['variations']
|
||||||
try:
|
if item['size'] == 't'), None)
|
||||||
storage = GoogleCloudStorageBucket(str(f['project']))
|
if not variation_t:
|
||||||
blob = storage.Get(variation_t['file_path'], to_dict=False)
|
continue
|
||||||
if blob:
|
|
||||||
try:
|
try:
|
||||||
print("Making blob public: {0}".format(blob.path))
|
storage = GoogleCloudStorageBucket(str(f['project']))
|
||||||
blob.make_public()
|
blob = storage.Get(variation_t['file_path'], to_dict=False)
|
||||||
except InternalServerError:
|
if not blob:
|
||||||
print("Internal Server Error")
|
print('Unable to find blob for project %s file %s', f['project'], f['_id'])
|
||||||
except Exception:
|
continue
|
||||||
pass
|
|
||||||
except InternalServerError:
|
print('Making blob public: {0}'.format(blob.path))
|
||||||
print("Internal Server Error")
|
blob.make_public()
|
||||||
except Exception:
|
except InternalServerError as ex:
|
||||||
pass
|
print('Internal Server Error: ', ex)
|
||||||
|
|
||||||
|
|
||||||
@manager.command
|
@manager.command
|
||||||
|
Reference in New Issue
Block a user