Exemplo n.º 1
0
def filenameOUT(basename=None):
    """
    File name for outgoing stats for today or other day.
    """
    if basename is None:
        basename = misc.gmtime2str('%d%m%y')
    return os.path.join(settings.BandwidthOutDir(), basename)
Exemplo n.º 2
0
def files2send():
    """
    Return a list of file names to be read and send later.

    Sent files are market with ".sent" extension and skipped here.
    """
    lg.out(6, 'bandwidth.files2send')
    listIN = []
    listOUT = []
    for filename in os.listdir(settings.BandwidthInDir()):
        # if we sent the file - skip it
        if filename.endswith('.sent'):
            continue
        # if filename is not a date - skip it
        if len(filename) != 6:
            continue
        # skip today bandwidth - it is still counting, right?
        if filename == misc.gmtime2str('%d%m%y'):
            continue
        filepath = os.path.join(settings.BandwidthInDir(), filename)
        # if filepath == filenameIN():
        #     continue
        listIN.append(filepath)
    for filename in os.listdir(settings.BandwidthOutDir()):
        if filename.endswith('.sent'):
            continue
        if len(filename) != 6:
            continue
        if filename == misc.gmtime2str('%d%m%y'):  # time.strftime('%d%m%y'):
            continue
        filepath = os.path.join(settings.BandwidthOutDir(), filename)
        # if filepath == filenameOUT():
        #     continue
        listOUT.append(filepath)
    lg.out(
        6, 'bandwidth.files2send listIN=%d listOUT=%d' %
        (len(listIN), len(listOUT)))
    for i in listIN:
        lg.out(6, '  ' + i)
    for i in listOUT:
        lg.out(6, '  ' + i)
    return listIN, listOUT