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
2b287763
Kaydet (Commit)
2b287763
authored
Ock 05, 2001
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added "repeat.py" -- repeatedly execute a shell command (like
watch(1)). Updated and untabified the README file.
üst
cadfaeca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
7 deletions
+64
-7
README
Demo/curses/README
+6
-7
repeat.py
Demo/curses/repeat.py
+58
-0
No files found.
Demo/curses/README
Dosyayı görüntüle @
2b287763
...
...
@@ -10,11 +10,11 @@ originals. I won't attempt to `beautify' the program anytime soon, but
I wouldn't mind someone else making an effort in that direction, of
course.
ncurses.py
-- currently only a panels demo
ncurses.py
-- currently only a panels demo
XXX this won't work until panel support is checked in
rain.py
-- raindrops keep falling on my desktop
tclock.py
-- ASCII clock, by Howard Jones
xmas.py
-- I'm dreaming of an ASCII christmas
rain.py
-- raindrops keep falling on my desktop
tclock.py
-- ASCII clock, by Howard Jones
xmas.py
-- I'm dreaming of an ASCII christmas
Please send bugfixes and new contributions to me or, even better,
submit them to the Python Bug Tracker on SourceForge
...
...
@@ -24,6 +24,5 @@ submit them to the Python Bug Tracker on SourceForge
Other demos
===========
life.py Simple game of Life
life.py -- Simple game of Life
repeat.py -- Repeatedly execute a shell command (like watch(1))
Demo/curses/repeat.py
0 → 100755
Dosyayı görüntüle @
2b287763
#! /usr/bin/env python
"""repeat <shell-command>
This simple program repeatedly (with 1-second intervals) executes the
shell command given on the command line and displays the output (or as
much of it as fits on the screen). It uses curses to paint each new
output on top of the old output, so that if nothing changes, the
screen doesn't change. This is handy to watch for changes in e.g. a
directory or process listing.
To end, hit Control-C.
"""
# Author: Guido van Rossum
# Disclaimer: there's a Linux program named 'watch' that does the same
# thing. Honestly, I didn't know of its existence when I wrote this!
# To do: add features until it has the same functionality as watch(1);
# then compare code size and development time.
import
os
import
sys
import
time
import
curses
def
main
():
if
not
sys
.
argv
[
1
:]:
print
__doc__
sys
.
exit
(
0
)
cmd
=
" "
.
join
(
sys
.
argv
[
1
:])
p
=
os
.
popen
(
cmd
,
"r"
)
text
=
p
.
read
()
sts
=
p
.
close
()
if
sts
:
print
>>
sys
.
stderr
,
"Exit code:"
,
sts
sys
.
exit
(
sts
)
w
=
curses
.
initscr
()
try
:
while
1
:
w
.
erase
()
try
:
w
.
addstr
(
text
)
except
curses
.
error
:
pass
w
.
refresh
()
time
.
sleep
(
1
)
p
=
os
.
popen
(
cmd
,
"r"
)
text
=
p
.
read
()
sts
=
p
.
close
()
if
sts
:
print
>>
sys
.
stderr
,
"Exit code:"
,
sts
sys
.
exit
(
sts
)
finally
:
curses
.
endwin
()
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