Skip to content

Commit

Permalink
0.12.3 (#57)
Browse files Browse the repository at this point in the history
* fix: fix ospath redaction in error reporting
* feat: report on platform and app (re)size
* feat: bump version
* fix: redacting uri AND ospath
  • Loading branch information
idoavrah authored Jan 9, 2024
1 parent cd17a02 commit 7dba4db
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,4 @@ state.txt

test/terraform.tfstate*
test/tftui.plan
test.py
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "tftui"
version = "0.12.2"
version = "0.12.3"
description = "Terraform Textual User Interface"
authors = ["Ido Avraham"]
license = "Apache-2.0"
Expand Down
22 changes: 14 additions & 8 deletions tftui/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import pyperclip
import os
import platform
import json
import traceback
import re
Expand Down Expand Up @@ -511,13 +512,14 @@ def _handle_exception(self, exception: Exception) -> None:
type(exception), exception, exception.__traceback__
)
)
self.error_message = re.sub(
r'"([^"]*)"',
lambda match: f'"{os.path.basename(match.group(1))}"',
self.error_message,
).split("\n")
super()._handle_exception(exception)

def _on_resize(self, event):
OutboundAPIs.post_usage(
"app resize", size=f"{event.size.width}x{event.size.height}"
)
super()._on_resize(event)


def parse_command_line() -> None:
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -592,7 +594,7 @@ def parse_command_line() -> None:

def main() -> None:
parse_command_line()
OutboundAPIs.post_usage("started application")
OutboundAPIs.post_usage("started application", platform=platform.platform())

result = ""
try:
Expand All @@ -607,9 +609,13 @@ def main() -> None:
if ApplicationGlobals.successful_termination:
OutboundAPIs.post_usage("exited successfully")
else:
error_message = app.error_message or str(result).strip()
error_message = re.sub(
r"(?<=[/\\])[^\s/\\]+(?=[/\\])",
"***",
app.error_message or str(result).strip(),
).split("\n")
logger.debug(error_message)
OutboundAPIs.post_usage("exited unsuccessfully", error_message)
OutboundAPIs.post_usage("exited unsuccessfully", error_message=error_message)

if OutboundAPIs.is_new_version_available:
print("\n*** New version available. ***")
Expand Down
4 changes: 3 additions & 1 deletion tftui/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def generate_handle():
)

@staticmethod
def post_usage(message: str, error_message="") -> None:
def post_usage(message: str, error_message="", platform="", size="") -> None:
if not OutboundAPIs.is_usage_tracking_enabled:
return
if not OutboundAPIs.generated_handle:
Expand All @@ -50,6 +50,8 @@ def post_usage(message: str, error_message="") -> None:
{
"tftui_version": OutboundAPIs.version,
"error_message": error_message,
"platform": platform,
"size": size,
},
)

Expand Down

0 comments on commit 7dba4db

Please sign in to comment.