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

Commit

Permalink
Fixed auth unit tests, show better error message if printer ppd not f…
Browse files Browse the repository at this point in the history
…ound
  • Loading branch information
simoncadman committed Feb 3, 2014
1 parent defe107 commit bf6e688
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion backend.py
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion deleteaccount.py
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion dynamicppd.py
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion listcloudprinters.py
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion listdrivefiles.py
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion reportissues.py
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion setupcloudprint.py
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions test_auth.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions upgrade.py
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.