Skip to content

Commit

Permalink
Update script_runner.py
Browse files Browse the repository at this point in the history
  • Loading branch information
RaresCode committed Sep 23, 2024
1 parent 90e3bac commit 6eed216
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sites/script_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ def run(self):
# Iterate over all files in the 'sites' directory
for site in os.listdir(path):
if site.endswith('.py') and site not in self.exclude:
script_path = os.path.join(path, site) # Full path to the script
script_path = os.path.join(path, site)
try:
print(f"Running: python3 {script_path}")
# Run the script with 'python3' and capture the output
result = subprocess.run(['python3', script_path], cwd=path, check=True)
# Run the script with 'python3' using shell=True to simulate direct execution
result = subprocess.run(f'python3 {script_path}', cwd=path, shell=True, check=True, env=os.environ)
print(f"Success scraping {site} with exit code {result.returncode}")
except subprocess.CalledProcessError as e:
print(f"Error scraping {site} with exit code {e.returncode}: {e}")
except Exception as e:
print(f"An unexpected error occurred while scraping {site}: {e}")



if __name__ == "__main__":
# exclude files
exclude = [
Expand Down

0 comments on commit 6eed216

Please sign in to comment.