Skip to content
Permalink
Browse files

Fixed ppd names to contain id, upgrade script adds id to uris

  • Loading branch information
simoncadman committed Feb 21, 2014
1 parent 4b99f3f commit 90f5cc19c05af513e7b24730269481bc17d2a87b
Showing with 46 additions and 18 deletions.
  1. +1 −1 backend.py
  2. +1 −1 deleteaccount.py
  3. +3 −3 dynamicppd.py
  4. +1 −1 listcloudprinters.py
  5. +1 −1 listdrivefiles.py
  6. +5 −4 printer.py
  7. +2 −2 reportissues.py
  8. +1 −1 setupcloudprint.py
  9. +31 −4 upgrade.py
@@ -22,7 +22,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140221 192004"
CCPVersion = "20140221 220925"
print "CUPS Cloud Print CUPS Backend Version " + CCPVersion
sys.exit(0)

@@ -22,7 +22,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140221 192004"
CCPVersion = "20140221 220925"
print "CUPS Cloud Print Delete Account Script Version " + CCPVersion
sys.exit(0)

@@ -20,7 +20,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140221 192004"
CCPVersion = "20140221 220925"
print "CUPS Cloud Print Dynamic PPD Generator Version " + CCPVersion
sys.exit(0)

@@ -55,7 +55,7 @@ def showUsage():
print "ERROR: No Printers Found"
sys.exit(1)
for foundprinter in printers:
print '"cupscloudprint:' + foundprinter['account'].encode('ascii', 'replace').replace(' ', '-') +':' + foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '.ppd" en "Google" "' + foundprinter['name'].encode('ascii', 'replace') + ' (' + foundprinter['account'] + ')" "MFG:GOOGLE;DRV:GCP;CMD:POSTSCRIPT;MDL:' + printer.printerNameToUri( foundprinter['account'], foundprinter['name'], foundprinter['id'] ) +';"'
print '"cupscloudprint:' + foundprinter['account'].encode('ascii', 'replace').replace(' ', '-') +':' + foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '-' + foundprinter['id'].encode('ascii', 'replace').replace(' ', '-') + '.ppd" en "Google" "' + foundprinter['name'].encode('ascii', 'replace') + ' (' + foundprinter['account'] + ')" "MFG:GOOGLE;DRV:GCP;CMD:POSTSCRIPT;MDL:' + printer.printerNameToUri( foundprinter['account'], foundprinter['name'], foundprinter['id'] ) +';"'

elif sys.argv[1] == 'cat':
if len(sys.argv) == 2 or sys.argv[2] == "":
@@ -80,7 +80,7 @@ def showUsage():

# find printer
for foundprinter in printers:
if ppdname == 'cupscloudprint:' + foundprinter['account'].encode('ascii', 'replace').replace(' ', '-') +':' + foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '.ppd':
if ppdname == 'cupscloudprint:' + foundprinter['account'].encode('ascii', 'replace').replace(' ', '-') +':' + foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '-' + foundprinter['id'].encode('ascii', 'replace').replace(' ', '-') + '.ppd':
capabilities = []
# generate and output ppd
language = "en"
@@ -26,7 +26,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140221 192004"
CCPVersion = "20140221 220925"
print "CUPS Cloud Print Printer Lister Version " + CCPVersion
sys.exit(0)

@@ -22,7 +22,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140221 192004"
CCPVersion = "20140221 220925"
print "CUPS Cloud Print Printer Drive Lister Version " + CCPVersion
sys.exit(0)

