Skip to content
This repository has been archived by the owner on Aug 21, 2020. It is now read-only.

Commit

Permalink
Attempt to list printers for cups on setup
Browse files Browse the repository at this point in the history
  • Loading branch information
simoncadman committed Aug 4, 2012
1 parent 534621a commit 7f75c81
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion backend.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,7 +24,30 @@ def fileIsPDF ( filename ) :
return type[0] == "application/pdf" return type[0] == "application/pdf"


if len(sys.argv) == 1: if len(sys.argv) == 1:
print("network " + progname + " \"Unknown\" \"Google Cloud Print\"") print("network cloudprint \"Unknown\" \"Google Cloud Print\"")

try:

libpath = "/usr/lib/cloudprint-cups/"
if not os.path.exists( libpath ):
libpath = "/usr/local/lib/cloudprint-cups"
sys.path.insert(0, libpath)
from config import Config
configuration = Config()
from auth import Auth
from printer import Printer
email = configuration.get("Google", "Username")
password = configuration.get("Google", "Password")

token = Auth.GetAuthTokens(email, password)
if token != None:
printers = Printer.GetPrinters(token)
if printers != None:
for printer in printers:
print("network " + Printer.printerNameToUri(printer['name']) + " " + "\"" + printer['name'] + "\" \"Google Cloud Print\"" )
except Exception as error:
print error
pass
sys.exit(0) sys.exit(0)


if len(sys.argv) < 6 or len(sys.argv) > 7: if len(sys.argv) < 6 or len(sys.argv) > 7:
Expand Down

0 comments on commit 7f75c81

Please sign in to comment.