Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7030d0a1
Kaydet (Commit)
7030d0a1
authored
Ara 18, 1991
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Modularized the code.
üst
5558b893
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
33 deletions
+26
-33
lpwatch.py
Demo/scripts/lpwatch.py
+26
-33
No files found.
Demo/scripts/lpwatch.py
Dosyayı görüntüle @
7030d0a1
...
...
@@ -34,22 +34,15 @@ def main():
clearhome
=
posix
.
popen
(
'clear'
,
'r'
)
.
read
()
#
while
1
:
# Pipe output through cat for extra buffering,
# so the output (which overwrites the previous)
# appears instantaneous.
sys
.
stdout
=
posix
.
popen
(
'exec cat'
,
'w'
)
sys
.
stdout
.
write
(
clearhome
)
text
=
clearhome
for
name
in
printers
:
pipe
=
posix
.
popen
(
'lpq -P'
+
name
+
' 2>&1'
,
'r'
)
showstatus
(
name
,
pipe
,
thisuser
)
sts
=
pipe
.
close
()
if
sts
:
print
name
+
': *** lpq exit status'
,
sts
sts
=
sys
.
stdout
.
close
()
text
=
text
+
makestatus
(
name
,
thisuser
)
+
'
\n
'
print
text
time
.
sleep
(
delay
)
def
showstatus
(
name
,
pipe
,
thisuser
):
lines
=
0
def
makestatus
(
name
,
thisuser
):
pipe
=
posix
.
popen
(
'lpq -P'
+
name
+
' 2>&1'
,
'r'
)
lines
=
[]
users
=
{}
aheadbytes
=
0
aheadjobs
=
0
...
...
@@ -83,33 +76,33 @@ def showstatus(name, pipe, thisuser):
users
[
user
]
=
ujobs
,
ubytes
else
:
if
fields
and
fields
[
0
]
<>
'Rank'
:
if
line
[
-
1
:]
=
'
\n
'
:
line
=
line
[:
-
1
]
if
not
lines
:
print
name
+
':'
,
else
:
print
print
line
,
lines
=
lines
+
1
line
=
string
.
strip
(
line
)
if
line
=
'no entries'
:
line
=
name
+
': idle'
elif
line
[
-
22
:]
=
' is ready and printing'
:
line
=
name
lines
.
append
(
line
)
#
if
totaljobs
:
if
lines
>
1
:
print
lines
=
lines
+
1
print
(
totalbytes
+
1023
)
/
1024
,
'K'
,
line
=
`(totalbytes+1023)/1024`
+
' K'
if
totaljobs
<>
len
(
users
):
print
'('
+
`totaljobs`
+
' jobs)'
,
line
=
line
+
' ('
+
`totaljobs`
+
' jobs)'
if
len
(
users
)
=
1
:
print
'for'
,
users
.
keys
()[
0
],
line
=
line
+
' for '
+
users
.
keys
()[
0
]
else
:
print
'for'
,
len
(
users
),
'users'
,
line
=
line
+
' for '
+
`len(users)`
+
' users'
if
userseen
:
if
aheadjobs
=
0
:
print
'('
+
thisuser
+
' first)'
,
line
=
line
+
' ('
+
thisuser
+
' first)'
else
:
print
'('
+
`(aheadbytes+1023)/1024`
,
print
'K before'
,
thisuser
+
')'
if
lines
:
print
line
=
line
+
' ('
+
`(aheadbytes+1023)/1024`
line
=
line
+
' K before '
+
thisuser
+
')'
lines
.
append
(
line
)
#
sts
=
pipe
.
close
()
if
sts
:
lines
.
append
(
'lpq exit status '
+
`sts`
)
return
string
.
joinfields
(
lines
,
': '
)
try
:
main
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment