Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

logocert_api branch no module named uritemplate #96

Closed
kdlucas opened this issue Dec 23, 2016 · 36 comments
Closed

logocert_api branch no module named uritemplate #96

kdlucas opened this issue Dec 23, 2016 · 36 comments
Assignees
Milestone

Comments

@kdlucas
Copy link
Contributor

kdlucas commented Dec 23, 2016

I attempted to set up and run the logocert_api branch today on OSX, running Python 2.7.10, and when testcert.py executes, I get:

File "./testcert.py", line 49, in
import _sheets
File "/Users/kdlucas/src/logocert_api/cloudprint_logocert/_sheets.py", line 22, in
import _gdocs
File "/Users/kdlucas/src/logocert_api/cloudprint_logocert/_gdocs.py", line 31, in
from googleapiclient import discovery
File "/Library/Python/2.7/site-packages/googleapiclient/discovery.py", line 53, in
import uritemplate
ImportError: No module named uritemplate

The googleapiclient is installed. I try to debug a bit and find out what else needs to be installed.

I fixed the issue by installing uritemplate with:

sudo pip install uritemplate.py

I then got another error:
./testcert.py
Adding SystemUnderTest to list of suites to run
Adding Privet to list of suites to run
/Library/Python/2.7/site-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access credentials.txt: No such file or directory
warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
No handlers could be found for logger "oauth2client.client"
ERROR

ERROR: setUpModule (main)

Traceback (most recent call last):
File "./testcert.py", line 149, in setUpModule
getTokens()
File "./testcert.py", line 245, in getTokens
GetNewTokens()
File "./testcert.py", line 282, in GetNewTokens
creds = run_flow(flow, _storage, flags=flags,http=http)
File "/Library/Python/2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Python/2.7/site-packages/oauth2client/tools.py", line 218, in run_flow
authorize_url = flow.step1_get_authorize_url()
File "/Library/Python/2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 1934, in step1_get_authorize_url
return _helpers.update_query_params(self.auth_uri, query_params)
File "/Library/Python/2.7/site-packages/oauth2client/_helpers.py", line 222, in update_query_params
parts = urllib.parse.urlparse(uri)
AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urlparse'

I haven't yet figured out how to solve this.

@kdlucas kdlucas added this to the Version 2.x milestone Dec 23, 2016
@lrbom
Copy link
Contributor

lrbom commented Dec 24, 2016 via email

@kdlucas
Copy link
Contributor Author

kdlucas commented Dec 26, 2016 via email

@lrbom
Copy link
Contributor

lrbom commented Dec 28, 2016 via email

@kdlucas
Copy link
Contributor Author

kdlucas commented Jan 23, 2017

Ok, I updated my shell by running the following in my shell:

export PYTHONPATH=/Library/Python/2.7/site-packages

Now I see the following error:
Traceback (most recent call last):
File "./testcert.py", line 149, in setUpModule
getTokens()
File "./testcert.py", line 245, in getTokens
GetNewTokens()
File "./testcert.py", line 282, in GetNewTokens
creds = run_flow(flow, _storage, flags=flags,http=http)
File "/Library/Python/2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Python/2.7/site-packages/oauth2client/tools.py", line 218, in run_flow
authorize_url = flow.step1_get_authorize_url()
File "/Library/Python/2.7/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Library/Python/2.7/site-packages/oauth2client/client.py", line 1934, in step1_get_authorize_url
return _helpers.update_query_params(self.auth_uri, query_params)
File "/Library/Python/2.7/site-packages/oauth2client/_helpers.py", line 222, in update_query_params
parts = urllib.parse.urlparse(uri)
AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urlparse'

@lrbom
Copy link
Contributor

lrbom commented Jan 23, 2017 via email

@kdlucas
Copy link
Contributor Author

kdlucas commented Jan 25, 2017

Executing sudo pip install --ignore-installed six

fixed that issue. Proceeding.

@kdlucas
Copy link
Contributor Author

kdlucas commented Jan 25, 2017

I set the printer name to M477, and now executing testcert.py, it hangs. I'm seeing the following:
Logocert INFO: Got new access token.
Logocert INFO: Service added: "HP Color LaserJet MFP M477fdw (6D418f)._privet._tcp.local."
and then it just hangs
looks like it's running setUpModule in _zconf.py Wait_for_privet_mdns_service

I'll check if there is an issue with the way we're checking for names, as maybe it needs to be M477fdw in the _config.py file. I'll add more debug info this evening.

@lrbom
Copy link
Contributor

lrbom commented Jan 25, 2017

Wait_for_privet_mdns_service() waits indefinitely for zeroconf threads to be terminated and this is likely the case for you. I have updated the code to wait up to 30 seconds only for the threads to terminate, and continue operation regardless of successful termination or not. This is pushed to logocert_api now.

As for name checking, M477 should be matched since it is a substring of the service "HP Color LaserJet MFP M477fdw (6D418f)._privet._tcp.local."

