示例#1
0
class CashBalanceReportFeed(object):
    """Gives an ability to run the cash balance report.
    """

    def __init__(self, path, db_url, output_path=None, asof=None, name=None, filename="%Y%m%d_cashbalance_report.html"):

        self.name = name or 'CashBalancesReport'
        asof = (asof and datetime.datetime.strptime(asof, '%Y-%m-%d')) or datetime.datetime.now()
        logging.info("Using asof date {}".format(asof)) 
        self.lpath = output_path or path
        logging.info("Using path {}".format(self.lpath))
        if not os.path.isdir(self.lpath):
            os.makedirs(self.lpath)
        self.filename = asof.strftime(filename)
        date_rel_path = asof.strftime(os.path.sep.join(['%Y', '%B', '%d']))
        make_path(self.lpath, date_rel_path)
        self.lfilename = os.path.join(self.lpath, date_rel_path, self.filename)
        self.timestamp = asof.strftime('%Y-%m-%d')
        self.report = CashBalanceReport(db_url, name=self.lfilename, asof=asof)

    def run(self):
        self.report.run()
        message = 'successfully generated cash balance report for %s' % self.timestamp
        dispatch_archive_event(
            sender = self,
            path = self.lfilename,
            rpath = self.filename,
            source = self.name,
            message = message
            )
示例#2
0
    def __init__(self, path, db_url, output_path=None, asof=None, name=None, filename="%Y%m%d_cashbalance_report.html"):

        self.name = name or 'CashBalancesReport'
        asof = (asof and datetime.datetime.strptime(asof, '%Y-%m-%d')) or datetime.datetime.now()
        logging.info("Using asof date {}".format(asof)) 
        self.lpath = output_path or path
        logging.info("Using path {}".format(self.lpath))
        if not os.path.isdir(self.lpath):
            os.makedirs(self.lpath)
        self.filename = asof.strftime(filename)
        date_rel_path = asof.strftime(os.path.sep.join(['%Y', '%B', '%d']))
        make_path(self.lpath, date_rel_path)
        self.lfilename = os.path.join(self.lpath, date_rel_path, self.filename)
        self.timestamp = asof.strftime('%Y-%m-%d')
        self.report = CashBalanceReport(db_url, name=self.lfilename, asof=asof)