Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
development:python [2023/07/31 22:15] – Zyzonix | development:python [2024/02/27 07:32] (current) – Zyzonix | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Python ===== | + | ====== Python |
===== Snippet list ===== | ===== Snippet list ===== | ||
Line 52: | Line 52: | ||
return mailText | return mailText | ||
- | def sendMail(self, hosts, awakeList, failedList, statusUnknownList): | + | def sendMail(self): |
if EMAILRECEIVER and EMAILSENDER and MAILSERVER and MAILSERVERPORT: | if EMAILRECEIVER and EMAILSENDER and MAILSERVER and MAILSERVERPORT: | ||
import smtplib | import smtplib | ||
Line 65: | Line 65: | ||
msgRoot = MIMEMultipart(" | msgRoot = MIMEMultipart(" | ||
msgRoot[' | msgRoot[' | ||
- | msgRoot[' | + | msgRoot[' |
msgRoot[' | msgRoot[' | ||
- | mailContent = MIMEText(wakeup.buildMail(self)) | + | mailContent = MIMEText(buildMail(self)) |
mailText = MIMEText(mailContent, | mailText = MIMEText(mailContent, | ||
msgRoot.attach(mailText) | msgRoot.attach(mailText) | ||
Line 119: | Line 119: | ||
| | ||
| | ||
- | mailContent = wakeup.buildMail(self) | + | mailContent = buildMail(self) |
mailText = MIMEText(mailContent, | mailText = MIMEText(mailContent, | ||
| | ||
Line 127: | Line 127: | ||
| | ||
except: | except: | ||
- | | + | |
- | | + | |
| | ||
else: | else: | ||
- | | + | |
</ | </ | ||
++++ | ++++ | ||
</ | </ | ||
- | //Sourced from: [[https:// | + | ==== Execute Bash command and capture output ==== |
+ | //The output will be captured when the command exited.// | ||
+ | <panel type=" | ||
+ | ++++ Show/Hide | | ||
+ | <code bash> | ||
+ | resultEncoded = subprocess.run("/ | ||
+ | result = resultEncoded.stdout.decode()[: | ||
+ | resultErr = resultEncoded.stderr.decode()[: | ||
+ | </ | ||
+ | ++++ | ||
+ | </ | ||
+ | |||
+ | //Sourced from [[https:// | ||
+ | |||
+ | ==== Get current Memory (RAM) information/ | ||
+ | //Using '' | ||
+ | <panel type=" | ||
+ | ++++ Show/Hide | | ||
+ | <code bash> | ||
+ | ++++ | ||
+ | </ | ||
+ | |||
+ | ==== FastAPI/ | ||
+ | === Change Log Format === | ||
+ | Adding the following lines to your '' | ||
+ | <code bash> | ||
+ | log_config = uvicorn.config.LOGGING_CONFIG | ||
+ | log_config[" | ||
+ | uvicorn.run(app, | ||
+ | </ | ||
+ | |||
+ | //Sourced from [[https:// |