#!/usr/bin/python
# fileName: runtest
# encoding = utf-8
import os,sys,getopt,re,time
os.popen('yum install -y unittest-xml-reporting')
import unittest,xmlrunner
def add_path():
if '/opt/mailcontrol/modules/TQPlugin/' not in sys.path:
sys.path.append('/opt/mailcontrol/modules/TQPlugin/')
if '/opt/mdmi/modules' not in sys.path:
sys.path.append('/opt/mdmi/modules')
print ''
def walk_dir(dir, modules, servers):
'''
Traverse all spcified directories along with sub-directories to present matched files and directories.
'''
matched_files = []
matched_dirs = []
comp = re.compile('^test_.+\.py$')
for thisdir, subdirs, fileshere in os.walk(dir):
os.chdir(thisdir)
for filename in fileshere:
if filename.endswith('.py'):
if thisdir not in sys.path:
sys.path.insert(0, thisdir)
if servers:
#m_file = re.search('^test_.+\.py$', filename)
if comp.search(filename):
file = open(filename, 'r')
line_note = ''
for i in range(20):
line = file.readline().strip('\n')
line_note = line_note + line
note_obj = re.search(r'(\"\"\").*?\1|(\'\'\').*?\2', line_note)
if note_obj:
note = note_obj.group()
for server in servers:
#note = __import__(m_file.group(1)).__doc__
#if not note: continue
if re.search('%s' %server, note):
if not modules:
#if re.search('^test_.+\.py$', filename):
if comp.search(filename):
matched_files.append(filename)
# fileName: runtest
# encoding = utf-8
import os,sys,getopt,re,time
os.popen('yum install -y unittest-xml-reporting')
import unittest,xmlrunner
def add_path():
if '/opt/mailcontrol/modules/TQPlugin/' not in sys.path:
sys.path.append('/opt/mailcontrol/modules/TQPlugin/')
if '/opt/mdmi/modules' not in sys.path:
sys.path.append('/opt/mdmi/modules')
print ''
def walk_dir(dir, modules, servers):
'''
Traverse all spcified directories along with sub-directories to present matched files and directories.
'''
matched_files = []
matched_dirs = []
comp = re.compile('^test_.+\.py$')
for thisdir, subdirs, fileshere in os.walk(dir):
os.chdir(thisdir)
for filename in fileshere:
if filename.endswith('.py'):
if thisdir not in sys.path:
sys.path.insert(0, thisdir)
if servers:
#m_file = re.search('^test_.+\.py$', filename)
if comp.search(filename):
file = open(filename, 'r')
line_note = ''
for i in range(20):
line = file.readline().strip('\n')
line_note = line_note + line
note_obj = re.search(r'(\"\"\").*?\1|(\'\'\').*?\2', line_note)
if note_obj:
note = note_obj.group()
for server in servers:
#note = __import__(m_file.group(1)).__doc__
#if not note: continue
if re.search('%s' %server, note):
if not modules:
#if re.search('^test_.+\.py$', filename):
if comp.search(filename):
matched_files.append(filename)