@@ -40,10 +40,11 @@ def __init__( self, requestors ):
Args:
requestors: list or cloudprintrequestor instance, A list of requestors, or a single requestor to use for all Cloud Print requests.
"""
if isinstance(requestors, list):
self.requestors = requestors
else:
self.requestors = [requestors]
if requestors != None:
if isinstance(requestors, list):
self.requestors = requestors
else:
self.requestors = [requestors]

def getCUPSPrintersForAccount(self, account):
import cups
@@ -21,7 +21,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140221 192004"
CCPVersion = "20140221 220925"
print "CUPS Cloud Print Issue Reporting Script Version " + CCPVersion
sys.exit(0)

@@ -47,7 +47,7 @@
print ""
print foundprinter['fulldetails']
print "\n"
p = subprocess.Popen([os.path.join(libpath,'dynamicppd.py'), 'cat', ('cupscloudprint:' + foundprinter['account'].encode('ascii', 'replace').replace(' ', '-') +':' + foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '.ppd').lstrip('-')], stdout=subprocess.PIPE)
p = subprocess.Popen([os.path.join(libpath,'dynamicppd.py'), 'cat', ('cupscloudprint:' + foundprinter['account'].encode('ascii', 'replace').replace(' ', '-') +':' + foundprinter['name'].encode('ascii', 'replace').replace(' ', '-') + '-' + foundprinter['id'].encode('ascii', 'replace').replace(' ', '-') + '.ppd').lstrip('-')], stdout=subprocess.PIPE)
ppddata = p.communicate()[0]
result = p.returncode
tempfile = open('/tmp/.ppdfile', 'w')
@@ -22,7 +22,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140221 192004"
CCPVersion = "20140221 220925"
print "CUPS Cloud Print Setup Script Version " + CCPVersion
sys.exit(0)

@@ -17,12 +17,13 @@

if __name__ == '__main__': # pragma: no cover

import sys, cups, subprocess, os, json, logging
import sys, cups, subprocess, os, json, logging, urllib
from oauth2client import client
from oauth2client import multistore_file
from auth import Auth

from ccputils import Utils
from printer import Printer
Utils.SetupLogging()

try:
@@ -32,8 +33,15 @@
except:
logging.warning("Failed to change ownerships and permissions of logfile")

requestors, storage = Auth.SetupAuth(False)
if requestors == False:
sys.stderr.write("ERROR: config is invalid or missing\n")
logging.error("backend tried to run with invalid config");
sys.exit(1)
printerItem = Printer(requestors)

# line below is replaced on commit
CCPVersion = "20140221 192004"
CCPVersion = "20140221 220925"

if len(sys.argv) == 2 and sys.argv[1] == 'version':
print "CUPS Cloud Print Upgrade Script Version " + CCPVersion
@@ -79,8 +87,27 @@
for device in cupsprinters:
try:
if ( cupsprinters[device]["device-uri"].find("cloudprint://") == 0 ):
print "Updating " + cupsprinters[device]["printer-info"]
printername, account, printerid = printerItem.parseURI(cupsprinters[device]["device-uri"])
if printerid == None:
# update with new uri
print "Updating " + cupsprinters[device]["printer-info"], "with new id uri format"
printerid, requestor = printerItem.getPrinterIDByURI(cupsprinters[device]["device-uri"])
if printerid != None:
newDeviceURI = printerItem.printerNameToUri(urllib.unquote(account), urllib.unquote(printername), printerid)
cupsprinters[device]["device-uri"] = newDeviceURI
p = subprocess.Popen(["lpadmin", "-p", cupsprinters[device]["printer-info"].lstrip('-'), "-v", newDeviceURI], stdout=subprocess.PIPE)
output = p.communicate()[0]
result = p.returncode
sys.stderr.write(output)
else:
print cupsprinters[device]["printer-info"], "not found, you should delete and re-add this printer"
continue
else:
print "Updating " + cupsprinters[device]["printer-info"]

ppdid = 'MFG:GOOGLE;DRV:GCP;CMD:POSTSCRIPT;MDL:' + cupsprinters[device]["device-uri"] + ';'

# just needs updating
printerppdname = None
for ppd in allppds:
if allppds[ppd]['ppd-device-id'] == ppdid:
@@ -91,6 +118,6 @@
result = p.returncode
sys.stderr.write(output)
else:
print cupsprinters[device]["printer-info"] + " not found"
print cupsprinters[device]["printer-info"], "not found, you should delete and re-add this printer"
except Exception, e:
sys.stderr.write("Error connecting to CUPS: " + str(e) + "\n")

0 comments on commit 90f5cc1

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