Example #1
0
def init_logger(args):
    """
    init the logger
    :param args:
    :return:
    """

    log_title = '{project}'.format(project=args.project)
    log_dir = os.path.join(CUR_DIR, 'log', args.project)
    if args.suite and args.project != args.suite:
        log_title += '-{suite}'.format(suite=args.suite)
        log_dir = os.path.join(log_dir, args.suite)
    if args.case_list:
        log_title += '-{str_case}'.format(str_case='_'.join(args.case_list))
    if args.output:
        log_dir = os.path.join(CUR_DIR, args.output)

    log_name = log_title + '-' + STR_TIME
    log_path = os.path.join(log_dir, log_name + '.log')
    logger = log.get_logger(log_path, output_logfile=True, debug=args.debug, reset_logger=True)

    return logger
Example #2
0
@Email : [email protected]
"""

import os
import random
import json
import xlrd
from prettytable import PrettyTable
from concurrent.futures import ThreadPoolExecutor, as_completed

from storagetest.pkgs.fileops import FileOps
from storagetest.pkgs.dd import DD
from storagetest.libs import utils, log
from storagetest.libs.exceptions import PlatformError, NoSuchDir

logger = log.get_logger()


class RawUT(object):
    """RAW unit test"""
    def __init__(self, raw_device):
        self.raw_device = raw_device
        self.phase_list = []

    def verify(self):
        if os.name != "posix":
            raise PlatformError("Just support for linux machine!")
        if not os.path.isdir(self.raw_device):
            raise NoSuchDir(self.raw_device)

    def print_phase(self):
Example #3
0
try:  # Python 2.7+
    from logging import NullHandler
except ImportError:

    class NullHandler(logging.Handler):
        def emit(self, record):
            pass


from storagetest.libs import log

# ======================
# --- Global
# ======================
# logging_logger = logging.getLogger(__name__)
logging_logger = log.get_logger()


def _sleep_progressbar(sleep_time):
    """
    Print a progress bar, total value: sleep_time(seconds)
    :param sleep_time:
    :return:
    """

    widgets = [
        'Progress: ',
        Percentage(), ' ',
        Bar(marker=RotatingMarker('-=>')), ' ',
        ETA()
    ]