Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
perun-proxy-utils
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Perun
Perun ProxyIdP
perun-proxy-utils
Commits
5cfec908
Verified
Commit
5cfec908
authored
1 year ago
by
Jiří Prokop
Browse files
Options
Downloads
Patches
Plain Diff
fix: check_php_syntax to work with containers
parent
0d9e1624
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!41
fix: check_php_syntax to work with containers
Pipeline
#311875
passed
1 year ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
perun/proxy/utils/nagios/check_php_syntax.py
+25
-23
25 additions, 23 deletions
perun/proxy/utils/nagios/check_php_syntax.py
with
25 additions
and
23 deletions
perun/proxy/utils/nagios/check_php_syntax.py
+
25
−
23
View file @
5cfec908
#!/usr/bin/env python3
import
os
import
subprocess
import
sys
import
argparse
...
...
@@ -20,39 +19,42 @@ def get_args():
"
automatically generated files
"
)
)
parser
.
add_argument
(
"
-c
"
,
"
--container
"
,
required
=
True
,
help
=
"
Docker container name to run PHP syntax check inside
"
,
)
parser
.
add_argument
(
"
-d
"
,
"
--directory
"
,
required
=
True
,
help
=
"
path which will be scanned for PHP files, including subdirectories
"
,
help
=
(
"
path inside container which will be scanned for PHP files, including
"
"
subdirectories
"
),
)
return
parser
.
parse_args
()
def
main
():
dir
=
get_args
().
directory
os
.
chdir
(
dir
)
paths
=
[]
for
(
dirpath
,
dirname
,
filenames
,
)
in
os
.
walk
(
"
.
"
):
for
f
in
filenames
:
if
f
.
endswith
(
"
.php
"
):
paths
.
append
(
os
.
path
.
join
(
dirpath
,
f
,
)
)
args
=
get_args
()
dir
=
args
.
directory
container
=
args
.
container
container_paths
=
(
subprocess
.
getoutput
(
f
"
docker exec
{
container
}
find
{
dir
}
-type f -name
'
*.php
'"
)
.
strip
()
.
split
(
"
\n
"
)
)
global_result
=
""
for
path
in
paths
:
if
os
.
path
.
isfile
(
path
):
result
=
subprocess
.
getoutput
(
f
"
php -l
{
path
}
"
)
if
not
result
.
startswith
(
"
No syntax errors
"
):
global_result
+=
f
"
{
result
}
|
"
for
path
in
container_paths
:
result
=
subprocess
.
getoutput
(
f
"
docker exec
{
container
}
php -l
{
path
}
"
)
if
"
No syntax errors
"
not
in
result
:
global_result
+=
f
"
{
result
}
|
"
if
not
global_result
:
print
(
f
"
{
OK
}
check_php_syntax - OK
"
)
...
...
This diff is collapsed.
Click to expand it.
Jednotné přihlášení test
@9008807
mentioned in commit
cd51abcd
·
1 year ago
mentioned in commit
cd51abcd
mentioned in commit cd51abcd5c86911ff4fdf7b034f274ca096ed20e
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment