示例#1
0
    def test_openprinting_unknownprinter(self):
        '''OpenPrintingDriverDB with an unknown printer'''

        backend = jockey.backend.Backend()
        backend.hardware = set([HardwareID('printer_deviceid',
            'MFG:FooTech;MDL:X-12;CMD:GDI')])
        backend.driver_dbs.append(jockey.detection.OpenPrintingDriverDB())
        backend.update_driverdb()
        self.assertEqual(backend.available(), [])
示例#2
0
    def test_openprinting_handler_binary(self):
        '''OpenPrintingDriverDB: PrinterDriverHandler for binary package'''

        backend = jockey.backend.Backend()
        backend.hardware = set([HardwareID('printer_deviceid',
            'MFG:EPSON;MDL:Epson ME 320')])
        backend.driver_dbs.append(jockey.detection.OpenPrintingDriverDB())
        orig_pkgsys = OSLib.inst.packaging_system
        try:
            OSLib.inst.packaging_system = lambda: 'apt'
            backend.update_driverdb()
        finally:
            OSLib.inst.packaging_system = orig_pkgsys
        handlers = backend.available()
        self.assertEqual(handlers, ['printer:epson-inkjet-printer-n10-nx127:1.0.0'])

        hi = backend.handler_info(handlers[0])
        self.assert_(hi['package'].startswith('epson-inkjet-'))
        self.assert_(hi['repository'].startswith('deb '))
        self.assert_('repository_sign_fp' in hi)
        self.assert_('driver_vendor' in hi)
示例#3
0
    def test_openprinting_handler_ppd(self):
        '''OpenPrintingDriverDB: PrinterDriverHandler for PPD package'''

        backend = jockey.backend.Backend()
        backend.hardware = set([HardwareID('printer_deviceid',
            'MFG:Hewlett-Packard;MDL:HP DesignJet 3500CP')])
        backend.driver_dbs.append(jockey.detection.OpenPrintingDriverDB())
        orig_pkgsys = OSLib.inst.packaging_system
        try:
            OSLib.inst.packaging_system = lambda: 'apt'
            backend.update_driverdb()
        finally:
            OSLib.inst.packaging_system = orig_pkgsys
        handlers = backend.available()
        self.assertEqual(handlers, ['printer:openprinting-ppds-postscript-hp:20091009'])

        hi = backend.handler_info(handlers[0])
        self.assertEqual(hi['package'], 'openprinting-ppds-postscript-hp')
        self.assertEqual(hi['free'], 'True')
        self.assert_('repository' in hi)
        self.assert_('driver_vendor' in hi)
示例#4
0
Note that this is just a gross hack for demo purposes. A real CLI should
inherit and properly implement jockey.ui.AbstractUI.'''

import sys

import jockey.backend
from jockey.oslib import OSLib

if len(sys.argv) not in (1,3):
    print >> sys.stderr, '''Usage:
  %(prog)  - list available drivers
  %(prog) enable <driver>  - enable driver
  %(prog) disable <driver> - disable driver
''' % { 'prog': sys.argv[0] }

OSLib.inst = OSLib()
backend = jockey.backend.Backend()

if len(sys.argv) == 1:
    print backend.available()
    sys.exit(0)

if sys.argv[1] == 'enable':
    backend.set_enabled(sys.argv[2], True)
elif sys.argv[1] == 'disable':
    backend.set_enabled(sys.argv[2], False)
else:
    print >> sys.stderr, 'Invalid mode', sys.argv[1]
    sys.exit(1)