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
61b95db3
Kaydet (Commit)
61b95db3
authored
Kas 17, 1999
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
# *NOT* by Sam Bayer: reindented to use 4 spaces like the rest here,
# and removed trailing whitespace.
üst
64acb5ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
203 additions
and
204 deletions
+203
-204
wsgui.py
Tools/webchecker/wsgui.py
+203
-204
No files found.
Tools/webchecker/wsgui.py
Dosyayı görüntüle @
61b95db3
...
@@ -14,231 +14,230 @@ import sys
...
@@ -14,231 +14,230 @@ import sys
import
os
import
os
import
threading
import
threading
import
Queue
import
Queue
import
time
import
time
VERBOSE
=
2
VERBOSE
=
2
try
:
try
:
class
Canceled
(
Exception
):
class
Canceled
(
Exception
):
"Exception used to cancel run()."
"Exception used to cancel run()."
except
:
except
:
Canceled
=
__name__
+
".Canceled"
Canceled
=
__name__
+
".Canceled"
class
SuckerThread
(
websucker
.
Sucker
):
class
SuckerThread
(
websucker
.
Sucker
):
stopit
=
0
stopit
=
0
savedir
=
None
savedir
=
None
rootdir
=
None
rootdir
=
None
def
__init__
(
self
,
msgq
):
def
__init__
(
self
,
msgq
):
self
.
msgq
=
msgq
self
.
msgq
=
msgq
websucker
.
Sucker
.
__init__
(
self
)
websucker
.
Sucker
.
__init__
(
self
)
self
.
setflags
(
verbose
=
VERBOSE
)
self
.
setflags
(
verbose
=
VERBOSE
)
self
.
urlopener
.
addheaders
=
[
self
.
urlopener
.
addheaders
=
[
(
'User-agent'
,
'websucker/
%
s'
%
websucker
.
__version__
),
(
'User-agent'
,
'websucker/
%
s'
%
websucker
.
__version__
),
]
]
def
message
(
self
,
format
,
*
args
):
def
message
(
self
,
format
,
*
args
):
if
args
:
if
args
:
format
=
format
%
args
format
=
format
%
args
##print format
##print format
self
.
msgq
.
put
(
format
)
self
.
msgq
.
put
(
format
)
def
run1
(
self
,
url
):
def
run1
(
self
,
url
):
try
:
try
:
try
:
try
:
self
.
reset
()
self
.
reset
()
self
.
addroot
(
url
)
self
.
addroot
(
url
)
self
.
run
()
self
.
run
()
except
Canceled
:
except
Canceled
:
self
.
message
(
"[canceled]"
)
self
.
message
(
"[canceled]"
)
else
:
else
:
self
.
message
(
"[done]"
)
self
.
message
(
"[done]"
)
finally
:
finally
:
self
.
msgq
.
put
(
None
)
self
.
msgq
.
put
(
None
)
def
savefile
(
self
,
text
,
path
):
def
savefile
(
self
,
text
,
path
):
if
self
.
stopit
:
if
self
.
stopit
:
raise
Canceled
raise
Canceled
websucker
.
Sucker
.
savefile
(
self
,
text
,
path
)
websucker
.
Sucker
.
savefile
(
self
,
text
,
path
)
def
getpage
(
self
,
url
):
def
getpage
(
self
,
url
):
if
self
.
stopit
:
if
self
.
stopit
:
raise
Canceled
raise
Canceled
return
websucker
.
Sucker
.
getpage
(
self
,
url
)
return
websucker
.
Sucker
.
getpage
(
self
,
url
)
def
savefilename
(
self
,
url
):
def
savefilename
(
self
,
url
):
path
=
websucker
.
Sucker
.
savefilename
(
self
,
url
)
path
=
websucker
.
Sucker
.
savefilename
(
self
,
url
)
if
self
.
savedir
:
if
self
.
savedir
:
n
=
len
(
self
.
rootdir
)
n
=
len
(
self
.
rootdir
)
if
path
[:
n
]
==
self
.
rootdir
:
if
path
[:
n
]
==
self
.
rootdir
:
path
=
path
[
n
:]
path
=
path
[
n
:]
while
path
[:
1
]
==
os
.
sep
:
while
path
[:
1
]
==
os
.
sep
:
path
=
path
[
1
:]
path
=
path
[
1
:]
path
=
os
.
path
.
join
(
self
.
savedir
,
path
)
path
=
os
.
path
.
join
(
self
.
savedir
,
path
)
return
path
return
path
def
XXXaddrobot
(
self
,
*
args
):
def
XXXaddrobot
(
self
,
*
args
):
pass
pass
def
XXXisallowed
(
self
,
*
args
):
def
XXXisallowed
(
self
,
*
args
):
return
1
return
1
class
App
:
class
App
:
sucker
=
None
sucker
=
None
msgq
=
None
msgq
=
None
def
__init__
(
self
,
top
):
def
__init__
(
self
,
top
):
self
.
top
=
top
self
.
top
=
top
top
.
columnconfigure
(
99
,
weight
=
1
)
top
.
columnconfigure
(
99
,
weight
=
1
)
self
.
url_label
=
Label
(
top
,
text
=
"URL:"
)
self
.
url_label
=
Label
(
top
,
text
=
"URL:"
)
self
.
url_label
.
grid
(
row
=
0
,
column
=
0
,
sticky
=
'e'
)
self
.
url_label
.
grid
(
row
=
0
,
column
=
0
,
sticky
=
'e'
)
self
.
url_entry
=
Entry
(
top
,
width
=
60
,
exportselection
=
0
)
self
.
url_entry
=
Entry
(
top
,
width
=
60
,
exportselection
=
0
)
self
.
url_entry
.
grid
(
row
=
0
,
column
=
1
,
sticky
=
'we'
,
self
.
url_entry
.
grid
(
row
=
0
,
column
=
1
,
sticky
=
'we'
,
columnspan
=
99
)
columnspan
=
99
)
self
.
url_entry
.
focus_set
()
self
.
url_entry
.
focus_set
()
self
.
url_entry
.
bind
(
"<Key-Return>"
,
self
.
go
)
self
.
url_entry
.
bind
(
"<Key-Return>"
,
self
.
go
)
self
.
dir_label
=
Label
(
top
,
text
=
"Directory:"
)
self
.
dir_label
=
Label
(
top
,
text
=
"Directory:"
)
self
.
dir_label
.
grid
(
row
=
1
,
column
=
0
,
sticky
=
'e'
)
self
.
dir_label
.
grid
(
row
=
1
,
column
=
0
,
sticky
=
'e'
)
self
.
dir_entry
=
Entry
(
top
)
self
.
dir_entry
=
Entry
(
top
)
self
.
dir_entry
.
grid
(
row
=
1
,
column
=
1
,
sticky
=
'we'
,
self
.
dir_entry
.
grid
(
row
=
1
,
column
=
1
,
sticky
=
'we'
,
columnspan
=
99
)
columnspan
=
99
)
self
.
go_button
=
Button
(
top
,
text
=
"Go"
,
command
=
self
.
go
)
self
.
go_button
=
Button
(
top
,
text
=
"Go"
,
command
=
self
.
go
)
self
.
go_button
.
grid
(
row
=
2
,
column
=
1
,
sticky
=
'w'
)
self
.
go_button
.
grid
(
row
=
2
,
column
=
1
,
sticky
=
'w'
)
self
.
cancel_button
=
Button
(
top
,
text
=
"Cancel"
,
self
.
cancel_button
=
Button
(
top
,
text
=
"Cancel"
,
command
=
self
.
cancel
,
command
=
self
.
cancel
,
state
=
DISABLED
)
state
=
DISABLED
)
self
.
cancel_button
.
grid
(
row
=
2
,
column
=
2
,
sticky
=
'w'
)
self
.
cancel_button
.
grid
(
row
=
2
,
column
=
2
,
sticky
=
'w'
)
self
.
auto_button
=
Button
(
top
,
text
=
"Paste+Go"
,
self
.
auto_button
=
Button
(
top
,
text
=
"Paste+Go"
,
command
=
self
.
auto
)
command
=
self
.
auto
)
self
.
auto_button
.
grid
(
row
=
2
,
column
=
3
,
sticky
=
'w'
)
self
.
auto_button
.
grid
(
row
=
2
,
column
=
3
,
sticky
=
'w'
)
self
.
status_label
=
Label
(
top
,
text
=
"[idle]"
)
self
.
status_label
=
Label
(
top
,
text
=
"[idle]"
)
self
.
status_label
.
grid
(
row
=
2
,
column
=
4
,
sticky
=
'w'
)
self
.
status_label
.
grid
(
row
=
2
,
column
=
4
,
sticky
=
'w'
)
self
.
top
.
update_idletasks
()
self
.
top
.
update_idletasks
()
self
.
top
.
grid_propagate
(
0
)
self
.
top
.
grid_propagate
(
0
)
def
message
(
self
,
text
,
*
args
):
def
message
(
self
,
text
,
*
args
):
if
args
:
if
args
:
text
=
text
%
args
text
=
text
%
args
self
.
status_label
.
config
(
text
=
text
)
self
.
status_label
.
config
(
text
=
text
)
def
check_msgq
(
self
):
def
check_msgq
(
self
):
while
not
self
.
msgq
.
empty
():
while
not
self
.
msgq
.
empty
():
msg
=
self
.
msgq
.
get
()
msg
=
self
.
msgq
.
get
()
if
msg
is
None
:
if
msg
is
None
:
self
.
go_button
.
configure
(
state
=
NORMAL
)
self
.
go_button
.
configure
(
state
=
NORMAL
)
self
.
auto_button
.
configure
(
state
=
NORMAL
)
self
.
auto_button
.
configure
(
state
=
NORMAL
)
self
.
cancel_button
.
configure
(
state
=
DISABLED
)
self
.
cancel_button
.
configure
(
state
=
DISABLED
)
if
self
.
sucker
:
if
self
.
sucker
:
self
.
sucker
.
stopit
=
0
self
.
sucker
.
stopit
=
0
self
.
top
.
bell
()
self
.
top
.
bell
()
else
:
else
:
self
.
message
(
msg
)
self
.
message
(
msg
)
self
.
top
.
after
(
100
,
self
.
check_msgq
)
self
.
top
.
after
(
100
,
self
.
check_msgq
)
def
go
(
self
,
event
=
None
):
def
go
(
self
,
event
=
None
):
if
not
self
.
msgq
:
if
not
self
.
msgq
:
self
.
msgq
=
Queue
.
Queue
(
0
)
self
.
msgq
=
Queue
.
Queue
(
0
)
self
.
check_msgq
()
self
.
check_msgq
()
if
not
self
.
sucker
:
if
not
self
.
sucker
:
self
.
sucker
=
SuckerThread
(
self
.
msgq
)
self
.
sucker
=
SuckerThread
(
self
.
msgq
)
if
self
.
sucker
.
stopit
:
if
self
.
sucker
.
stopit
:
return
return
self
.
url_entry
.
selection_range
(
0
,
END
)
self
.
url_entry
.
selection_range
(
0
,
END
)
url
=
self
.
url_entry
.
get
()
url
=
self
.
url_entry
.
get
()
url
=
string
.
strip
(
url
)
url
=
string
.
strip
(
url
)
if
not
url
:
if
not
url
:
self
.
top
.
bell
()
self
.
top
.
bell
()
self
.
message
(
"[Error: No URL entered]"
)
self
.
message
(
"[Error: No URL entered]"
)
return
return
self
.
rooturl
=
url
self
.
rooturl
=
url
dir
=
string
.
strip
(
self
.
dir_entry
.
get
())
dir
=
string
.
strip
(
self
.
dir_entry
.
get
())
if
not
dir
:
if
not
dir
:
self
.
sucker
.
savedir
=
None
self
.
sucker
.
savedir
=
None
else
:
else
:
self
.
sucker
.
savedir
=
dir
self
.
sucker
.
savedir
=
dir
self
.
sucker
.
rootdir
=
os
.
path
.
dirname
(
self
.
sucker
.
rootdir
=
os
.
path
.
dirname
(
websucker
.
Sucker
.
savefilename
(
self
,
url
))
websucker
.
Sucker
.
savefilename
(
self
,
url
))
self
.
go_button
.
configure
(
state
=
DISABLED
)
self
.
go_button
.
configure
(
state
=
DISABLED
)
self
.
auto_button
.
configure
(
state
=
DISABLED
)
self
.
auto_button
.
configure
(
state
=
DISABLED
)
self
.
cancel_button
.
configure
(
state
=
NORMAL
)
self
.
cancel_button
.
configure
(
state
=
NORMAL
)
self
.
message
(
'[running...]'
)
self
.
message
(
'[running...]'
)
self
.
sucker
.
stopit
=
0
self
.
sucker
.
stopit
=
0
t
=
threading
.
Thread
(
target
=
self
.
sucker
.
run1
,
args
=
(
url
,))
t
=
threading
.
Thread
(
target
=
self
.
sucker
.
run1
,
args
=
(
url
,))
t
.
start
()
t
.
start
()
def
cancel
(
self
):
def
cancel
(
self
):
if
self
.
sucker
:
if
self
.
sucker
:
self
.
sucker
.
stopit
=
1
self
.
sucker
.
stopit
=
1
self
.
message
(
"[canceling...]"
)
self
.
message
(
"[canceling...]"
)
def
auto
(
self
):
def
auto
(
self
):
tries
=
[
'PRIMARY'
,
'CLIPBOARD'
]
tries
=
[
'PRIMARY'
,
'CLIPBOARD'
]
text
=
""
text
=
""
for
t
in
tries
:
for
t
in
tries
:
try
:
try
:
text
=
self
.
top
.
selection_get
(
selection
=
t
)
text
=
self
.
top
.
selection_get
(
selection
=
t
)
except
TclError
:
except
TclError
:
continue
continue
text
=
string
.
strip
(
text
)
text
=
string
.
strip
(
text
)
if
text
:
if
text
:
break
break
if
not
text
:
if
not
text
:
self
.
top
.
bell
()
self
.
top
.
bell
()
self
.
message
(
"[Error: clipboard is empty]"
)
self
.
message
(
"[Error: clipboard is empty]"
)
return
return
self
.
url_entry
.
delete
(
0
,
END
)
self
.
url_entry
.
delete
(
0
,
END
)
self
.
url_entry
.
insert
(
0
,
text
)
self
.
url_entry
.
insert
(
0
,
text
)
self
.
go
()
self
.
go
()
class
AppArray
:
class
AppArray
:
def
__init__
(
self
,
top
=
None
):
def
__init__
(
self
,
top
=
None
):
if
not
top
:
if
not
top
:
top
=
Tk
()
top
=
Tk
()
top
.
title
(
"websucker GUI"
)
top
.
title
(
"websucker GUI"
)
top
.
iconname
(
"wsgui"
)
top
.
iconname
(
"wsgui"
)
top
.
wm_protocol
(
'WM_DELETE_WINDOW'
,
self
.
exit
)
top
.
wm_protocol
(
'WM_DELETE_WINDOW'
,
self
.
exit
)
self
.
top
=
top
self
.
top
=
top
self
.
appframe
=
Frame
(
self
.
top
)
self
.
appframe
=
Frame
(
self
.
top
)
self
.
appframe
.
pack
(
fill
=
'both'
)
self
.
appframe
.
pack
(
fill
=
'both'
)
self
.
applist
=
[]
self
.
applist
=
[]
self
.
exit_button
=
Button
(
top
,
text
=
"Exit"
,
command
=
self
.
exit
)
self
.
exit_button
=
Button
(
top
,
text
=
"Exit"
,
command
=
self
.
exit
)
self
.
exit_button
.
pack
(
side
=
RIGHT
)
self
.
exit_button
.
pack
(
side
=
RIGHT
)
self
.
new_button
=
Button
(
top
,
text
=
"New"
,
command
=
self
.
addsucker
)
self
.
new_button
=
Button
(
top
,
text
=
"New"
,
command
=
self
.
addsucker
)
self
.
new_button
.
pack
(
side
=
LEFT
)
self
.
new_button
.
pack
(
side
=
LEFT
)
self
.
addsucker
()
self
.
addsucker
()
##self.applist[0].url_entry.insert(END, "http://www.python.org/doc/essays/")
##self.applist[0].url_entry.insert(END, "http://www.python.org/doc/essays/")
def
addsucker
(
self
):
def
addsucker
(
self
):
self
.
top
.
geometry
(
""
)
self
.
top
.
geometry
(
""
)
frame
=
Frame
(
self
.
appframe
,
borderwidth
=
2
,
relief
=
GROOVE
)
frame
=
Frame
(
self
.
appframe
,
borderwidth
=
2
,
relief
=
GROOVE
)
frame
.
pack
(
fill
=
'x'
)
frame
.
pack
(
fill
=
'x'
)
app
=
App
(
frame
)
app
=
App
(
frame
)
self
.
applist
.
append
(
app
)
self
.
applist
.
append
(
app
)
done
=
0
done
=
0
def
mainloop
(
self
):
def
mainloop
(
self
):
while
not
self
.
done
:
while
not
self
.
done
:
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
self
.
top
.
update
()
self
.
top
.
update
()
def
exit
(
self
):
def
exit
(
self
):
for
app
in
self
.
applist
:
for
app
in
self
.
applist
:
app
.
cancel
()
app
.
cancel
()
app
.
message
(
"[exiting...]"
)
app
.
message
(
"[exiting...]"
)
self
.
done
=
1
self
.
done
=
1
def
main
():
def
main
():
AppArray
()
.
mainloop
()
AppArray
()
.
mainloop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
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