Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
url-checker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
url-checker
Commits
7479fca7
Commit
7479fca7
authored
Oct 16, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Infinite loop
parent
c2b9d57d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
9 deletions
+23
-9
urlchecker_http.py
urlchecker_http.py
+23
-9
No files found.
urlchecker_http.py
View file @
7479fca7
...
@@ -26,7 +26,7 @@ class BotError(Exception):
...
@@ -26,7 +26,7 @@ class BotError(Exception):
class
WebBot
:
class
WebBot
:
def
__init__
(
self
):
def
__init__
(
self
):
self
.
config
=
configparser
.
ConfigParser
(
empty_lines_in_values
=
False
)
self
.
config
=
configparser
.
ConfigParser
(
empty_lines_in_values
=
False
)
self
.
config
[
CONFIG_SECTION
]
=
{}
self
.
config
[
CONFIG_SECTION
]
=
{
"INTERVAL"
:
60
}
def
initDB
(
self
,
sqlite_path
):
def
initDB
(
self
,
sqlite_path
):
self
.
_db
=
LogDB
(
sqlite_path
)
self
.
_db
=
LogDB
(
sqlite_path
)
...
@@ -116,6 +116,17 @@ class WebBot:
...
@@ -116,6 +116,17 @@ class WebBot:
)
)
self
.
_db
.
storeQuery
(
ip
,
url
,
response
.
status_code
)
self
.
_db
.
storeQuery
(
ip
,
url
,
response
.
status_code
)
def
iterateLoop
(
self
):
for
url
in
self
.
config
[
CONFIG_SECTION
][
"URL"
].
split
():
self
.
check
(
url
)
def
stop
(
self
):
print
(
"Bye bye"
)
print
(
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
))
self
.
_running
=
False
if
hasattr
(
self
,
"_db"
):
self
.
_db
.
close
()
def
run
(
self
):
def
run
(
self
):
print
(
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
))
print
(
time
.
strftime
(
"%Y-%m-%d %H:%M:%S"
))
self
.
initDB
(
self
.
config
[
CONFIG_SECTION
][
"SQLITE"
])
self
.
initDB
(
self
.
config
[
CONFIG_SECTION
][
"SQLITE"
])
...
@@ -144,12 +155,15 @@ class WebBot:
...
@@ -144,12 +155,15 @@ class WebBot:
except
Exception
:
except
Exception
:
pass
pass
for
url
in
self
.
config
[
CONFIG_SECTION
][
"URL"
].
split
():
self
.
_running
=
True
try
:
try
:
self
.
check
(
url
)
while
self
.
_running
:
self
.
iterateLoop
()
time
.
sleep
(
self
.
config
.
getint
(
CONFIG_SECTION
,
"INTERVAL"
))
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
self
.
stop
()
self
.
stop
()
except
:
except
:
self
.
stop
()
print
(
"Oups, error"
)
print
(
"Oups, error"
)
raise
raise
...
...
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