Permalink
Browse files

Generate capabilities from GCP into PPD file output

  • Loading branch information...
simoncadman committed Apr 20, 2013
1 parent 0b1cdb9 commit 4a427d746e657991474d5d9e84a01be31814bbc2
Showing with 25 additions and 4 deletions.
  1. +18 −3 dynamicppd.py
  2. +7 −1 printer.py
View
@@ -25,7 +25,7 @@ def showUsage():
requestors, storage = Auth.SetupAuth(False)
printer = Printer(requestors)
-printers = printer.getPrinters()
+printers = printer.getPrinters(True)
if printers == None:
print("ERROR: No Printers Found")
sys.exit(1)
@@ -45,6 +45,7 @@ def showUsage():
# find printer
for foundprinter in printers:
if ppdname == 'cupscloudprint:'+ foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '.ppd':
+ capabilities = []
# generate and output ppd
ppddetails = """*PPD-Adobe: "4.3"
*%%%% PPD file for Cloud Print with CUPS.
@@ -98,8 +99,22 @@ def showUsage():
*ColorModel Gray/Grayscale: "<</cupsColorSpace 0/cupsColorOrder 0/cupsCompression 0>>setpagedevice"
*ColorModel RGB/Color: "<</cupsColorSpace 1/cupsColorOrder 0/cupsCompression 0>>setpagedevice"
*ColorModel CMYK/CMYK: "<</cupsColorSpace 6/cupsColorOrder 0/cupsCompression 0>>setpagedevice"
-*CloseUI: *ColorModel
-*DefaultFont: Courier
+*CloseUI: *ColorModel"""
+
+ #print foundprinter['fulldetails']
+ if 'capabilities' in foundprinter['fulldetails']:
+ for capability in foundprinter['fulldetails']['capabilities']:
+ if capability['type'] == 'Feature':
+ ppddetails += '*OpenUI *' + capability['name']+': PickOne' + "\n"
+ for option in capability['options']:
+ ppddetails += '*' + capability['name'] + ': ' + option['displayName'] + ' "' + option['name'] + '"' + "\n"
+ ppddetails += '*CloseUI: *' + capability['displayName'] + "\n"
+ elif capability['type'] == 'ParameterDef':
+ pass
+ #print option['displayName']
+ #print capability['psf:MinValue'], capability['psf:MaxValue']
+
+ ppddetails += """*DefaultFont: Courier
*Font AvantGarde-Book: Standard "(1.05)" Standard ROM
*Font AvantGarde-BookOblique: Standard "(1.05)" Standard ROM
*Font AvantGarde-Demi: Standard "(1.05)" Standard ROM
View
@@ -35,7 +35,7 @@ def __init__( self, requestors ):
else:
self.requestors = [requestors]
- def getPrinters(self):
+ def getPrinters(self, fulldetails = False):
"""Fetch a list of printers
Returns:
@@ -47,6 +47,12 @@ def getPrinters(self):
if 'printers' in responseobj and len(responseobj['printers']) > 0:
for printer in responseobj['printers']:
printer['account'] = requestor.getAccount()
+
+ # fetch all details - search doesnt return all capabilities
+ if fulldetails:
+ self.requestor = requestor
+ details = self.getPrinterDetails( printer['id'] )
+ printer['fulldetails'] = details['printers'][0]
allprinters.append(printer)
return allprinters

0 comments on commit 4a427d7

Please sign in to comment.