Permalink
Browse files

Only fetch list of ppds once then filter, at least halves upgrade scr…

…ipt time when multiple printers
  • Loading branch information...
simoncadman committed Jan 26, 2014
1 parent a59e9b2 commit 3298b299d72c4e575881c092ed319a64dfb3bd55
Showing with 20 additions and 11 deletions.
  1. +1 −1 backend.py
  2. +1 −1 deleteaccount.py
  3. +1 −1 dynamicppd.py
  4. +1 −1 listcloudprinters.py
  5. +1 −1 listdrivefiles.py
  6. +1 −1 reportissues.py
  7. +1 −1 setupcloudprint.py
  8. +1 −1 submitjob.py
  9. +12 −3 upgrade.py
View
@@ -20,7 +20,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140126 174301"
+ CCPVersion = "20140126 180729"
print "CUPS Cloud Print CUPS Backend Version " + CCPVersion
sys.exit(0)
View
@@ -21,7 +21,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140126 174301"
+ CCPVersion = "20140126 180729"
print "CUPS Cloud Print Delete Account Script Version " + CCPVersion
sys.exit(0)
View
@@ -19,7 +19,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140126 174301"
+ CCPVersion = "20140126 180729"
print "CUPS Cloud Print Dynamic PPD Generator Version " + CCPVersion
sys.exit(0)
View
@@ -21,7 +21,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140126 174301"
+ CCPVersion = "20140126 180729"
print "CUPS Cloud Print Printer Lister Version " + CCPVersion
sys.exit(0)
View
@@ -21,7 +21,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140126 174301"
+ CCPVersion = "20140126 180729"
print "CUPS Cloud Print Printer Drive Lister Version " + CCPVersion
sys.exit(0)
View
@@ -19,7 +19,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140126 174301"
+ CCPVersion = "20140126 180729"
print "CUPS Cloud Print Issue Reporting Script Version " + CCPVersion
sys.exit(0)
View
@@ -21,7 +21,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140126 174301"
+ CCPVersion = "20140126 180729"
print "CUPS Cloud Print Setup Script Version " + CCPVersion
sys.exit(0)
View
@@ -21,7 +21,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140126 174301"
+ CCPVersion = "20140126 180729"
print "CUPS Cloud Print Submit Job Version " + CCPVersion
sys.exit(0)
View
@@ -37,7 +37,7 @@
sys.stderr.write("If you are upgrading from version 20131013 or earlier you should be aware that the scripts have moved from /usr/lib/cloudprint-cups to /usr/share/cloudprint-cups\n")
# line below is replaced on commit
-CCPVersion = "20140126 174301"
+CCPVersion = "20140126 180729"
if len(sys.argv) == 2 and sys.argv[1] == 'version':
print "CUPS Cloud Print Upgrade Script Version " + CCPVersion
@@ -70,13 +70,22 @@
sys.stderr.write("lpadmin command not found, you may need to run this script as root\n")
sys.exit(1)
+try:
+ print "Fetching list of available ppds..."
+ allppds = connection.getPPDs()
+ print "List retrieved successfully"
+except Exception, e:
+ sys.stderr.write("Error connecting to CUPS: " + str(e) + "\n")
+ sys.exit(1)
+
for device in cupsprinters:
try:
if ( cupsprinters[device]["device-uri"].find("cloudprint://") == 0 ):
print "Updating " + cupsprinters[device]["printer-info"]
ppdid = 'MFG:GOOGLE;DRV:GCP;CMD:POSTSCRIPT;MDL:' + cupsprinters[device]["device-uri"] + ';'
- ppds = connection.getPPDs(ppd_device_id=ppdid)
- printerppdname, printerppd = ppds.popitem()
+ for ppd in allppds:
+ if allppds[ppd]['ppd-device-id'] == ppdid:
+ printerppdname = ppd
p = subprocess.Popen(["lpadmin", "-p", cupsprinters[device]["printer-info"], "-m", printerppdname], stdout=subprocess.PIPE)
output = p.communicate()[0]
result = p.returncode

0 comments on commit 3298b29

Please sign in to comment.