-
Andrew Kapuscinski authoredAndrew Kapuscinski authored
42723a9dd85c_move_images_out_of_subdirs.py 1.50 KiB
"""move images out of subdirs
Revision ID: 42723a9dd85c
Revises: 01de4f42cf27
Create Date: 2021-09-13 13:52:28.908485
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "42723a9dd85c"
down_revision = "01de4f42cf27"
branch_labels = None
depends_on = None
script_content = """#!/bin/sh
set -o errexit
export HOME=$TMPDIR
{{#need_data}}
./framework.sh -r .
chmod 770 .
cd rawdata/
../productfetcher{{product_locator}} {{^single_image}}&{{/single_image}}
image_subdirs=$(ls)
for i in $image_subdirs; do
if [[ -d "./$i" ]]; then
mv "./$i"/* .
rm -rf "./$i"
fi
done
.{{/need_data}}./carta_envoy {{#need_data}}--parallel{{/need_data}} {{#single_image}}--single -i {{imageName}}{{/single_image}} -d $1 -n $2 -wf $3 -r $4
{{#need_data}}wait{{/need_data}}
"""
old_content = """#!/bin/sh
set -o errexit
export HOME=$TMPDIR
{{#need_data}}
./framework.sh -r .
chmod 770 .
cd rawdata/
../productfetcher{{product_locator}} {{^single_image}}&{{/single_image}}
.{{/need_data}}./carta_envoy {{#need_data}}--parallel{{/need_data}} {{#single_image}}--single -i {{imageName}}{{/single_image}} -d $1 -n $2 -wf $3 -r $4
{{#need_data}}wait{{/need_data}}
"""
def upgrade():
op.execute(
f"""
UPDATE workflow_templates
SET content=E'{script_content}' where filename='carta.sh'
"""
)
def downgrade():
op.execute(
f"""
UPDATE workflow_templates
SET content=E'{old_content}' where filename='carta.sh'
"""
)