@kdlucas
Copy link
Contributor Author

kdlucas commented Jan 26, 2017

Now it's executing after your latest change. So far I've run a couple of test suites. I'll update after I've run through all of them.

@kdlucas
Copy link
Contributor Author

kdlucas commented Jan 26, 2017

Everything is working pretty good. I've tested the test suites up to jobstate. Once I got there I see some jobs are in error or queued states:
Jobs.pdf

No jobs have printed. Attaching the last log as well.
archive.zip

@kdlucas
Copy link
Contributor Author

kdlucas commented Jan 27, 2017

Today I was running more of the jobstate tests, and I got a continual message:

LogoCert INFO: Access token expired, need to refresh it
Trying again in 1 sec(s)
Bad status code from Submit(): 403

@lrbom
Copy link
Contributor

lrbom commented Jan 27, 2017 via email

@kdlucas
Copy link
Contributor Author

kdlucas commented Jan 27, 2017

Ok, I wonder if we should put something in the setUpModule to automatically do this if we detect this error.

@lrbom
Copy link
Contributor

lrbom commented Jan 27, 2017 via email

@lrbom lrbom removed the help wanted label Jan 31, 2017
@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 1, 2017

Since the latest changes were made, I'm now seeing:

"No printers discovered under HP Color LaserJet MFP M477fdw".

Previously I saw:

LogoCert INFO: Service added: "HP Color LaserJet MFP M477fdw ..."

and in my _config.py I have:

'MODEL': 'M477',
'NAME': 'HP Color LaserJet MFP M477fdw',

However, when I changed 'NAME' to read 'M477fdw' it started working, so spaces might be an issue. For me it's fine if spaces are not allowed, but we should document it.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 1, 2017

When running through the tests, when I ran the test for testJobStateEmptyInputTray, the job goes into the Queued state but the test fails, saying it didn't find the job in the queued or In Progress state.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 1, 2017

Looks like I may need to update the printer firmware, as I think it has an issue with the version of Java.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 2, 2017

I updated the firmware and now tests are passing as expected. For the Name string, I don't think it was related to string handling, as I think it had more to do with the printer failure to send mDNS packets. I've now completed the JobState suite, and will move to the cloud printing suite next.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 3, 2017

I completed all of the CloudPrinting suite tests. I noticed a number of tests failed with an Error. Not sure why. Nothing was attempted to print. I've attached the log.
LogoCert2017February02_204831.log.zip

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 3, 2017

I attempted to run the LocalPrinting suite. The first print job printed; however, testcert.py bailed out with:
./testcert.py
Adding LocalPrinting to list of suites to run
LogoCert INFO: Got new access token.
LogoCert INFO: Service added: "HP Color LaserJet MFP M477fdw (6D418F)._privet._tcp.local."
LogoCert INFO: All listeners have been stopped.
LogoCert INFO: Device URL: http://192.168.1.65:80
LogoCert INFO: Got new access token.

                 Starting LocalPrinting testSuite

================================================================================

/Users/kdlucas/src/logocert_api/cloudprint_logocert/images/testpage.pwg not found.
Likely that this is the first time LocalPrinting suite is run.
Generating pwg-raster via cloud print
Attempting to submit a job through GCP for up to 60 seconds
Job submitted successfully
[Configurable timeout] PRINTER_STATUS:
Waiting up to 180 seconds for the printer to have status: processing
<function FetchRaster at 0x10223dc80> failed
ERROR

======================================================================
ERROR: setUpClass (main.LocalPrinting)

Traceback (most recent call last):
File "./testcert.py", line 2284, in setUpClass
getLocalPrintingRasterImages()
File "./testcert.py", line 337, in getLocalPrintingRasterImages
getRasterImageFromCloud(Constants.IMAGES['PWG1'], Constants.IMAGES['PNG7'])
File "./testcert.py", line 323, in getRasterImageFromCloud
res = _gcp.FetchRaster(output['job']['id'])
File "/Users/kdlucas/src/logocert_api/cloudprint_logocert/_cpslib.py", line 94, in VerifyNotNone
raise AssertionError
AssertionError


Ran 0 tests in 194.276s

FAILED (errors=1)
LogoCert2017February02_210849.log.zip

@lrbom
Copy link
Contributor

lrbom commented Feb 3, 2017 via email

@lrbom
Copy link
Contributor

lrbom commented Feb 3, 2017 via email

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 3, 2017

Ah, ok, maybe I'll turn up the debug level to debug to get more information.

@lrbom
Copy link
Contributor

lrbom commented Feb 3, 2017 via email

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 4, 2017

Ok, I'm going to rename the spreadsheet to a unique name and run it again. It will be owned by testcloudprint30.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 5, 2017

So I reran the tests, and all of the tests that had errors (39 of them) did not make any entry in the spreadsheet. So I'm going to rerun with debug enabled.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 5, 2017

