Skip to content
Permalink
Browse files

Added start of dynamic generation of pdd

  • Loading branch information
simoncadman committed Apr 14, 2013
1 parent 2b199ac commit 5cf2ed4aa705f80281e09e93209cdd628a26a9f3
Showing with 126 additions and 1 deletion.
  1. +126 −1 dynamicppd.py
@@ -15,4 +15,129 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

print '"cupscloudprint:CupsCloudPrintTest.ppd" en "Google" "Google Cloud Print 2.0" "DRV:GCP;"'
import sys
from auth import Auth
from printer import Printer

def showUsage():
sys.stderr.write("ERROR: Usage: " + sys.argv[0] + " [list|cat drivername]\n")
sys.exit(1)

requestors, storage = Auth.SetupAuth(False)
printer = Printer(requestors)
printers = printer.getPrinters()
if printers == None:
print("ERROR: No Printers Found")
sys.exit(1)

if ( len(sys.argv) < 2 ):
showUsage()

if sys.argv[1] == 'list':
for foundprinter in printers:
print('"cupscloudprint:' + foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '.ppd" en "Google" "Google Cloud Print 2.0" "DRV:GCP;"')

elif sys.argv[1] == 'cat':
if len(sys.argv) == 2 or sys.argv[2] == "":
showUsage()
else:
ppdname = sys.argv[2]
# find printer
for foundprinter in printers:
if ppdname == foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '.ppd':
# generate and output ppd
ppddetails = {
'*PPD-Adobe' : '"4.3"',
'*FormatVersion' : '"4.3"',
'*FileVersion' : '"1.0"',
'*LanguageVersion' : 'English',
'*LanguageEncoding': 'ISOLatin1',
'*PCFileName' : ppdname,
'*Product' : '"(Google Cloud Print)"',
'*Manufacturer' : '"Google"',
'*ModelName' : '"Google Cloud Print"',
'*ShortNickName' : '"Google Cloud Print"',
'*NickName' : '"Google Cloud Print, 2.0"',
'*PSVersion' : '"(1) 0"',
'*LanguageLevel' : '"3"',
'*ColorDevice' : 'True',
'*DefaultColorSpace' : 'RGB',
'*FileSystem' : 'False',
'*Throughput' : '"1"',
'*LandscapeOrientation' : 'Minus90',
'*TTRasterizer' : 'Type42',
'*1284DeviceID' : '"MFG:Google;MDL:Cloud Print;DES:GoogleCloudPrint;"',
'*cupsLanguages' : '"en"',
'*OpenUI *PageSize/Media Size' : 'PickOne',
'*OrderDependency' : '10 AnySetup *PageSize',
'*DefaultPageSize' : 'Letter',
'*PageSize Letter/US Letter' : '"<</PageSize[612 792]/ImagingBBox null>>setpagedevice"',
'*PageSize Legal/US Legal' : '"<</PageSize[612 1008]/ImagingBBox null>>setpagedevice"',
'*PageSize A4/A4' : '"<</PageSize[595 842]/ImagingBBox null>>setpagedevice"',
'*CloseUI' : '*PageSize',
'*OpenUI *PageRegion/Media Size' : 'PickOne',
'*OrderDependency' : '10 AnySetup *PageRegion',
'*DefaultPageRegion' : 'Letter',
'*PageRegion Letter/US Letter' : '"<</PageSize[612 792]/ImagingBBox null>>setpagedevice"',
'*PageRegion Legal/US Legal' : '"<</PageSize[612 1008]/ImagingBBox null>>setpagedevice"',
'*PageRegion A4/A4' : '"<</PageSize[595 842]/ImagingBBox null>>setpagedevice"',
'*CloseUI' : '*PageRegion',
'*DefaultImageableArea' : 'Letter',
'*ImageableArea Letter/US Letter' : '"0 0 612 792"',
'*ImageableArea Legal/US Legal' : '"0 0 612 1008"',
'*ImageableArea A4/A4' : '"0 0 595 842"',
'*DefaultPaperDimension' : 'Letter',
'*PaperDimension Letter/US Letter' : '"612 792"',
'*PaperDimension Legal/US Legal' : '"612 1008"',
'*PaperDimension A4/A4' : '"595 842"',
'*OpenUI *ColorModel/Color Mode' : 'PickOne',
'*OrderDependency' : '10 AnySetup *ColorModel',
'*DefaultColorModel' : 'RGB',
'*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',
'*Font AvantGarde-Book' : 'Standard "(1.05)" Standard ROM',
'*Font AvantGarde-BookOblique' : 'Standard "(1.05)" Standard ROM',
'*Font AvantGarde-Demi' : 'Standard "(1.05)" Standard ROM',
'*Font AvantGarde-DemiOblique' : 'Standard "(1.05)" Standard ROM',
'*Font Bookman-Demi' : 'Standard "(1.05)" Standard ROM',
'*Font Bookman-DemiItalic' : 'Standard "(1.05)" Standard ROM',
'*Font Bookman-Light' : 'Standard "(1.05)" Standard ROM',
'*Font Bookman-LightItalic' : 'Standard "(1.05)" Standard ROM',
'*Font Courier' : 'Standard "(1.05)" Standard ROM',
'*Font Courier-Bold' : 'Standard "(1.05)" Standard ROM',
'*Font Courier-BoldOblique' : 'Standard "(1.05)" Standard ROM',
'*Font Courier-Oblique' : 'Standard "(1.05)" Standard ROM',
'*Font Helvetica' : 'Standard "(1.05)" Standard ROM',
'*Font Helvetica-Bold' : 'Standard "(1.05)" Standard ROM',
'*Font Helvetica-BoldOblique' : 'Standard "(1.05)" Standard ROM',
'*Font Helvetica-Narrow' : 'Standard "(1.05)" Standard ROM',
'*Font Helvetica-Narrow-Bold' : 'Standard "(1.05)" Standard ROM',
'*Font Helvetica-Narrow-BoldOblique' : 'Standard "(1.05)" Standard ROM',
'*Font Helvetica-Narrow-Oblique' : 'Standard "(1.05)" Standard ROM',
'*Font Helvetica-Oblique' : 'Standard "(1.05)" Standard ROM',
'*Font NewCenturySchlbk-Bold' : 'Standard "(1.05)" Standard ROM',
'*Font NewCenturySchlbk-BoldItalic' : 'Standard "(1.05)" Standard ROM',
'*Font NewCenturySchlbk-Italic' : 'Standard "(1.05)" Standard ROM',
'*Font NewCenturySchlbk-Roman' : 'Standard "(1.05)" Standard ROM',
'*Font Palatino-Bold' : 'Standard "(1.05)" Standard ROM',
'*Font Palatino-BoldItalic' : 'Standard "(1.05)" Standard ROM',
'*Font Palatino-Italic' : 'Standard "(1.05)" Standard ROM',
'*Font Palatino-Roman' : 'Standard "(1.05)" Standard ROM',
'*Font Symbol' : 'Special "(001.005)" Special ROM',
'*Font Times-Bold' : 'Standard "(1.05)" Standard ROM',
'*Font Times-BoldItalic' : 'Standard "(1.05)" Standard ROM',
'*Font Times-Italic' : 'Standard "(1.05)" Standard ROM',
'*Font Times-Roman' : 'Standard "(1.05)" Standard ROM',
'*Font ZapfChancery-MediumItalic' : 'Standard "(1.05)" Standard ROM',
'*Font ZapfDingbats' : 'Special "(001.005)" Special ROM'
}
for key in ppddetails:
print(key + ': ' + ppddetails[key])
sys.exit(0)

# no printers found
print("ERROR: PPD " + ppdname +" Not Found")
sys.exit(1)

0 comments on commit 5cf2ed4

Please sign in to comment.
You can’t perform that action at this time.