Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Justin
slapos.toolbox
Commits
f0711a83
Commit
f0711a83
authored
Jan 27, 2012
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add wordpress version of logfollower
parent
3d1c1ba6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
0 deletions
+83
-0
setup.py
setup.py
+1
-0
slapos/wordpress/ia/logfollower.py
slapos/wordpress/ia/logfollower.py
+82
-0
No files found.
setup.py
View file @
f0711a83
...
...
@@ -67,6 +67,7 @@ setup(name=name,
'logfollower = slapos.logfollower:main'
,
'runafter = slapos.runafter:main'
,
'wp-agent = slapos.wordpress.ia.http:main'
,
'wp-logfollower = slapos.wordpress.ia.logfollower:main'
,
]
},
)
slapos/wordpress/ia/logfollower.py
0 → 100644
View file @
f0711a83
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 3
# of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
argparse
import
re
import
os
import
urllib2
import
urlparse
from
slapos
import
logfollower
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"Log follower."
)
parser
.
add_argument
(
'--regex'
,
'-r'
,
help
=
"Regular expression which "
"trigger the callback."
,
required
=
True
)
parser
.
add_argument
(
'--rotated'
,
action
=
'store_const'
,
default
=
False
,
const
=
True
,
help
=
"Specify that the logfile can be "
"rotated. This will detect the "
"rotation and reload it."
)
parser
.
add_argument
(
'--timeout'
,
'-t'
,
default
=-
1
,
type
=
int
)
parser
.
add_argument
(
'--wait-for-creation'
,
action
=
'store_const'
,
default
=
False
,
const
=
True
,
help
=
"Wait for the log file creation."
)
parser
.
add_argument
(
'logfile'
,
metavar
=
'LOGFILE'
,
nargs
=
1
,
help
=
"Log file to follow."
)
parser
.
add_argument
(
'url'
,
metavar
=
'URL'
,
nargs
=
1
,
help
=
"Url where to posts logs"
)
args
=
parser
.
parse_args
()
try
:
regex
=
re
.
compile
(
args
.
regex
)
except
:
parser
.
error
(
"Bad regular expression."
)
log_filename
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
getcwd
(),
args
.
logfile
[
0
]))
if
args
.
wait_for_creation
:
try
:
logfollower
.
wait_for_creation
(
log_filename
)
except
:
return
1
# Exit failure
elif
not
os
.
path
.
isfile
(
log_filename
):
return
1
# Exit failure
for
line
in
logfollower
.
follow_each_line
(
args
.
logfile
[
0
],
args
.
rotated
,
args
.
timeout
):
message
=
'<p>OK</p>'
if
line
==
None
:
message
=
'<p>TIMEOUT</p>'
elif
regex
.
match
(
line
):
message
=
'<p>FAIL</p>'
urllib2
.
urlopen
(
urllib2
.
Request
(
url
=
urlparse
.
urljoin
(
args
.
url
[
0
],
'?Status'
),
data
=
message
,
headers
=
{
'Content-Type'
:
'application/octet-stream'
},
)).
read
()
if
__name__
==
'__main__'
:
__import__
(
'sys'
).
exit
(
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