Here is the log file in debug mode.
LogoCert2017February05_104210.log.zip

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 8, 2017

Kevin and I were discussing possible failure scenarios, and we think that another issue here could be that some printers may not support some of the CJT options that the tests is passing in. Need to increase error messages to understand better why there are failures with certain printers in the CloudPrinting suite.

@lrbom
Copy link
Contributor

lrbom commented Feb 8, 2017

I found the culprit. It was a method for adding color options in a CJT that was raising the unhandled exception. This occurs when the printer does not include 'vendor_id' in its capabilities for color options. This issue is now fixed.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 9, 2017

Ok, I grabbed your latest changes and all of the tests passed except one. The failure was with test PrintJpgDpiSetting, AttributeError: 'Cloudprinting' object has no attribute 'Submit'. If you log in as testcloudprint30, you can see the spreadsheet called LogoCert_api_cjtchanges for details.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 9, 2017

I still can't get any tests to pass in the LocalPrinting suite, as when the first test runs, it does print the page, but I see:
Users/kdlucas/src/logocert_api/cloudprint_logocert/images/testpage.pwg not found.
Likely that this is the first time LocalPrinting suite is run.
Generating pwg-raster via cloud print
Attempting to submit a job through GCP for up to 60 seconds
Job submitted successfully
[Configurable timeout] PRINTER_STATUS:
Waiting up to 180 seconds for the printer to have status: processing
<function FetchRaster at 0x102841c80> failed
ERROR

======================================================================
ERROR: setUpClass (main.LocalPrinting)

Traceback (most recent call last):
File "./testcert.py", line 2283, in setUpClass
getLocalPrintingRasterImages()
File "./testcert.py", line 337, in getLocalPrintingRasterImages
getRasterImageFromCloud(Constants.IMAGES['PWG1'], Constants.IMAGES['PNG7'])
File "./testcert.py", line 323, in getRasterImageFromCloud
res = _gcp.FetchRaster(output['job']['id'])
File "/Users/kdlucas/src/logocert_api/cloudprint_logocert/_cpslib.py", line 94, in VerifyNotNone
raise AssertionError
AssertionError

@lrbom
Copy link
Contributor

lrbom commented Feb 9, 2017

The CloudPrinting error has been fixed and pushed, it was a typo in a function name. Great catch!

As for the LocalPrinting error, I can only pinpoint it to some failure in the /download GCP API call. In the setup code for LocalPrinting, Cloud Printing is leveraged for converting several images to the raster format that will be used for LocalPrinting.

The procedure goes like this:

  1. A Cloud Print job is created (The page that you see printed is the result of this)
  2. While the Cloud Print job is queued or in progress, we can download the raster format of the target image via the /download interface. (This is where the error occurred for you.)
  3. The raster file is saved to disk and will be used for subsequent LocalPrinting testcases

I have added better console logging in FetchRaster() so hopefully this will help us get to the root of the issue.

@lrbom
Copy link
Contributor

lrbom commented Feb 10, 2017

I have pushed up a change in LocalPrinting. It now waits on the GCP job state instead of the Privet printer state when it's determining when to access the /download API for the raster image. This should fix your issue Kelly.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 10, 2017

Thanks for making the changes, I'll test this over the weekend.

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 11, 2017

Ok, I ran ran the local printing suite. I noticed the printer I was testing on failed tests for:

  1. printing in landscape mode (printed in portrait)
  2. failed the margins tests (printed identical margins for both printouts)
  3. failed selective print page numbers (printed all pages, instead of just 2 and 3)

And at the end of the tests I saw:
Verify printer respects GCP Mgt page when local printing toggled.
... Disabling local printing
[Configurable timeout] GCP_UPDATE:
Waiting up to 60 seconds for printer to accept pending settings
Local print successfully turned off

Wait for idle state before starting a local print job
[Configurable timeout] PRINTER_STATUS:
Waiting up to 180 seconds for the printer to have status: idle
Device state observed to be: idle
Attempt to get a local job id for up to 30 seconds
Got a job id

LogoCert INFO: Test ID: 533d4ac6-5c1d-4c99-a91e-2bac7c31864f
LogoCert INFO: Result: Blocked
LogoCert INFO: Name: testLocalPrintingToggle
LogoCert INFO: Notes: Able to print via privet local printing when disabled.
FAIL

======================================================================
FAIL: testLocalPrintingToggle (main.LocalPrinting)

======================================================================
Verify printer respects GCP Mgt page when local printing toggled.


Traceback (most recent call last):
File "./testcert.py", line 2349, in testLocalPrintingToggle
self.assertIsNone(job_id)
AssertionError: u'163' is not None

@kdlucas
Copy link
Contributor Author

kdlucas commented Feb 15, 2017

Ok, I tested the rest of the the printing suites, and it all looks good. I think we should be ready to close out this issue and move to the next stage of getting this branch pushed into our main branch.

@kdlucas kdlucas closed this as completed Feb 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants