Пример #1
0
class CashBalanceReportFeed(object):
    """Gives an ability to run the cash balance report.
    """

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

        self.name = name or "CashBalancesReport"
        asof_orig = asof
        if asof is None:
            asof = datetime.datetime.now()
        else:
            asof = datetime.datetime(*time.strptime(asof, "%Y-%m%d")[:6])
        self.lpath = path
        if not os.path.isdir(self.lpath):
            os.makedirs(self.lpath)
        self.filename = asof.strftime(filename)
        self.lfilename = self._get_local_file_name(self.filename)
        self.timestamp = str(asof)[:10]
        self.report = CashBalanceReport(db_url, name=self.lfilename, asof=asof_orig)

    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)

    def _get_local_file_name(self, rfilename):
        date = datetime.date.today()
        return os.path.abspath(get_archive_filename(self.lpath, rfilename, date=date, source=self.name))
Пример #2
0
    def __init__(self, path, db_url, asof=None, name=None, filename="%Y%m%d_cashbalance_report.html"):

        self.name = name or "CashBalancesReport"
        asof_orig = asof
        if asof is None:
            asof = datetime.datetime.now()
        else:
            asof = datetime.datetime(*time.strptime(asof, "%Y-%m%d")[:6])
        self.lpath = path
        if not os.path.isdir(self.lpath):
            os.makedirs(self.lpath)
        self.filename = asof.strftime(filename)
        self.lfilename = self._get_local_file_name(self.filename)
        self.timestamp = str(asof)[:10]
        self.report = CashBalanceReport(db_url, name=self.lfilename, asof=asof_orig)