Exemplo n.º 1
0
def install_log():
    log_level = str(ConfigUtil.instance(
    ).log_level if hasattr(ConfigUtil.instance(), "log_level") else "INFO")
    # 分割log
    if sys.hexversion > 0x20700f0:
        logging.config.dictConfig(
            yaml.load(open(ConfigUtil.instance().loggingyaml, 'r')))
    else:
        log_file = 'logging.%s-%d.log' % (time.strftime(
            "%Y-%m-%d--%H-%M-%S", time.localtime()), os.getpid())
        timelog = logging.handlers.TimedRotatingFileHandler(
            log_file, 'midnight', 1, 0)
        logger.addHandler(timelog)
    logger = logging.getLogger()
    logger.setLevel(log_level)

    stdout_encoding()
Exemplo n.º 2
0
 def export(self, outfilename, dbname=None):
     if dbname == None:
         dbname = self.datasource.get_db_name()
     outputdir = ConfigUtil.instance().outputdir
     outpath = os.path.join(os.getcwd(), outputdir)
     mkdir_p(outpath)
     outpath = os.path.join(outpath, outfilename)
     self.export_output(outpath, dbname)
Exemplo n.º 3
0
import os

from reportlab.lib import fonts,colors
from reportlab.lib.pagesizes import letter, inch
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle,Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

from base_format import BaseFormat
from configutil import ConfigUtil


# ttf=os.path.join(os.getcwd(), 'templates',"simsun.ttf")
ttf=ConfigUtil.instance().pdfttf
ttfname = 'sim'
pdfmetrics.registerFont(TTFont(ttfname,ttf))

fonts.addMapping(ttfname, 0, 0,ttfname)
fonts.addMapping(ttfname, 0, 1, ttfname)

class PdfFormat(BaseFormat):

	def __init__(self, filename,headings):
		self.suffix = "pdf" #后缀
		super(PdfFormat, self).__init__(filename,headings)

		self.doc = SimpleDocTemplate(self.outname, pagesize=letter)
		self.elements = []
Exemplo n.º 4
0
def is_debug():
    return ConfigUtil.instance().log_level == "DEBUG"