. , Dell, , CSV, MS SCCM. . , , MAC- .
gLabels. gLabels, CSV , PDF , lpr Dymo Labelwriter.
"", , .
def self.print
printed_labels = 0
csv_file = Tempfile.new(["computers", ".csv"])
logger.debug("Writing #{csv_file.path}")
begin
Computer.transaction do
Computer.unprinted.each do |computer|
csv_file.puts "\"#{computer.mac(' ')}\",\"#{computer.hostname}\""
computer.printed = true
computer.save
printed_labels += 1
end
end
ensure
csv_file.close
if csv_file.length > 0
pdf_file = Tempfile.new(["computers", ".pdf"])
begin
pdf_file.close
system '/usr/bin/glabels-batch', "--input=#{csv_file.path}", "--output=#{pdf_file.path}", AssetBase::Application.config.computer_label
system '/usr/bin/lpr', '-P', 'LabelWriter-450', pdf_file.path
ensure
pdf_file.unlink
end
end
csv_file.unlink
end
printed_labels
end
Fedora Linux, - CUPS, PDF, . CUPS .
There are other methods for creating structured text in PDF, but for shortcuts gLabels is great.
source
share