This repository has been archived by the owner on Mar 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbooklet.py
141 lines (133 loc) · 6.31 KB
/
booklet.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# booklet.py
__version__ = "v20200801"
from termcolor import colored
import colorama
import printer
import instructions
def bookletPrint(log, order, print_que, Print_Files, SETS, LPR, D110_IP, MERGED):
"""
Logic & workflow for printing saddle-stitched booklets.
Saddle-stitched bookelts require a differnet workflow.
Booklets also require extra validation before running.
Booklets also only get ran one-set at a time.
This can handle that.
Parameters:
log (object): The object that allows the software to log itself.
order (object): The object containing all the information for the current order.
print_que (list) : The list of print ready files waiting to be run. (Used when Bulk Printing)
Print_Files (list) : The location of all the postscript files for the current job.
SETS (int) : How many sets to run.
LPR (list) : The front portion of the LPR command for each printer.
D110_IP (int) : Which IP to use form the LPR list.
MERGED (bool) : The flag for knowing if all the files are merged together.
Returns:
N/A
"""
approved = 0
COPIES_PER_SET = 0
print("Enter How Many Sets and Copies Per Set You Would Like to Run.\nEnter 1 + Copy Count if you want to run everything at once.")
while True:
try:
SETS = int(input("\nHow Many Sets?: "))
break
except:
log.logger.exception("")
pass
while True:
try:
COPIES_PER_SET = int(input("How Many Copies Per Set?: "))
break
except:
log.logger.exception("")
pass
for j in range(len(Print_Files)):
lpr_path = LPR[D110_IP] + '"' + Print_Files[j] + '"'
lpr_path = LPR[D110_IP] + '"' + order.OD+'/' + order.NAME + '/PSP/' + \
Print_Files[j] + '" -J "' + Print_Files[j] + '"'
log.logger.debug((lpr_path.replace(
"C:/Windows/system32/lpr.exe -S 10.56.54.", "").replace(
'-P PS "C:/S/SO/', "").split("-J")[0]))
print_que.append(lpr_path)
printer.print_processor(print_que) # Does the printing
print("PLEASE CHECK PROOF, if any files look incorrect, please cancel order")
loop = True
flip = []
while loop:
try:
approved = int(input(''.join(["Flip All & Proof?: ", colored("1", "cyan"), " | Flip Individually & Proof?: ", colored(
"2", "cyan"), " | Approved? Yes: ", colored(
"3", "cyan"), " | No: ", colored("0", "cyan"), " :"])))
except:
log.logger.exception("")
pass
if(approved == 3):
if (len(flip) == 0):
instructions.pjl_insert(
order, COPIES_PER_SET)
instructions.pjl_merge(order,
"PSP", MERGED, order.FILE_NAMES)
else:
for j in range(len(Print_Files)):
order.DUPLEX = "two-sided-short-edge" if flip[j] else "Two-sided (back to back)"
instructions.pjl_insert(
order, COPIES_PER_SET)
flip_file = [order.FILE_NAMES[j]]
instructions.pjl_merge(order, "PSP",
MERGED, flip_file)
for i in range(SETS):
print("\n\nRunning Set " + str(i+1) + " of " + str(SETS))
for j in range(len(Print_Files)):
lpr_path = LPR[D110_IP] + '"' + Print_Files[j] + '"'
lpr_path = LPR[D110_IP] + '"' + order.OD+'/' + order.NAME + \
'/PSP/' + Print_Files[j] + \
'" -J "' + Print_Files[j] + '"'
log.logger.debug((lpr_path.replace(
"C:/Windows/system32/lpr.exe -S 10.56.54.", "").replace(
'-P PS "C:/S/SO/', "").split("-J")[0]))
print_que.append(lpr_path)
printer.print_processor(print_que) # Does the printing
print("Ran Set " + str(i+1) + " of " + str(SETS))
if(SETS != 1):
str(input("\nPress Enter to Continue: "))
loop = False
elif(approved == 1):
order.DUPLEX = "two-sided-short-edge"
instructions.pjl_insert(
order, 1)
instructions.pjl_merge(order, "PSP", MERGED, order.FILE_NAMES)
for j in range(len(Print_Files)):
lpr_path = LPR[D110_IP] + '"' + Print_Files[j] + '"'
lpr_path = LPR[D110_IP] + '"' + order.OD+'/' + order.NAME + '/PSP/' + \
Print_Files[j] + '" -J "' + Print_Files[j] + '"'
log.logger.debug((lpr_path.replace(
"C:/Windows/system32/lpr.exe -S 10.56.54.", "").replace(
'-P PS "C:/S/SO/', "").split("-J")[0]))
print_que.append(lpr_path)
printer.print_processor(print_que) # Does the printing
elif(approved == 2):
for j in range(len(Print_Files)):
while True:
try:
flipT = int(input(''.join(["File: ", str(j+1), ": Flip? Yes: ", colored(
"1", "cyan"), " No: ", colored("0", "cyan"), " : "])))
if(flipT == 1 or flipT == 0):
flip.append(flipT)
break
else:
pass
except:
log.logger.exception("")
pass
order.DUPLEX = "two-sided-short-edge" if flip[-1] else "Two-sided (back to back)"
instructions.pjl_insert(
order, 1)
flip_file = [order.FILE_NAMES[j]]
instructions.pjl_merge(order,
"PSP", MERGED, flip_file)
lpr_path = LPR[D110_IP] + '"' + Print_Files[j] + '"'
lpr_path = LPR[D110_IP] + '"' + order.OD+'/' + order.NAME + '/PSP/' + \
Print_Files[j] + '" -J "' + Print_Files[j] + '"'
print_que.append(lpr_path)
printer.print_processor(print_que) # Does the printing
elif(approved == 0):
loop = False