File: test.py

package info (click to toggle)
python-cups 1.9.73-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 460 kB
  • sloc: ansic: 8,863; python: 325; makefile: 58
file content (34 lines) | stat: -rw-r--r-- 886 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
import cups

# Simple demonstration of cups module

def callback (prompt):
	print ("Password is required for this operation")
	password = raw_input (prompt)
	return password

def test_cups_module ():
	cups.setUser ("root")
	cups.setPasswordCB (callback)
	conn = cups.Connection ()
	printers = list(conn.getPrinters ().keys ())

	if 0:
		print ("Getting cupsd.conf")
		file ("cupsd.conf", "w")
		conn.getFile ("/admin/conf/cupsd.conf", "cupsd.conf")
		print ("Putting cupsd.conf")
		conn.putFile ("/admin/conf/cupsd.conf", "cupsd.conf")

	print ("Getting PPD for %s" % printers[len (printers) - 1])
	f = conn.getPPD (printers[len (printers) - 1])
	ppd = cups.PPD (f)
	ppd.markDefaults ()
	print (ppd.conflicts ())
	groups = ppd.optionGroups
	for group in groups:
		for opt in group.options:
			print (list (map (lambda x: x["text"], opt.choices)))

test_cups_module ()