Skip to content

Commit

Permalink
formatting, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tommartensen committed Aug 3, 2023
1 parent 84ca034 commit eaa31e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 1 addition & 4 deletions scripts/cost-estimation/calculate-costs.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#!/bin/bash

set +xeuo pipefail

WORKING_DIR=$(dirname "$0")

# Hack to avoid bq initialization
# Hack to avoid bq initialization spamming the stdout
touch "${HOME}/.bigqueryrc"

bq query \
--nouse_legacy_sql \
--project_id stackrox-infra \
--format prettyjson \
< "${WORKING_DIR}/total-time-consumed.sql" \
2>/dev/null \
| python3 "${WORKING_DIR}/render_costs.py"
13 changes: 7 additions & 6 deletions scripts/cost-estimation/render_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@

def read_usage_from_stdin():
content = ""
print("hello")
for line in sys.stdin:
print(1, line)
content += line

print(content)

return json.loads(content)
try:
return json.loads(content)
except Exception as e:
raise("an exception occured while reading stdin:", e)

def calculate_costs(usage):
costs = []
Expand All @@ -48,12 +47,14 @@ def main():
usage = read_usage_from_stdin()
cost_per_flavor_env = calculate_costs(usage)

print("```")
print(tabulate(
cost_per_flavor_env,
headers="keys",
tablefmt="simple_outline",
tablefmt="github",
floatfmt=".2f"
))
print("```")


if __name__ == "__main__":
Expand Down

0 comments on commit eaa31e7

Please sign in to comment.