Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cups-pdf-postprocess
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Radek Hušek
cups-pdf-postprocess
Commits
e36154f0
Commit
e36154f0
authored
7 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
add support for config files
default config is /etc/cups/cups-pdf-postprocess.conf
parent
62d8f932
No related branches found
No related tags found
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cups-pdf-postprocess.py
+27
-12
27 additions, 12 deletions
cups-pdf-postprocess.py
with
27 additions
and
12 deletions
cups-pdf-postprocess.py
+
27
−
12
View file @
e36154f0
...
...
@@ -14,6 +14,8 @@ import subprocess as sp
import
ast
import
os
CONFIG_FILE
=
"
/etc/cups/cups-pdf-postprocess.conf
"
def
exec_pipeline
(
pipeline
,
inp
,
out
=
None
,
err_callback
=
None
):
def
make_proc
(
cmd
):
p
=
QProcess
()
...
...
@@ -55,21 +57,13 @@ def exec_pipeline(pipeline, inp, out = None, err_callback = None):
QApplication
.
instance
().
processEvents
()
SAVE_AS_FILE
=
object
()
PRINTERS
=
ast
.
literal_eval
(
"
[
\n
%s
\n
]
"
%
""
.
join
(
sys
.
stdin
))
PRINTERS
.
append
((
"
Save as ...
"
,
SAVE_AS_FILE
))
for
l
in
sp
.
check_output
([
"
lpstat
"
,
"
-a
"
]).
decode
(
"
UTF-8
"
).
split
(
"
\n
"
):
p
=
l
.
split
(
"
"
)[
0
]
if
p
==
""
:
continue
PRINTERS
.
append
((
p
,
[
"
lp
"
,
"
-d
"
,
p
]))
class
CPP
(
QWidget
):
def
__init__
(
self
,
pdf
,
user
):
def
__init__
(
self
,
config
,
pdf
,
user
):
super
().
__init__
()
self
.
_pdf
=
pdf
self
.
_config
=
config
vbox
=
QVBoxLayout
()
vbox
.
addStretch
(
1
)
...
...
@@ -232,7 +226,28 @@ class CPP(QWidget):
DIR
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
sys
.
argv
[
0
]))
if
__name__
==
'
__main__
'
:
app
=
QApplication
(
sys
.
argv
[
2
:])
ex
=
CPP
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
args
=
sys
.
argv
if
args
[
1
]
==
'
-c
'
:
CONFIG_FILE
=
args
[
2
]
args
=
args
[
2
:]
else
:
CONFIG_FILE
=
os
.
getenv
(
'
CUPS_PDF_POSTPROCESS_CONFIG
'
,
CONFIG_FILE
)
with
open
(
CONFIG_FILE
)
as
config
:
CONFIG
=
ast
.
literal_eval
(
"
{
\n
%s
\n
}
"
%
config
.
read
())
SAVE_AS_FILE
=
object
()
PRINTERS
=
CONFIG
.
get
(
"
printers
"
,
[])
PRINTERS
.
append
((
"
Save as ...
"
,
SAVE_AS_FILE
))
for
l
in
sp
.
check_output
([
"
lpstat
"
,
"
-a
"
]).
decode
(
"
UTF-8
"
).
split
(
"
\n
"
):
p
=
l
.
split
(
"
"
)[
0
]
if
p
==
""
:
continue
PRINTERS
.
append
((
p
,
[
"
lp
"
,
"
-d
"
,
p
]))
app
=
QApplication
(
args
[
2
:])
ex
=
CPP
(
CONFIG
,
args
[
1
],
args
[
2
])
sys
.
exit
(
app
.
exec_
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment