Sanket17 commited on
Commit
12bba7c
·
verified ·
1 Parent(s): 8d77ac5

Update src/analysis.py

Browse files
Files changed (1) hide show
  1. src/analysis.py +4 -13
src/analysis.py CHANGED
@@ -1,10 +1,5 @@
1
  import subprocess
2
  import sys
3
- import os
4
-
5
- # ✅ Define cloud-safe temp folder
6
- TEMP_FOLDER = "/tmp"
7
- STATUS_FILE = os.path.join(TEMP_FOLDER, "status.txt")
8
 
9
  def install_requirements():
10
  """Ensure dependencies are installed before running scripts."""
@@ -15,10 +10,10 @@ def install_requirements():
15
  print(f"⚠️ Failed to install dependencies: {e}")
16
 
17
  def run_python_file(file_name, company_name):
18
- """Run a Python script with subprocess and pass the temp folder."""
19
  try:
20
  result = subprocess.run(
21
- [sys.executable, file_name, company_name, TEMP_FOLDER],
22
  capture_output=True,
23
  text=True
24
  )
@@ -36,9 +31,8 @@ def main():
36
  else:
37
  company_name = "Default_Company"
38
 
39
- install_requirements() # Install dependencies before execution
40
 
41
- # ✅ Modify script paths to use /tmp/ for storage
42
  scripts = [
43
  'src/input_analysis/product-analysis/product_analysis.py',
44
  'src/input_analysis/competitor-analysis/competitor_analysis.py',
@@ -53,9 +47,6 @@ def main():
53
  'src/Report/Report.py'
54
  ]
55
 
56
- # ✅ Ensure TEMP_FOLDER exists
57
- os.makedirs(TEMP_FOLDER, exist_ok=True)
58
-
59
  for script in scripts:
60
  status, message = run_python_file(script, company_name)
61
  if status == "error":
@@ -65,7 +56,7 @@ def main():
65
  print(f"{script} executed successfully.")
66
 
67
  # ✅ After all scripts run successfully, mark the status as "done"
68
- with open(STATUS_FILE, "w") as f:
69
  f.write("done")
70
 
71
  if __name__ == "__main__":
 
1
  import subprocess
2
  import sys
 
 
 
 
 
3
 
4
  def install_requirements():
5
  """Ensure dependencies are installed before running scripts."""
 
10
  print(f"⚠️ Failed to install dependencies: {e}")
11
 
12
  def run_python_file(file_name, company_name):
13
+ """Run a Python script with subprocess."""
14
  try:
15
  result = subprocess.run(
16
+ [sys.executable, file_name, company_name],
17
  capture_output=True,
18
  text=True
19
  )
 
31
  else:
32
  company_name = "Default_Company"
33
 
34
+ install_requirements() # Install requirements before execution
35
 
 
36
  scripts = [
37
  'src/input_analysis/product-analysis/product_analysis.py',
38
  'src/input_analysis/competitor-analysis/competitor_analysis.py',
 
47
  'src/Report/Report.py'
48
  ]
49
 
 
 
 
50
  for script in scripts:
51
  status, message = run_python_file(script, company_name)
52
  if status == "error":
 
56
  print(f"{script} executed successfully.")
57
 
58
  # ✅ After all scripts run successfully, mark the status as "done"
59
+ with open("src/Report/status.txt", "w") as f:
60
  f.write("done")
61
 
62
  if __name__ == "__main__":