-
Notifications
You must be signed in to change notification settings - Fork 0
/
af-list-jobs
executable file
·57 lines (48 loc) · 1.88 KB
/
af-list-jobs
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
#!/usr/bin/python
# vim:set ft=python ts=4 sw=4 et fileencoding=utf-8:
# af-list-jobs -- List completed and finished print jobs for the Ricoh Aficio
# 1075
#
# Copyright (C) 2008 Fabian Knittel <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
# Depends on aficio.jobs
from optparse import OptionParser
from aficio1075 import jobs
import sys
import codecs
sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)
sys.stderr = codecs.getwriter('UTF-8')(sys.stderr)
def display_list(joblist):
if joblist.jobs is None:
return
for job in sorted(joblist.jobs, lambda x, y: -cmp(x.id, y.id)):
print '%s, %s, %s, %s, %s, %s' % (job.id, job.user_name, job.doc_name,
job.status, job.pages, job.size)
def main():
parser = OptionParser()
parser.add_option("--hostname", action = "store", dest = "hostname",
help = "Hostname of the Aficio printer")
(options, args) = parser.parse_args()
if len(args) != 0:
parser.error("incorrect number of arguments")
wjl = jobs.WaitingJobList(host = options.hostname)
print 'Active jobs:'
display_list(wjl)
jl = jobs.JobList(host = options.hostname)
print 'Finished jobs:'
display_list(jl)
if __name__ == '__main__':
main()