Skip to content

Commit

Permalink
codeassist merged with release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakdinesh1123 committed Aug 23, 2024
1 parent 1c45be2 commit 04ddba2
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import requests
import tarfile
from time import sleep
import subprocess
import shutil

from django.core.management.base import BaseCommand

Expand All @@ -13,10 +15,6 @@ class Command(BaseCommand):

def add_arguments(self, parser):
super().add_arguments(parser)
parser.add_argument(
"action",
help="Action to be performed.",
)
parser.add_argument(
"--codeassist_endpoint",
help="The endpoint URL for codeassist.",
Expand Down Expand Up @@ -59,12 +57,12 @@ def handle(self, *args, **options):
print("App started successfully, proceeding with codeassist")
break
resp = requests.post(
options["codeassist_endpoint"],
json=json.dumps(spec),
f"{options['codeassist_endpoint']}/generate-app",
json=spec,
headers={"Content-Type": "application/json"},
)
if resp.status_code == 200:
os.removedirs(f"workspaces/{app_name}/")
shutil.rmtree(f"workspaces/{app_name}")

file_path = f"{app_name}.tar"
with open(file_path, "wb") as f:
Expand All @@ -73,8 +71,15 @@ def handle(self, *args, **options):
f.write(chunk)

with tarfile.open(file_path) as tar:
tar.extractall(path=f"workspaces/{app_name}/")
tar.extractall(path=f"workspaces/")
os.remove(file_path)
else:
print(resp.text)
try:
subprocess.run(["python", "manage.py", "ws_makemigration", app_name])
subprocess.run(["zango", "update-apps", "--app_name", app_name])
except Exception as e:
print(e)
except json.JSONDecodeError as e:
print(f"Error while parsing jsonspec: {e}")
return

0 comments on commit 04ddba2

Please sign in to comment.