Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden - archive
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
713
Warden
Warden - archive
Commits
44237c0f
Commit
44237c0f
authored
Jul 20, 2017
by
Pavel Kácha
Browse files
Options
Downloads
Patches
Plain Diff
Print as a function (Py3 preparation) (thx krkos@cesnet.cz)
parent
9b9fabc1
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
warden3/warden_server/warden_server.py
+13
-11
13 additions, 11 deletions
warden3/warden_server/warden_server.py
with
13 additions
and
11 deletions
warden3/warden_server/warden_server.py
+
13
−
11
View file @
44237c0f
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
# Copyright (C) 2011-2015 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
# Use of this source is governed by a 3-clause BSD-style license, see LICENSE file.
# Use of this source is governed by a 3-clause BSD-style license, see LICENSE file.
from
__future__
import
print_function
import
sys
import
sys
import
os
import
os
import
logging
import
logging
...
@@ -1473,7 +1475,7 @@ def build_server(conf, section_order=section_order, section_def=section_def, par
...
@@ -1473,7 +1475,7 @@ def build_server(conf, section_order=section_order, section_def=section_def, par
def
check_config
():
def
check_config
():
# If we got so far, server object got set up fine
# If we got so far, server object got set up fine
print
>>
sys
.
stderr
,
"
Looks clear.
"
print
(
"
Looks clear.
"
,
file
=
sys
.
stderr
)
return
0
return
0
...
@@ -1483,7 +1485,7 @@ def list_clients(id=None):
...
@@ -1483,7 +1485,7 @@ def list_clients(id=None):
col_width
=
[
max
(
len
(
val
)
for
val
in
col
)
for
col
in
zip
(
*
(
lines
+
[
Client
.
_fields
]))]
col_width
=
[
max
(
len
(
val
)
for
val
in
col
)
for
col
in
zip
(
*
(
lines
+
[
Client
.
_fields
]))]
divider
=
[
"
-
"
*
l
for
l
in
col_width
]
divider
=
[
"
-
"
*
l
for
l
in
col_width
]
for
line
in
[
Client
.
_fields
,
divider
]
+
lines
:
for
line
in
[
Client
.
_fields
,
divider
]
+
lines
:
print
"
"
.
join
([
val
.
ljust
(
width
)
for
val
,
width
in
zip
(
line
,
col_width
)])
print
(
"
"
.
join
([
val
.
ljust
(
width
)
for
val
,
width
in
zip
(
line
,
col_width
)])
)
return
0
return
0
...
@@ -1529,29 +1531,29 @@ def modify_client(**kwargs):
...
@@ -1529,29 +1531,29 @@ def modify_client(**kwargs):
if
kwargs
[
"
name
"
]
is
not
None
:
if
kwargs
[
"
name
"
]
is
not
None
:
kwargs
[
"
name
"
]
=
kwargs
[
"
name
"
].
lower
()
kwargs
[
"
name
"
]
=
kwargs
[
"
name
"
].
lower
()
if
not
isValidNSID
(
kwargs
[
"
name
"
]):
if
not
isValidNSID
(
kwargs
[
"
name
"
]):
print
>>
sys
.
stderr
,
"
Invalid client name
\"
%s
\"
.
"
%
kwargs
[
"
name
"
]
print
(
"
Invalid client name
\"
%s
\"
.
"
%
(
kwargs
[
"
name
"
]
),
file
=
sys
.
stderr
)
return
254
return
254
if
kwargs
[
"
hostname
"
]
is
not
None
:
if
kwargs
[
"
hostname
"
]
is
not
None
:
kwargs
[
"
hostname
"
]
=
kwargs
[
"
hostname
"
].
lower
()
kwargs
[
"
hostname
"
]
=
kwargs
[
"
hostname
"
].
lower
()
if
not
isValidHostname
(
kwargs
[
"
hostname
"
]):
if
not
isValidHostname
(
kwargs
[
"
hostname
"
]):
print
>>
sys
.
stderr
,
"
Invalid hostname
\"
%s
\"
.
"
%
kwargs
[
"
hostname
"
]
print
(
"
Invalid hostname
\"
%s
\"
.
"
%
(
kwargs
[
"
hostname
"
]
),
file
=
sys
.
stderr
)
return
253
return
253
if
kwargs
[
"
requestor
"
]
is
not
None
and
not
isValidEmail
(
kwargs
[
"
requestor
"
]):
if
kwargs
[
"
requestor
"
]
is
not
None
and
not
isValidEmail
(
kwargs
[
"
requestor
"
]):
print
>>
sys
.
stderr
,
"
Invalid requestor email
\"
%s
\"
.
"
%
kwargs
[
"
requestor
"
]
print
(
"
Invalid requestor email
\"
%s
\"
.
"
%
(
kwargs
[
"
requestor
"
]
),
file
=
sys
.
stderr
)
return
252
return
252
if
kwargs
[
"
id
"
]
is
not
None
and
not
isValidID
(
kwargs
[
"
id
"
]):
if
kwargs
[
"
id
"
]
is
not
None
and
not
isValidID
(
kwargs
[
"
id
"
]):
print
>>
sys
.
stderr
,
"
Invalid id
\"
%s
\"
.
"
%
kwargs
[
"
id
"
]
print
(
"
Invalid id
\"
%s
\"
.
"
%
(
kwargs
[
"
id
"
]
),
file
=
sys
.
stderr
)
return
251
return
251
for
c
in
server
.
handler
.
db
.
get_clients
():
for
c
in
server
.
handler
.
db
.
get_clients
():
if
kwargs
[
"
name
"
]
is
not
None
and
kwargs
[
"
name
"
].
lower
()
==
c
.
name
:
if
kwargs
[
"
name
"
]
is
not
None
and
kwargs
[
"
name
"
].
lower
()
==
c
.
name
:
print
>>
sys
.
stderr
,
"
Clash with existing name: %s
"
%
str
(
c
)
print
(
"
Clash with existing name: %s
"
%
(
str
(
c
)
),
file
=
sys
.
stderr
)
return
250
return
250
if
kwargs
[
"
secret
"
]
is
not
None
and
kwargs
[
"
secret
"
]
==
c
.
secret
:
if
kwargs
[
"
secret
"
]
is
not
None
and
kwargs
[
"
secret
"
]
==
c
.
secret
:
print
>>
sys
.
stderr
,
"
Clash with existing secret: %s
"
%
str
(
c
)
print
(
"
Clash with existing secret: %s
"
%
str
(
c
)
,
file
=
sys
.
stderr
)
return
249
return
249
newid
=
server
.
handler
.
db
.
add_modify_client
(
**
kwargs
)
newid
=
server
.
handler
.
db
.
add_modify_client
(
**
kwargs
)
...
@@ -1569,10 +1571,10 @@ def purge(days=30, lastlog=None, events=None):
...
@@ -1569,10 +1571,10 @@ def purge(days=30, lastlog=None, events=None):
lastlog
=
events
=
True
lastlog
=
events
=
True
if
lastlog
:
if
lastlog
:
count
=
server
.
handler
.
db
.
purge_lastlog
(
days
)
count
=
server
.
handler
.
db
.
purge_lastlog
(
days
)
print
"
Purged %d lastlog entries.
"
%
count
print
(
"
Purged %d lastlog entries.
"
%
(
count
))
if
events
:
if
events
:
count
=
server
.
handler
.
db
.
purge_events
(
days
)
count
=
server
.
handler
.
db
.
purge_events
(
days
)
print
"
Purged %d events.
"
%
count
print
(
"
Purged %d events.
"
%
(
count
))
return
0
return
0
...
@@ -1695,6 +1697,6 @@ if __name__=="__main__":
...
@@ -1695,6 +1697,6 @@ if __name__=="__main__":
del
subargs
[
"
command
"
]
del
subargs
[
"
command
"
]
del
subargs
[
"
config
"
]
del
subargs
[
"
config
"
]
if
not
server
or
server
is
fallback_wsgi
:
if
not
server
or
server
is
fallback_wsgi
:
print
>>
sys
.
stderr
,
"
Failed initialization, check configured log targets for reasons.
"
print
(
"
Failed initialization, check configured log targets for reasons.
"
,
file
=
sys
.
stderr
)
sys
.
exit
(
255
)
sys
.
exit
(
255
)
sys
.
exit
(
command
(
**
subargs
))
sys
.
exit
(
command
(
**
subargs
))
This diff is collapsed.
Click to expand it.
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