Ejemplo n.º 1
0
from ocflib.printing.printers import get_toner
from ocflib.printing.printers import PRINTERS

import labstats.db


if __name__ == '__main__':
    dest_dir = '/opt/stats/var/printing/oracle/'
    suffix = '.csv'

    for target in PRINTERS:
        now = str(time.time())

        try:
            toner = get_toner(target)
        except OSError as ex:
            print('Error reading data from {}, continuing to next...'.format(target))
            print('\t{}'.format(ex))
            continue

        with open(dest_dir + target + suffix, 'a+') as file:
            out_str = ','.join(map(str, (now,) + toner)) + '\n'
            file.write(out_str)
            print('Updated {target} with new value: {out_str}'.format(
                target=target,
                out_str=out_str,
            ))

        value, max_ = toner
        c = labstats.db.get_connection()
Ejemplo n.º 2
0
def test_get_toner(mock_snmp):
    assert get_toner('logjam') == (500, 24000)
Ejemplo n.º 3
0
import time

from ocflib.printing.printers import get_toner
from ocflib.printing.printers import PRINTERS

import labstats.db

if __name__ == '__main__':
    dest_dir = '/opt/stats/var/printing/oracle/'
    suffix = '.csv'

    for target in PRINTERS:
        now = str(time.time())

        try:
            toner = get_toner(target)
        except OSError as ex:
            print('Error reading data from {}, continuing to next...'.format(
                target))
            print('\t{}'.format(ex))
            continue

        with open(dest_dir + target + suffix, 'a+') as file:
            out_str = ','.join(map(str, (now, ) + toner)) + '\n'
            file.write(out_str)
            print('Updated {target} with new value: {out_str}'.format(
                target=target,
                out_str=out_str,
            ))

        value, max_ = toner
Ejemplo n.º 4
0
def test_get_toner(mock_snmp):
    assert get_toner('logjam') == [500, 24000]
Ejemplo n.º 5
0
def test_get_toner(mock_snmp):
    assert get_toner('pagefault') == (500, 24000)
Ejemplo n.º 6
0
#!/usr/bin/env python3
import ocflib.printing.printers as printers

if __name__ == '__main__':
    for printer in printers.PRINTERS:
        print(printer)
        print('\ttoner: {}'.format(printers.get_toner(printer)))
        print('\tmaint kit: {}'.format(printers.get_maintkit(printer)))