Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot print at all due to unicode job ownerId #137

Open
4gra opened this issue Apr 26, 2018 · 1 comment · May be fixed by #140
Open

cannot print at all due to unicode job ownerId #137

4gra opened this issue Apr 26, 2018 · 1 comment · May be fixed by #140

Comments

@4gra
Copy link

4gra commented Apr 26, 2018

Symptoms: nothing prints. Vague ERROR: <jobname> output each time a job is accepted; running with -v provides no more detail on the error. Suppressing exception handling in the appropriate block revealed the following exception, referring to the options dict to the cups_connection (at cloudprint.py:421):

TypeError: Keys and values must be strings

The simplest way to fix this is simply to reverse the lines setting up the options dict, ensuring everything is a str:

cloudprint/cloudprint.py:411-412:

        options['job-originating-user-name'] = job['ownerId']
        options = dict((str(k), str(v)) for k, v in list(options.items()))

...but it occurred to me that it might be wiser to escape the userID to avoid exceptions where the userID can't be represented in ASCII:

        options = dict((str(k), str(v)) for k, v in list(options.items()))
        options['job-originating-user-name'] = job['ownerId'].encode('unicode_escape')

the latter might not result in pretty output but it'll at least preserve the connecting user ID.

I wasn't sure how you'd like to approach the solution so thought an issue was better than a PR -- but happy to prepare one if it's easier.

To be clear, my username doesn't contain anything that's not in ASCII, so assume one of my libraries is returning unicode "unexpectedly" (I haven't investigated which, but since either change will work with string job IDs I don't see that it matters).

Environment: Debian 8, Python 2.7.9, dependencies supplied by a questionable mix of Debian repositories and pypi (versions available on request if you really care!)

4gra referenced this issue in 4gra/cloudprint Apr 26, 2018
* produce debug-level log with exception detail if printing fails
* exclude options whose values are the string 'None'
* ensure ownerId is passed to CUPS as escaped-unicode string.
@4gra 4gra linked a pull request Dec 11, 2018 that will close this issue
@4gra
Copy link
Author

4gra commented Dec 11, 2018

On reflection it looks like this repository is not frequently maintained, and I'm relatively confident of my commit across environments, so I've made a PR mainly to increase visibility of the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant