Permalink
Browse files

Fixed auth unit tests, show better error message if printer ppd not f…

…ound
  • Loading branch information...
simoncadman committed Feb 3, 2014
1 parent defe107 commit bf6e688c25618e316b0034f1ffdaefb02035f970
Showing with 19 additions and 15 deletions.
  1. +1 −1 backend.py
  2. +1 −1 deleteaccount.py
  3. +1 −1 dynamicppd.py
  4. +1 −1 listcloudprinters.py
  5. +1 −1 listdrivefiles.py
  6. +1 −1 reportissues.py
  7. +1 −1 setupcloudprint.py
  8. +2 −2 test_auth.py
  9. +10 −6 upgrade.py
View
@@ -20,7 +20,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140203 212134"
+ CCPVersion = "20140203 212709"
print "CUPS Cloud Print CUPS Backend 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 = "20140203 212134"
+ CCPVersion = "20140203 212709"
print "CUPS Cloud Print Delete Account Script Version " + CCPVersion
sys.exit(0)
View
@@ -19,7 +19,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140203 212134"
+ CCPVersion = "20140203 212709"
print "CUPS Cloud Print Dynamic PPD Generator Version " + CCPVersion
sys.exit(0)
View
@@ -28,7 +28,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140203 212134"
+ CCPVersion = "20140203 212709"
print "CUPS Cloud Print Printer Lister 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 = "20140203 212134"
+ CCPVersion = "20140203 212709"
print "CUPS Cloud Print Printer Drive Lister Version " + CCPVersion
sys.exit(0)
View
@@ -19,7 +19,7 @@
if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
- CCPVersion = "20140203 212134"
+ CCPVersion = "20140203 212709"
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 = "20140203 212134"
+ CCPVersion = "20140203 212709"
print "CUPS Cloud Print Setup Script Version " + CCPVersion
sys.exit(0)
View
@@ -59,7 +59,7 @@ def test_fixConfigOwnerships():
def test_setupAuth():
# create initial file
assert os.path.exists(Auth.config) == False
- assert Auth.SetupAuth(False) == False
+ assert Auth.SetupAuth(False) == (False, False)
assert os.path.exists(Auth.config) == True
# ensure permissions are correct after creating config
@@ -88,7 +88,7 @@ def test_setupAuth():
@pytest.mark.skipif( grp.getgrnam('lp').gr_gid not in ( os.getgroups() ) and os.getuid() != 0 ,
reason="will only pass if running user part of lp group or root")
def test_setupAuthOwnership():
- assert Auth.SetupAuth(False) == False
+ assert Auth.SetupAuth(False) == (False, False)
# ensure ownership is correct after creating config
assert Auth.GetLPID() == os.stat(Auth.config).st_gid
View
@@ -41,7 +41,7 @@
sys.stderr.write("If you are upgrading from version 20131013 or earlier you should be aware that the scripts have moved from /usr/lib/cloudprint-cups to /usr/share/cloudprint-cups\n")
# line below is replaced on commit
-CCPVersion = "20140203 212134"
+CCPVersion = "20140203 212709"
if len(sys.argv) == 2 and sys.argv[1] == 'version':
print "CUPS Cloud Print Upgrade Script Version " + CCPVersion
@@ -68,7 +68,7 @@
sys.exit(0)
else:
- sys.stderr.write("\n\nRun: /usr/share/cloudprint-cups/setupcloudprint.py to setup your Google Credentials and add your printers to CUPS\n\n")
+ sys.stderr.write("\nRun: /usr/share/cloudprint-cups/setupcloudprint.py to setup your Google Credentials and add your printers to CUPS\n\n")
sys.exit(0)
from backend import which
@@ -89,12 +89,16 @@
if ( cupsprinters[device]["device-uri"].find("cloudprint://") == 0 ):
print "Updating " + cupsprinters[device]["printer-info"]
ppdid = 'MFG:GOOGLE;DRV:GCP;CMD:POSTSCRIPT;MDL:' + cupsprinters[device]["device-uri"] + ';'
+ printerppdname = None
for ppd in allppds:
if allppds[ppd]['ppd-device-id'] == ppdid:
printerppdname = ppd
- p = subprocess.Popen(["lpadmin", "-p", cupsprinters[device]["printer-info"], "-m", printerppdname], stdout=subprocess.PIPE)
- output = p.communicate()[0]
- result = p.returncode
- sys.stderr.write(output)
+ if printerppdname != None:
+ p = subprocess.Popen(["lpadmin", "-p", cupsprinters[device]["printer-info"], "-m", printerppdname], stdout=subprocess.PIPE)
+ output = p.communicate()[0]
+ result = p.returncode
+ sys.stderr.write(output)
+ else:
+ print cupsprinters[device]["printer-info"] + " not found"
except Exception, e:
sys.stderr.write("Error connecting to CUPS: " + str(e) + "\n")

0 comments on commit bf6e688

Please sign in to comment.