Skip to content

Commit

Permalink
feat: added more logging to script.py to troubleshoot problems
Browse files Browse the repository at this point in the history
  • Loading branch information
jlumbroso committed Mar 3, 2024
1 parent 44f842d commit d1f48aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/scrape.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ jobs:
uses: EndBug/add-and-commit@v9
with:
message: "Commit updated data 📈"
add: "./data/*.json ./data/*.csv"
add: "./data/*.json"
cwd: "."
force: true
default_author: github_actions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ def scrape_data_point():
dem.save()
loguru.logger.info("Saved daily event monitor")

def print_tree(directory, ignore_dirs=[".git", "__pycache__"]):
loguru.logger.info(f"Printing tree of files/dirs at {directory}")
for root, dirs, files in os.walk(directory):
dirs[:] = [d for d in dirs if d not in ignore_dirs]
level = root.replace(directory, "").count(os.sep)
indent = " " * 4 * (level)
loguru.logger.info(f"{indent}+--{os.path.basename(root)}/")
sub_indent = " " * 4 * (level + 1)
for file in files:
loguru.logger.info(f"{sub_indent}+--{file}")

print_tree(os.getcwd())

loguru.logger.info("Printing contents of data file {}".format(dem.file_path))
with open(dem.file_path, "r") as f:
loguru.logger.info(f.read())

# Finish
loguru.logger.info("Scrape complete")
loguru.logger.info("Exiting")

0 comments on commit d1f48aa

Please sign in to comment.