-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add meta cfg and mail send func
- Loading branch information
Showing
7 changed files
with
191 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ | |
} | ||
|
||
RUN_LOG_SIZE_LIMIT = 5 * 1024 * 1024 # 5MB | ||
|
||
SEND_MAIL_URL = '[email protected]' | ||
|
||
def exec_cmd(cmd: str) -> str: | ||
try: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,12 @@ def parse(self) -> bool: | |
config.git_commit(config.RPT_DIR, '[bot] new report!', | ||
True) # NOTE: need to set 'True' when in product env | ||
|
||
report.send_mail( | ||
('[email protected]', 'on'), | ||
f'{sub_cfg.dut_cfg.top}-{cmt_cfg.date}-{cmt_cfg.time}') | ||
report.send_mail( | ||
sub_cfg.meta_cfg.notif, | ||
f'{sub_cfg.dut_cfg.top}-{cmt_cfg.date}-{cmt_cfg.time}') | ||
return True | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
#!/bin/python | ||
import os | ||
import logging | ||
from typing import Tuple | ||
import config | ||
|
||
|
||
# helper class | ||
class Report(object): | ||
def __init__(self): | ||
|
@@ -17,12 +19,44 @@ def create_dir(repo: str): | |
os.system(f'mkdir -p {report.dut_rpt_dir}') | ||
|
||
|
||
def send_mail(notif_cfg: Tuple[str, str], commit: str): | ||
(rcpt_mail_url, send_ena) = notif_cfg | ||
if send_ena == 'on': | ||
cmd = 'curl --url smtp://smtp.qq.com' | ||
cmd += f' --mail-from {config.SEND_MAIL_URL}' | ||
cmd += f' --mail-rcpt {rcpt_mail_url}' | ||
os.system( | ||
f'cp -rf {config.TEMPLATE_DIR}/mail.info {config.DATA_DIR}/tmp_mail.info' | ||
) | ||
|
||
config.repl_str(f'{config.DATA_DIR}/tmp_mail.info', | ||
'TEMPLATE_SEND_MAIL_URL', config.SEND_MAIL_URL) | ||
|
||
config.repl_str(f'{config.DATA_DIR}/tmp_mail.info', | ||
'TEMPLATE_RCPT_MAIL_URL', rcpt_mail_url) | ||
|
||
config.repl_str(f'{config.DATA_DIR}/tmp_mail.info', 'TEMPLATE_NAME', | ||
rcpt_mail_url.split('@')[0]) | ||
|
||
config.repl_str(f'{config.DATA_DIR}/tmp_mail.info', 'TEMPLATE_COMMIT', | ||
commit) | ||
|
||
cmd += f' --upload-file {config.DATA_DIR}/tmp_mail.info' | ||
with open(f'{config.TEMPLATE_DIR}/mail.token', 'r', | ||
encoding='utf-8') as fp: | ||
for v in fp: | ||
cmd += f' --user {v.rstrip()}' | ||
print(cmd) | ||
os.system(cmd) | ||
|
||
|
||
def gen_state(stat: str): | ||
os.system(f'echo {stat} > {report.dut_rpt_dir}/state') | ||
|
||
|
||
def main(): | ||
logging.info(msg='[return report]') | ||
send_mail('[email protected]', '2024-03-11-09:52:51') | ||
|
||
|
||
if __name__ == '__main__': | ||
|
Oops, something went wrong.