Skip to content
Permalink
Browse files

Added script to check file pushed up to drive correctly

  • Loading branch information
simoncadman committed Jan 11, 2014
1 parent a89e536 commit fe50109f35a0e32ef3f3e5a99c66672695d3dcf0
Showing with 83 additions and 13 deletions.
  1. +3 −3 auth.py
  2. +1 −1 backend.py
  3. +3 −1 cloudprintrequestor.py
  4. +1 −1 deleteaccount.py
  5. +1 −1 dynamicppd.py
  6. +14 −0 full-test.sh
  7. +1 −1 listcloudprinters.py
  8. +40 −0 listdrivefiles.py
  9. +1 −0 packages/redhat/SPECS/cupscloudprint.spec
  10. +14 −0 printer.py
  11. +1 −1 reportissues.py
  12. +1 −2 setupcloudprint.py
  13. +1 −1 submitjob.py
  14. +1 −1 upgrade.py
@@ -77,7 +77,7 @@ def AddAccount(storage, userid=None): # pragma: no cover
while True:
flow = client.OAuth2WebServerFlow(client_id=Auth.clientid,
client_secret=Auth.clientsecret,
scope='https://www.googleapis.com/auth/cloudprint',
scope=['https://www.googleapis.com/auth/cloudprint'],
user_agent=userid)
auth_uri = flow.step1_get_authorize_url()
print "Open this URL, grant access to CUPS Cloud Print, then provide the code displayed : \n\n" + auth_uri + "\n"
@@ -99,7 +99,7 @@ def AddAccount(storage, userid=None): # pragma: no cover

AddAccount = staticmethod(AddAccount)

def SetupAuth(interactive=False):
def SetupAuth(interactive=False, permissions=['https://www.googleapis.com/auth/cloudprint']):
"""Sets up requestors with authentication tokens
Args:
@@ -128,7 +128,7 @@ def SetupAuth(interactive=False):
Auth.config,
Auth.clientid,
userid,
['https://www.googleapis.com/auth/cloudprint'])
permissions)
credentials = storage.get()

if not credentials and interactive: # pragma: no cover
@@ -20,7 +20,7 @@

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

@@ -36,7 +36,7 @@ def getAccount ( self ):
"""
return self.account

def doRequest ( self, path, headers = None, data = None , boundary = None, testResponse=None ): # pragma: no cover
def doRequest ( self, path, headers = None, data = None , boundary = None, testResponse=None, endpointurl=None ): # pragma: no cover
"""Sends a request to Google Cloud Print
Args:
@@ -53,6 +53,8 @@ def doRequest ( self, path, headers = None, data = None , boundary = None, testR
headers['user-agent'] = "CUPS Cloud Print"

url = '%s/%s' % (self.CLOUDPRINT_URL, path)
if endpointurl != None:
url = '%s/%s' % (endpointurl, path)

# use test response for testing
if testResponse == None:
@@ -21,7 +21,7 @@

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

@@ -19,7 +19,7 @@

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

@@ -84,4 +84,18 @@ if [[ $success == 0 ]]; then
exit 1
fi

if [[ $testconfig != "" ]]; then
# download drive config file so we can check if file exists on drive correctly
if [[ "`whoami`" == "root" ]]; then
scp $testconfig.drive /etc/cloudprint.conf
else
sudo scp $testconfig.drive /etc/cloudprint.conf
fi
fi

if [[ `./listdrivefiles.py "$jobname"` != "133909 11QSOvUX6KZKZVB6nCB3GloLTJQ/MTM4OTQ3ODc0NDQwOA" ]]; then
echo "Uploaded file does not match expected etag or size"
exit 1
fi

tail /var/log/cups/cloudprint_log
@@ -21,7 +21,7 @@

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

@@ -0,0 +1,40 @@
#! /usr/bin/env python2
# CUPS Cloudprint - Print via Google Cloud Print
# Copyright (C) 2011 Simon Cadman
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import 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 = "20140111 233828"
print "CUPS Cloud Print Printer Drive Lister Version " + CCPVersion
sys.exit(0)

requestors, storage = Auth.SetupAuth(True, permissions=['https://www.googleapis.com/auth/cloudprint', 'https://www.googleapis.com/auth/drive.readonly'])
printer = Printer(requestors)
files = printer.getDriveFiles()
if files == None:
print "No Files Found"
sys.exit(1)

for drivefile in files:
if len(sys.argv) == 2 and drivefile['title'] == sys.argv[1] + '.pdf':
print drivefile['fileSize'], drivefile['etag'].strip('"')
sys.exit(0)
elif len(sys.argv) != 2:
print drivefile['title']
@@ -53,6 +53,7 @@ make install DESTDIR=$RPM_BUILD_ROOT NOPERMS=1
%attr(755, root, lp) %{_usr}/share/cloudprint-cups/deleteaccount.py
%attr(755, root, lp) %{_usr}/share/cloudprint-cups/dynamicppd.py
%attr(755, root, lp) %{_usr}/share/cloudprint-cups/listcloudprinters.py
%attr(755, root, lp) %{_usr}/share/cloudprint-cups/listdrivefiles.py
%attr(755, root, lp) %{_usr}/share/cloudprint-cups/full-test.sh
%attr(755, root, lp) %{_usr}/share/cloudprint-cups/reportissues.py
%attr(755, root, lp) %{_usr}/share/cloudprint-cups/setupcloudprint.py
@@ -459,6 +459,20 @@ def submitJob(self, printerid, jobtype, jobfile, jobname, printername, options="
print 'ERROR: Print job %s failed with %s' % ( jobtype, error_msg )
return False

def getDriveFiles ( self ):
returnValue = []
for requestor in self.requestors:
responseobj = requestor.doRequest( 'files', endpointurl="https://www.googleapis.com/drive/v2" )
if 'error' in responseobj:
print "Errored fetching files from drive"
pass
else:
for item in responseobj['items']:
returnValue.append( item )
if len(returnValue) == 0:
return None
return returnValue

def getInternalName ( self, details, internalType, capabilityName = None, existingList = [] ) :
returnValue = None
fixedNameMap = {}
@@ -19,7 +19,7 @@

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

@@ -21,7 +21,7 @@

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

@@ -54,7 +54,6 @@
break
else:
Auth.AddAccount(storage)


for requestor in requestors:
addedCount = 0
@@ -21,7 +21,7 @@

if len(sys.argv) == 2 and sys.argv[1] == 'version':
# line below is replaced on commit
CCPVersion = "20140111 220539"
CCPVersion = "20140111 233828"
print "CUPS Cloud Print Submit Job Version " + CCPVersion
sys.exit(0)

@@ -32,7 +32,7 @@
logfile.write("Unable to write to log file /var/log/cups/cloudprint_log")

# line below is replaced on commit
CCPVersion = "20140111 220539"
CCPVersion = "20140111 233828"

if len(sys.argv) == 2 and sys.argv[1] == 'version':
print "CUPS Cloud Print Upgrade Script Version " + CCPVersion

0 comments on commit fe50109

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