Esempio n. 1
0
#!/usr/bin/env python

import sys

sys.path += ['src']

import abstract as pyinsane

if __name__ == "__main__":
    for device in pyinsane.get_devices():
        print("%s" % (str(device)))

        for opt in device.options.values():
            print("  Option: %s" % (opt.name))
            print("    Title: %s" % (opt.title))
            print("    Desc: %s" % (opt.desc))
            print("    Type: %s" % (str(opt.val_type)))
            print("    Unit: %s" % (str(opt.unit)))
            print("    Size: %d" % (opt.size))
            print("    Capabilities: %s" % (str(opt.capabilities)))
            print("    Constraint type: %s" % (str(opt.constraint_type)))
            print("    Constraint: %s" % (str(opt.constraint)))
            try:
                print("    Value: %s" % (str(opt.value)))
            except pyinsane.SaneException as exc:
                # Some scanner allow changing a value, but not reading it.
                # For instance Canon Lide 110 allow setting the resolution,
                # but not reading it
                print("    Value: Failed to get the value: %s" % str(exc))

        print("")
Esempio n. 2
0
        print("  %s [-s] <output file (JPG)>" % sys.argv[0])
        print("")
        print("Options:")
        print("  -s : Generate intermediate images (may generate a lot of" " images !)")
        sys.exit(1)

    for arg in args[:]:
        if arg == "-s":
            steps = True
            args.remove(arg)

    output_file = args[0]
    print("Output file: %s" % output_file)

    print("Looking for scanners ...")
    devices = pyinsane.get_devices()
    if len(devices) <= 0:
        print("No scanner detected !")
        sys.exit(1)
    print("Devices detected:")
    print("- " + "\n- ".join([str(d) for d in devices]))

    print("")

    device = devices[0]
    print("Will use: %s" % str(device))

    print("")

    source = "Auto"
    # beware: don't select a source that is not in the constraint,