Permalink
Browse files

Ask to delete printers when deleting account

  • Loading branch information...
simoncadman committed Oct 17, 2013
1 parent 0dfd9e2 commit 0a75463c5ab2a41387c53b0c7748b16b7551fb46
Showing with 36 additions and 9 deletions.
  1. +1 −1 backend.py
  2. +17 −2 deleteaccount.py
  3. +1 −1 dynamicppd.py
  4. +1 −1 listcloudprinters.py
  5. +12 −0 printer.py
  6. +1 −1 reportissues.py
  7. +1 −1 setupcloudprint.py
  8. +1 −1 submitjob.py
  9. +1 −1 upgrade.py
View
@@ -20,7 +20,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20131013 171837"
+ CCPVersion = "20131017 211222"
print "CUPS Cloud Print CUPS Backend Version " + CCPVersion
sys.exit(0)
View
@@ -17,10 +17,11 @@
import cups, os, json, sys
from auth import Auth
+from printer import Printer
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20131013 171837"
+ CCPVersion = "20131017 211222"
print "CUPS Cloud Print Delete Account Script Version " + CCPVersion
sys.exit(0)
@@ -42,7 +43,21 @@
answer = raw_input("Which account to delete (1-" + str(i) + ") ? ")
if ( answer.isdigit() and int(answer) <= i and int(answer) >= 1 ):
if ( Auth.DeleteAccount(accounts[int(answer)-1]) == None ):
- print(accounts[int(answer)-1] + " deleted. Associated printers were not deleted.")
+ print(accounts[int(answer)-1] + " deleted.")
+ deleteprintersanswer = raw_input("Also delete associated printers? ")
+ if deleteprintersanswer.startswith("Y") or deleteprintersanswer.startswith("y"):
+ printer = Printer(requestors)
+ printers, connection = printer.getCUPSPrintersForAccount(accounts[int(answer)-1])
+ if len(printers) == 0:
+ print "No printers to delete"
+ else:
+ for cupsPrinter in printers:
+ print "Deleting " + cupsPrinter['printer-info']
+ deleteReturnValue = connection.deletePrinter(cupsPrinter['printer-info'])
+ if deleteReturnValue != None:
+ print "Error deleting printer: " + str(deleteReturnValue)
+ else:
+ print "Not deleting associated printers"
else:
print("Error deleting stored credentials, perhaps /etc/cloudprint.conf is not writable?")
elif ( answer == "0" ):
View
@@ -19,7 +19,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20131013 171837"
+ CCPVersion = "20131017 211222"
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 = "20131013 171837"
+ CCPVersion = "20131017 211222"
print "CUPS Cloud Print Printer Lister Version " + CCPVersion
sys.exit(0)
View
@@ -45,6 +45,18 @@ def __init__( self, requestors ):
else:
self.requestors = [requestors]
+ def getCUPSPrintersForAccount(self, account):
+ import cups
+ connection = cups.Connection()
+ cupsprinters = connection.getPrinters()
+ accountPrinters = []
+ for cupsprinter in cupsprinters:
+ id, requestor = self.getPrinterIDByURI(cupsprinters[cupsprinter]['device-uri'])
+ if id != None and requestor != None:
+ if requestor.getAccount() == account:
+ accountPrinters.append(cupsprinters[cupsprinter])
+ return accountPrinters, connection
+
def getPrinters(self, fulldetails = False):
"""Fetch a list of printers
View
@@ -19,7 +19,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20131013 171837"
+ CCPVersion = "20131017 211222"
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 = "20131013 171837"
+ CCPVersion = "20131017 211222"
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 = "20131013 171837"
+ CCPVersion = "20131017 211222"
print "CUPS Cloud Print Submit Job Version " + CCPVersion
sys.exit(0)
View
@@ -22,7 +22,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20131013 171837"
+ CCPVersion = "20131017 211222"
print "CUPS Cloud Print Upgrade Script Version " + CCPVersion
sys.exit(0)

0 comments on commit 0a75463

Please sign in to comment.