Skip to content

Commit d67e4f7

Browse files
committed
corrected python
1 parent 6e04af7 commit d67e4f7

File tree

1 file changed

+6
-38
lines changed

1 file changed

+6
-38
lines changed

docs/deploy_flex_manual.py

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
script_content = '''#!/usr/bin/env python3
1+
#!/usr/bin/env python3
22
"""
33
Deploy Flex Manual to S3
44
Replaces the deploy-flex-manual Makefile target with staging/production/sandbox support
@@ -10,7 +10,6 @@
1010
import sys
1111
from pathlib import Path
1212

13-
1413
def run_command(cmd, check=True):
1514
"""Run a shell command and return the result"""
1615
print(f"Running: {' '.join(cmd)}")
@@ -21,46 +20,33 @@ def run_command(cmd, check=True):
2120
print(result.stderr, file=sys.stderr)
2221
return result
2322

24-
2523
def deploy_flex_manual(environment, branch=None, aws_profile=None, flex_manual_prefix="flex-manual"):
2624
"""Deploy flex manual to S3"""
27-
2825
# Environment-specific bucket configuration
2926
buckets = {
3027
"sandbox": "sandbox.docs", # Your current sandbox bucket
31-
"staging": "opentrons.staging.docs", # Replace with your staging bucket
32-
"production": "opentrons.production.docs" # Replace with your production bucket
28+
"staging": "opentrons.staging.docs", # Replace with your staging bucket
29+
"production": "opentrons.production.docs" # Replace with your production bucket
3330
}
34-
3531
if environment not in buckets:
3632
print(f"Error: Environment must be one of {list(buckets.keys())}")
3733
sys.exit(1)
38-
3934
bucket = buckets[environment]
40-
4135
# Default branch based on environment
4236
if branch is None:
43-
if environment == "sandbox":
44-
branch = "edge"
45-
elif environment == "staging":
46-
branch = "edge"
47-
else: # production
48-
branch = "main"
49-
37+
branch = "edge"
5038
# Check if we're in CI
5139
is_ci = os.getenv("CI") is not None
5240
if is_ci:
5341
print("Running in CI environment")
5442
elif aws_profile is None:
5543
print("Warning: AWS_PROFILE not set. Make sure you have AWS credentials configured.")
56-
5744
# Verify source directory exists
5845
source_dir = Path(flex_manual_prefix) / "site"
5946
if not source_dir.exists():
6047
print(f"Error: Source directory {source_dir} does not exist.")
6148
print("Make sure you've run 'make build-flex-manual' first.")
6249
sys.exit(1)
63-
6450
# Build S3 sync command
6551
s3_path = f"s3://{bucket}/{branch}/{flex_manual_prefix}/"
6652
cmd = [
@@ -70,29 +56,23 @@ def deploy_flex_manual(environment, branch=None, aws_profile=None, flex_manual_p
7056
"--delete",
7157
"--acl", "public-read"
7258
]
73-
7459
# Add AWS profile if specified
7560
if aws_profile:
7661
cmd.extend(["--profile", aws_profile])
77-
7862
print(f"Deploying to {environment} environment:")
7963
print(f" Bucket: {bucket}")
8064
print(f" Branch: {branch}")
8165
print(f" S3 Path: {s3_path}")
82-
8366
try:
8467
run_command(cmd)
8568
print(f"✅ Successfully deployed to {environment}!")
86-
8769
# Print the URL where it's deployed
8870
url = f"https://{bucket}/{branch}/{flex_manual_prefix}/"
8971
print(f"📍 Deployed to: {url}")
90-
9172
except subprocess.CalledProcessError as e:
9273
print(f"❌ Deployment failed with exit code {e.returncode}")
9374
sys.exit(1)
9475

95-
9676
def main():
9777
parser = argparse.ArgumentParser(description="Deploy Flex Manual to S3")
9878
parser.add_argument(
@@ -102,7 +82,7 @@ def main():
10282
)
10383
parser.add_argument(
10484
"--branch",
105-
help="Branch name (defaults to 'edge' for sandbox/staging, 'main' for production)"
85+
help="Branch name (defaults to 'edge')"
10686
)
10787
parser.add_argument(
10888
"--aws-profile",
@@ -113,26 +93,14 @@ def main():
11393
default="flex-manual",
11494
help="Flex manual prefix directory (default: flex-manual)"
11595
)
116-
11796
args = parser.parse_args()
118-
119-
# Use AWS_PROFILE env var if not specified
12097
aws_profile = args.aws_profile or os.getenv("AWS_PROFILE")
121-
12298
deploy_flex_manual(
12399
environment=args.environment,
124100
branch=args.branch,
125101
aws_profile=aws_profile,
126102
flex_manual_prefix=args.flex_manual_prefix
127103
)
128104

129-
130105
if __name__ == "__main__":
131-
main()
132-
'''
133-
134-
# Write the script to a file
135-
with open('deploy_flex_manual.py', 'w') as f:
136-
f.write(script_content)
137-
138-
print("Updated deploy_flex_manual.py with sandbox support")
106+
main()

0 commit comments

Comments
 (0)