Пример #1
0
 def do(self):
     self.emit("device-finding-start")
     try:
         logger.info("Looking for scan devices ...")
         sys.stdout.flush()
         devices = pyinsane.get_devices()
         for device in devices:
             selected = (self.__selected_devid == device.name)
             name = self.__get_dev_name(device)
             logger.info("Device found: [%s] -> [%s]" % (name, device.name))
             sys.stdout.flush()
             self.emit('device-found', name, device.name, selected)
     finally:
         self.emit("device-finding-end")
Пример #2
0
 def do(self):
     self.emit("device-finding-start")
     try:
         print "Looking for scan devices ..."
         sys.stdout.flush()
         devices = pyinsane.get_devices()
         for device in devices:
             selected = (self.__selected_devid == device.name)
             name = self.__get_dev_name(device)
             print "Device found: [%s] -> [%s]" % (name, device.name)
             sys.stdout.flush()
             self.emit('device-found', name, device.name, selected)
     finally:
         self.emit("device-finding-end")
Пример #3
0
def get_scanner(config, preferred_sources=None):
    devid = config['scanner_devid'].value

    try:
        return _get_scanner(config, devid, preferred_sources)
    except pyinsane.SaneException as exc:
        logger.warning("Exception while configuring scanner: %s: %s",
                       type(exc), exc)
        if (int(exc.status) != pyinsane.SaneStatus.IO_ERROR
                and int(exc.status) != pyinsane.SaneStatus.UNSUPPORTED
                and int(exc.status) != pyinsane.SaneStatus.INVAL):
            raise
        # we didn't find the scanner at the given ID
        # but maybe there is only one, so we can guess the scanner to use
        devices = [x for x in pyinsane.get_devices() if x[:4] != "v4l:"]
        if len(devices) != 1:
            raise
        logger.info("Will try another scanner id: %s", devices[0].name)
        return _get_scanner(config, devices[0].name, preferred_sources)
Пример #4
0
def _get_scanner_info():
    import pyinsane.abstract_th as pyinsane
    devices = pyinsane.get_devices()
    return [ScannerInfo(name=d.name,
                        vendor=d.vendor,
                        model=d.model) for d in devices]
Пример #5
0
#for saving and loading settings
import cPickle as pickle

#the pyinotify (for USB insertion), and pygame (for joypad entries) listeners run in parallel, thus multiprocessing is used to run them together.
from multiprocessing import Process

#for notifying on insertion of USB memory or disk. in add_watch() include
#auto_add=True and watch for wm.addwatch('/MEDIA', pyinotify.IN_CREATE)
import pyinotify, pyttsx

#python sane library for scanning
import pyinsane.abstract_th as pyinsane
import PIL

#startup the scanning interface
devices = pyinsane.get_devices()
print devices
assert (len(devices) > 0)
device = devices[0]
scanner_id = device.name
device.options['mode'].value = 'Gray'
device.options['resolution'].value = 300

#startup the pygame system for joypad controls
pygame.init()
pygame.joystick.init()
j1 = pygame.joystick.Joystick(0)
j1.init()

#the text to speech engine using espeak. for user interface
engine = pyttsx.init()