Ejemplo n.º 1
0
	def __write_bug_report(self, command, username):
		log.Log(self.bug_report).error(
			'Bug report from {}\nMessage: {}\nTime: {}\n\n'.format(
				username,
				command[4:],
				self.now
			)
		)
Ejemplo n.º 2
0
def reporterror(error, logevent=False, logfilepath='c:/temp/reporterror.log'):
    """
    Report an error, using the Exception object.

    DESIGN:
    Module designed to handle error reporting and logging.

    PARAMETERS:
        - error
        Exception from the error handler; refer to the USE section.
        - logevent (default=False)
        Send the error to a log file.
        Note: use of this command assumes the log file is already
        created, and the header is already written.
        - logfilename (default='c:/temp/reporterror.log')
        File path to the log file.

    USE:
    > try:
    >     stuff here ...
    > except Exception as err:
    >     # REPORT / LOG ERROR
    >     reporterror.reporterror(err)
    """

    import sys
    import traceback
    import utils.log as log

    # GET TRACEBACK OBJECTS
    exc_type, exc_obj, exc_tb = sys.exc_info()
    filename, line_num, func_name, text = traceback.extract_tb(exc_tb)[-1]

    # USER NOTIFICATION
    print('')
    print('ERROR:\t%s' % error)
    print('TYPE:\t%s' % exc_type)
    print('FUNC:\t%s' % func_name)
    print('LINE:\t%s' % line_num)
    print('CMD:\t%s' % text)

    # LOG ERROR
    if logevent:
        # SETUP THE LOGGER
        _log = log.Log(filepath=logfilepath)
        # LOG ERROR
        _log.write(text='ERROR: %s; CMD: %s; METHOD: %s; LINE: %s' %
                   (error, text, func_name, line_num))

    # CLEANUP
    del (exc_type, exc_obj, exc_tb)
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
__time__ = '2018/2/27 15:23'
__author__ = '*****@*****.**'
import sys
from optparse import OptionParser
from warOperate import *
from utils import redisManager
from utils import log
from utils.utils import GetConf
from core import showOperate
from core import fileOperate

logger = log.Log()


class Saber(object):
    def __init__(self):
        self.redis_cli = redisManager.redis_cli()
        self.project_cf = GetConf("project.conf")
        self.vesionLib_cf = GetConf("saber.conf")
        #主字典,需传输
        self.operParam = {}
        #工程相关
        self.project = {}
        #文件相关
        self.file = {}
        #版本机相关
        self.versionLib = {}
        #master节点相关
        self.master = {}
        self.getProjectList()
Ejemplo n.º 4
0
    :homepage:  https://github.com/wufeifei/cobra
    :license:   MIT, see LICENSE for more details.
    :copyright: Copyright (c) 2017 Feei. All rights reserved
"""
import os
import time
import subprocess
import getpass
import logging
from app.models import CobraProjects, CobraTaskInfo
from app import db
from utils import config, decompress, log
from pickup import git
from engine import detection

log.Log()
logging = logging.getLogger(__name__)


class Scan(object):
    def __init__(self, target):
        """
        Set target
        :param target: compress(filename) version(repository)
        """
        self.target = target.strip()

    def compress(self):
        dc = decompress.Decompress(self.target)
        ret, result_d = dc.decompress()
        if ret is False:
Ejemplo n.º 5
0
	def __init__(self):
		self.log_file = 'error_log.txt'
		self.bug_report = 'bug_report.txt'
		self.logger = log.Log(self.log_file)
		self.now = datetime.datetime.now() + timedelta(hours=3)
Ejemplo n.º 6
0
def main():
    log.Log()
    debug = config.Config('cobra', 'debug').value
    web.debug = bool(debug)
    manager.run()
Ejemplo n.º 7
0
from utils import log
from bot.bot import Bot

if __name__ == '__main__':
	try:
		while True:
			Bot().run()
	except KeyboardInterrupt:
		pass
	except Exception as exc:
		print("Error: {}".format(exc))
		log.Log('error_log.txt').error(exc)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
@author: zhaogao
@license: (C) Copyright 2013-2018.
@contact: [email protected]
@software: web-uiautomation-selenium
@file: conftest
@time: 06/06/2018 1:39 PM
'''

import pytest
from selenium import webdriver
from utils import log, config_parser, path_parser

log = log.Log().getlog('Base')


@pytest.fixture(scope='function', autouse=True)
def driver(request):
    cp = config_parser.ConfigParser()
    pp = path_parser.PathParser()
    browser = cp.get_browser_name()
    url = cp.get_test_url()
    implicitly_wait = cp.get_implicitly_wait()

    log.info('init the driver:')
    try:
        if browser == 'Chrome':
            driver = webdriver.Chrome(executable_path=pp.get_chrome_driver())
        elif browser == 'Firefox':
Ejemplo n.º 9
0
 def init_log(self):
     date = datetime.datetime.now()
     filename = "./log/" + str(date.year) + '-' + str(
         date.month) + '-' + str(date.day) + ".log"
     gm.set("logging", log.Log(filename))
     gm.get("logging").setLevel(self._log_level)
Ejemplo n.º 10
0
#

#############################################
#
# Some utilities used in generating reports
#
#
#Darrell
#05/20/2009
#############################################

import datetime

from utils import log

log = log.Log()


def round_datetime(dt, round_to):
    if round_to == 'DAY':
        return dt.replace(hour=0, minute=0, second=0, microsecond=0)
    if round_to == 'HOUR':
        return dt.replace(minute=0, second=0, microsecond=0)
    if round_to == 'HALFHOUR':
        if dt.minute < 30:
            return dt.replace(minute=0, second=0, microsecond=0)
        else:
            return dt.replace(minute=30, second=0, microsecond=0)
    if round_to == '10MIN':
        return dt.replace(minute=int((dt.minute / 10) * 10),
                          second=0,