Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.3 #82

Merged
merged 6 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# Changelog

## [1.2.2a2](https://github.com/NeonGeckoCom/skill-support_helper/tree/1.2.2a2) (2024-04-02)
## [1.2.3a2](https://github.com/NeonGeckoCom/skill-support_helper/tree/1.2.3a2) (2024-07-05)

[Full Changelog](https://github.com/NeonGeckoCom/skill-support_helper/compare/1.2.2a1...1.2.2a2)
[Full Changelog](https://github.com/NeonGeckoCom/skill-support_helper/compare/1.2.3a1...1.2.3a2)

**Fixed bugs:**

- \[BUG\] Attachments missing from support email [\#81](https://github.com/NeonGeckoCom/skill-support_helper/issues/81)
- \[BUG\] support email cannot be sent [\#79](https://github.com/NeonGeckoCom/skill-support_helper/issues/79)

**Merged pull requests:**

- Update test dependencies [\#76](https://github.com/NeonGeckoCom/skill-support_helper/pull/76) ([NeonDaniel](https://github.com/NeonDaniel))
- Update attachment truncation to avoid missing attachments [\#80](https://github.com/NeonGeckoCom/skill-support_helper/pull/80) ([NeonDaniel](https://github.com/NeonDaniel))

## [1.2.2a1](https://github.com/NeonGeckoCom/skill-support_helper/tree/1.2.2a1) (2024-02-05)
## [1.2.3a1](https://github.com/NeonGeckoCom/skill-support_helper/tree/1.2.3a1) (2024-05-20)

[Full Changelog](https://github.com/NeonGeckoCom/skill-support_helper/compare/1.2.1...1.2.2a1)
[Full Changelog](https://github.com/NeonGeckoCom/skill-support_helper/compare/1.2.2...1.2.3a1)

**Merged pull requests:**

- Support ovos-utils 0.1 [\#75](https://github.com/NeonGeckoCom/skill-support_helper/pull/75) ([NeonDaniel](https://github.com/NeonDaniel))
- Remove deprecated calls to `self.translate` [\#78](https://github.com/NeonGeckoCom/skill-support_helper/pull/78) ([NeonDaniel](https://github.com/NeonDaniel))



Expand Down
19 changes: 10 additions & 9 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def handle_contact_support(self, message: Message):
diagnostic_info["user_description"] = user_description
attachment_files = self._parse_attachments(
self._get_attachments(diagnostic_info))
if self.send_email(self.translate("email_title"),
if self.send_email(self.resources.render_dialog("email_title"),
self._format_email_body(diagnostic_info),
message, email_addr,
attachments=attachment_files):
Expand All @@ -103,7 +103,7 @@ def handle_contact_support(self, message: Message):
private=True)
return
LOG.error("Email failed to send, retry without attachments")
if self.send_email(self.translate("email_title"),
if self.send_email(self.resources.render_dialog("email_title"),
self._format_email_body(diagnostic_info),
message, email_addr):
self.speak_dialog("complete",
Expand All @@ -130,12 +130,13 @@ def _parse_attachments(files: list) -> dict:
byte_size = getsize(file)
if byte_size > 1000000:
LOG.info(f"{file} is >1MB, truncating")
with open(file, 'r+') as f:
lines = f.readlines()
with open(file, 'rb+') as f:
content = f.read()
trunc = content[-1000000:].split(b'\n', 1)[1]
f.seek(0)
f.writelines(lines[-50000:])
f.write(trunc)
f.truncate()

LOG.debug(f"{file} is {getsize(file)/1024/1024} MiB")
attachments[basename(file).replace('.log', '_log.txt')] = \
encode_file_to_base64_string(file)
except Exception as e:
Expand All @@ -148,11 +149,11 @@ def _format_email_body(self, diagnostics: dict) -> str:
:param diagnostics: diagnostic data to format into the email.
:returns: email body to send
"""
return '\n\n'.join((self.translate("email_intro",
{"email": self.support_email}),
return '\n\n'.join((self.resources.render_dialog("email_intro",
{"email": self.support_email}),
diagnostics.get('user_description') or
"No Description Provided",
self.translate("email_signature")))
self.resources.render_dialog("email_signature")))

def _check_service_status(self, message: Message = None) -> dict:
"""
Expand Down
10 changes: 8 additions & 2 deletions test/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
from neon_minerva.tests.skill_unit_test_base import SkillTestCase


os.environ["TEST_SKILL_ENTRYPOINT"] = "skill-support_helper.neongeckocom"


class TestSkill(SkillTestCase):
def test_00_skill_init(self):
# Test any parameters expected to be set in init or initialize methods
Expand Down Expand Up @@ -196,8 +199,11 @@ def test_parse_attachments(self):
original = f.readlines()
with open(test_outfile, 'r') as f:
truncated = f.readlines()
self.assertEqual(truncated, original[-50000:])
self.assertLess(getsize(test_outfile), input_size)
self.assertTrue(set(truncated) <= set(original)) # truncated is subset
self.assertIsInstance(int(truncated[0].split()[0]), int)
self.assertEqual(truncated[0].split()[1], '-')
self.assertEqual(truncated[-1], original[-1])
self.assertLess(getsize(test_outfile), 1000000)
os.remove(test_outfile)
os.remove(test_file)

Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

__version__ = "1.2.2"
__version__ = "1.2.3"
Loading