Skip to content
Open
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
19 changes: 8 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import subprocess
import getpass
import time
import pdb
import configparser
import sys
import logging
Expand Down Expand Up @@ -46,7 +45,7 @@ def refresh_repos():
logging.warning("An error occured while refreshing repos. See output below.")
print(err.output)
output = err.output

return output

def list_patches():
Expand All @@ -57,7 +56,7 @@ def list_patches():
logging.warning("An error occured while listing patches. See output below.")
print(err.output)
output = err.output

return output

def install_patches(categories, with_interactive):
Expand Down Expand Up @@ -96,7 +95,7 @@ def install_patches(categories, with_interactive):
else:
logging.warning("An error occured while installing patches. See output below.")
print(err.output)

return output

def send_email(content, subject, email_to):
Expand All @@ -116,24 +115,22 @@ def send_telegram(content, token, chat_id):
return r

def compose_body(time_start, refresh_output, install_output, list_output):
if install_output == None:
if install_output is None:
outputs = {'refresh_output': refresh_output,
'list_output': list_output}
else:
outputs = {'refresh_output': refresh_output,
'install_output': install_output,
'list_output': list_output}

# Convert bytes to strings if needed.
for key, value in outputs.items():
if type(value) is bytes:
if isinstance(value, bytes):
outputs[key] = str(value, 'utf-8')

head = f"JOB STARTED: {time_start}"


# Combine outputs to create body of message.
body = "\n".join(outputs.values())

return body

if __name__ == "__main__":
Expand Down