From 761a30a662ec37b9bad0836edcdac7ba24756f3b Mon Sep 17 00:00:00 2001 From: Graham <4gra@users.noreply.github.com> Date: Thu, 26 Apr 2018 15:25:54 +0100 Subject: [PATCH 1/7] permit unicode user IDs, no empty opts, debug log * 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. --- cloudprint/cloudprint.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cloudprint/cloudprint.py b/cloudprint/cloudprint.py index dc454e2..aff669c 100755 --- a/cloudprint/cloudprint.py +++ b/cloudprint/cloudprint.py @@ -408,8 +408,8 @@ def process_job(cups_connection, cpp, printer, job): if 'request' in options: del options['request'] - options = dict((str(k), str(v)) for k, v in list(options.items())) - options['job-originating-user-name'] = job['ownerId'] + options = dict((str(k), str(v)) for k, v in list(options.items()) if v != 'None') + options['job-originating-user-name'] = job['ownerId'].encode('unicode_escape') # Cap the title length to 255, or cups will complain about invalid # job-name @@ -425,7 +425,8 @@ def process_job(cups_connection, cpp, printer, job): cpp.finish_job(job['id']) num_retries = 0 - except Exception: + except Exception, e: + LOGGER.debug(unicode_escape('ERROR detail: ' + e)) if num_retries >= RETRIES: num_retries = 0 cpp.fail_job(job['id']) From 03d2c3f9e9e0db682dae1c3f2c91215a5dd35300 Mon Sep 17 00:00:00 2001 From: Graham <4gra@users.noreply.github.com> Date: Wed, 15 Aug 2018 21:46:00 +0100 Subject: [PATCH 2/7] Create cloudprint.service --- cloudprint.service | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cloudprint.service diff --git a/cloudprint.service b/cloudprint.service new file mode 100644 index 0000000..4564b54 --- /dev/null +++ b/cloudprint.service @@ -0,0 +1,14 @@ +[Unit] +Description=Google Cloud Print Daemon +Requires=cups.service +After=cups.service +Documentation=https://github.com/4gra/cloudprint + +[Service] +User=printer +ExecStart=/usr/local/bin/cloudprint +Restart=always +RestartSec=300 +StandardOutput=syslog +StandardError=syslog +SyslogIdentifier=cloudprint From ab7053566ca86b4e800069a9b9f9e7c5a11a711e Mon Sep 17 00:00:00 2001 From: Graham <4gra@users.noreply.github.com> Date: Tue, 11 Dec 2018 23:00:41 +0000 Subject: [PATCH 3/7] Update cloudprint.py removed dubious string handling in error message --- cloudprint/cloudprint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudprint/cloudprint.py b/cloudprint/cloudprint.py index aff669c..2bde8a4 100755 --- a/cloudprint/cloudprint.py +++ b/cloudprint/cloudprint.py @@ -426,7 +426,7 @@ def process_job(cups_connection, cpp, printer, job): num_retries = 0 except Exception, e: - LOGGER.debug(unicode_escape('ERROR detail: ' + e)) + LOGGER.debug(unicode_escape('ERROR detail: %s' % e)) if num_retries >= RETRIES: num_retries = 0 cpp.fail_job(job['id']) From 9f8e705acc9f5080c751ccf9209378dcd9584244 Mon Sep 17 00:00:00 2001 From: Graham <4gra@users.noreply.github.com> Date: Tue, 11 Dec 2018 23:14:55 +0000 Subject: [PATCH 4/7] tweaked for flake8 reduced line length (to pass armooo/cloudprint CI flake8 test) --- cloudprint/cloudprint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudprint/cloudprint.py b/cloudprint/cloudprint.py index 2bde8a4..e1565cf 100755 --- a/cloudprint/cloudprint.py +++ b/cloudprint/cloudprint.py @@ -408,7 +408,8 @@ def process_job(cups_connection, cpp, printer, job): if 'request' in options: del options['request'] - options = dict((str(k), str(v)) for k, v in list(options.items()) if v != 'None') + options = dict( (str(k), str(v)) for k, v in list(options.items()) \ + if v != 'None' ) options['job-originating-user-name'] = job['ownerId'].encode('unicode_escape') # Cap the title length to 255, or cups will complain about invalid From d1f8b570f85ecd001f3243cb2c5b5353d2d046fb Mon Sep 17 00:00:00 2001 From: Graham <4gra@users.noreply.github.com> Date: Tue, 11 Dec 2018 23:20:59 +0000 Subject: [PATCH 5/7] Update cloudprint.py last attempt at manual flake8 compliance --- cloudprint/cloudprint.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cloudprint/cloudprint.py b/cloudprint/cloudprint.py index e1565cf..751fc87 100755 --- a/cloudprint/cloudprint.py +++ b/cloudprint/cloudprint.py @@ -408,9 +408,12 @@ def process_job(cups_connection, cpp, printer, job): if 'request' in options: del options['request'] - options = dict( (str(k), str(v)) for k, v in list(options.items()) \ - if v != 'None' ) - options['job-originating-user-name'] = job['ownerId'].encode('unicode_escape') + options = dict( + (str(k), str(v)) for k, v in list(options.items()) if v != 'None' + ) + options['job-originating-user-name'] = job['ownerId'].encode( + 'unicode_escape' + ) # Cap the title length to 255, or cups will complain about invalid # job-name From fb6095915e4c3d6bc809372300bc156e235e69b1 Mon Sep 17 00:00:00 2001 From: Graham <4gra@users.noreply.github.com> Date: Sun, 10 Feb 2019 17:10:12 +0000 Subject: [PATCH 6/7] added install target seems a bit silly not to add the install section. --- cloudprint.service | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cloudprint.service b/cloudprint.service index 4564b54..0b5d03c 100644 --- a/cloudprint.service +++ b/cloudprint.service @@ -12,3 +12,6 @@ RestartSec=300 StandardOutput=syslog StandardError=syslog SyslogIdentifier=cloudprint + +[Install] +WantedBy=multi-user.target From 79e2009b363936f3403667d7a96154930de45b30 Mon Sep 17 00:00:00 2001 From: Graham <4gra@users.noreply.github.com> Date: Sun, 10 Feb 2019 17:12:36 +0000 Subject: [PATCH 7/7] Update README.rst small typo --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 5c29af8..b796829 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ Google's linux connector, it does not require chrome to be installed on the serv Requires --------------------------------------------------- - python 2.6 or 2.7 -- pycups (can be tricky on OS X) wich depends on libcups2-dev +- pycups (can be tricky on OS X) which depends on libcups2-dev Usage ---------------------------------------------------