summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/controller/settings/mail_settings.py
diff options
context:
space:
mode:
authorMatthewLi <matthew.lijun@huawei.com>2016-03-25 03:55:53 -0400
committerMatthewLi <matthew.lijun@huawei.com>2016-03-25 03:55:53 -0400
commitf84c8dcc22f1499128893e62b0e15b4b592c47ba (patch)
treeee14029aa59c076fdfde1c504a385f3389477a6a /vstf/vstf/controller/settings/mail_settings.py
parent7ba76747d55669e2bbaf70a3061e1c0b5dea912e (diff)
adjust project directories
JIRA: BOTTLENECK-56 Change-Id: Ic9acad5eaa4917093bdb85a80960f796f5b4ba7f Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
Diffstat (limited to 'vstf/vstf/controller/settings/mail_settings.py')
-rw-r--r--vstf/vstf/controller/settings/mail_settings.py113
1 files changed, 0 insertions, 113 deletions
diff --git a/vstf/vstf/controller/settings/mail_settings.py b/vstf/vstf/controller/settings/mail_settings.py
deleted file mode 100644
index db01097f..00000000
--- a/vstf/vstf/controller/settings/mail_settings.py
+++ /dev/null
@@ -1,113 +0,0 @@
-##############################################################################
-# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-import logging
-import pprint
-
-import vstf.controller.settings.settings as sets
-import vstf.common.decorator as deco
-from vstf.common.input import raw_choice
-
-LOG = logging.getLogger(__name__)
-
-
-class MailSettings(sets.Settings):
- def __init__(self, path="/etc/vstf", filename="reporters.mail.mail-settings", mode=sets.SETS_DEFAULT):
- super(MailSettings, self).__init__(path, filename, mode)
-
- def _register_func(self):
- super(MailSettings, self)._register_func()
- body = set(
- self._fset['body'].keys()
- )
- LOG.debug(body)
- for item in body:
- item = item.encode()
- func_name = "set_%s" % item
- setattr(self, func_name, self._setting_file(func_name, self._mset['body'], self._fset['body'], item))
- other = {"attach", "content", "subtype"}
- for item in other:
- func_name = "mset_%s" % item
- setattr(self, func_name, self._setting_memory(func_name, self._mset['body'], item))
-
- LOG.debug(self.__dict__)
-
- def sinput(self):
- if raw_choice("if set mail server"):
- server = self.raw_server()
- self.set_server(server)
-
- if raw_choice("if set mail body"):
- body = self.raw_body()
- self.set_body(body)
- print "%s set finish: " % (self._filename)
- print "+++++++++++++++++++++++++++++++++++++++++"
- pprint.pprint(self.settings, indent=4)
- print "+++++++++++++++++++++++++++++++++++++++++"
-
- @deco.vstf_input("password", types=str)
- @deco.vstf_input("username", types=str)
- @deco.vstf_input('host', types=str)
- def raw_server(self):
- print "---------------------------------------"
- print "Please vstf set mail server info like:"
- print " 'host': 'localhost',"
- print " 'username': 'user',['\\n' = None]"
- print " 'password': '******',['\\n' = None]"
- print "---------------------------------------"
-
- @deco.vstf_input("subject", types=str, default='vstf mail')
- @deco.vstf_input("bcc", types=list, default=[])
- @deco.vstf_input("cc", types=list, default=[])
- @deco.vstf_input("to", types=list, default=[])
- @deco.vstf_input('from', types=list, default=['vstf_from@vstf.com'])
- def raw_body(self):
- print "----------------------------------------------------"
- print "Please vstf set mail server info like:"
- print " 'from': ['vstf_from@vstf.com'],"
- print " 'to': ['vstf_to@vstf.com'],"
- print " 'cc': ['vstf_cc@vstf.com']"
- print " 'bcc': ['vstf_bcc@vstf.com']"
- print " 'subject': Vstf Performance Test Report"
- print "----------------------------------------------------"
-
-
-def unit_test():
- from vstf.common.log import setup_logging
- setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-mail-settings.log", clevel=logging.INFO)
-
- mail_settings = MailSettings()
- mail_settings.sinput()
-
- return
-
- mail_server = {
- "host": "localhost",
- "username": None,
- "password": None
- }
- mail_settings.set_server(mail_server)
-
- subject = "Virtual Switching Performance Test Report"
- mail_settings.set_subject(subject)
-
- subtype = "plain"
- mail_settings.mset_subtype(subtype)
-
- attach_list = []
- mail_settings.mset_attach(attach_list)
-
- content = "this is a test"
- mail_settings.mset_content(content)
-
- LOG.info(mail_settings.settings)
-
-
-if __name__ == '__main__':
- unit_test()