Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
38fb2219
Commit
38fb2219
authored
6 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Avoid imp usage in APT proxy test
parent
e391769f
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
tests/test_apt_proxy.py
+43
-35
43 additions, 35 deletions
tests/test_apt_proxy.py
with
43 additions
and
35 deletions
tests/test_apt_proxy.py
+
43
−
35
View file @
38fb2219
...
...
@@ -5,46 +5,54 @@
Criticality: Normal
Checks that packages mirror works for capture systems
'''
import
imp
from
pathlib
import
Path
import
os
import
requests
import
sys
GREEN
=
'
\033
[92m
'
RED
=
'
\033
[91m
'
DEF
=
'
\033
[0m
'
if
not
os
.
path
.
exists
(
'
/etc/nginx/sites-enabled/skyreach.conf
'
):
print
(
'
Server not running Miris Manager, skipping test
'
)
sys
.
exit
(
2
)
os
.
chdir
(
os
.
path
.
dirname
(
__file__
))
if
not
os
.
path
.
isfile
(
'
../utils.py
'
):
print
(
'
conf.sh not found
'
)
sys
.
exit
(
1
)
es_utils
=
imp
.
load_source
(
'
es_utils
'
,
'
../utils.py
'
)
conf
=
es_utils
.
load_conf
()
all_ok
=
True
conf_servers
=
(
'
CM_SERVER_NAME
'
,
)
try
:
from
requests.packages.urllib3.exceptions
import
InsecureRequestWarning
requests
.
packages
.
urllib3
.
disable_warnings
(
InsecureRequestWarning
)
except
ImportError
:
requests
.
packages
.
urllib3
.
disable_warnings
()
sys
.
path
.
append
(
str
(
Path
(
__file__
).
parents
[
1
].
resolve
()))
# pylint: disable=wrong-import-position
from
envsetup
import
utils
as
u
# noqa: E402
def
main
():
# get Miris Manager domain
path
=
'
/etc/nginx/sites-enabled/skyreach.conf
'
if
not
os
.
path
.
exists
(
path
):
u
.
log
(
'
Server not running Miris Manager, skipping test
'
)
return
2
domain
=
None
with
open
(
path
,
'
r
'
)
as
fo
:
for
line
in
fo
:
if
line
.
strip
().
startswith
(
'
server_name
'
):
domain
=
line
.
strip
()[
len
(
'
server_name
'
):].
strip
(
'
\t
;
'
).
split
(
'
'
)[
0
]
if
not
domain
:
u
.
error
(
'
Miris Manager domain not found in Nginx configuration.
'
)
return
1
for
s
in
conf_servers
:
v
=
conf
.
get
(
s
)
try
:
url
=
'
https://%s/panel.ubicast.eu/old-releases.ubuntu.com/ubuntu/dists/lucid/Release.gpg
'
%
v
print
(
'
Checking url certificate %s
'
%
url
)
d
=
requests
.
get
(
url
,
verify
=
False
).
text
if
'
BEGIN PGP SIGNATURE
'
not
in
d
:
all_ok
=
Fal
se
print
(
'
%sUnexpected content: %s%s
'
%
(
RED
,
d
,
DEF
))
url
=
'
https://%s/panel.ubicast.eu/old-releases.ubuntu.com/ubuntu/dists/lucid/Release.gpg
'
%
domain
u
.
log
(
'
Checking url certificate
"
%s
"
...
'
%
url
)
response
=
requests
.
get
(
url
,
verify
=
False
).
text
if
'
BEGIN PGP SIGNATURE
'
not
in
response
:
u
.
error
(
'
Unexpected content:
\n
%s
'
%
respon
se
)
return
1
else
:
print
(
'
%sTest OK%s
'
%
(
GREEN
,
DEF
))
except
Exception
:
print
(
'
%sPackage mirror not working%s
'
%
(
RED
,
DEF
))
all_ok
=
False
u
.
success
(
'
Test OK.
'
)
except
Exception
as
e
:
u
.
error
(
'
Package mirror not working: %s
'
%
e
)
return
1
return
0
sys
.
exit
(
int
(
not
all_ok
))
if
__name__
==
'
__main__
'
:
code
=
main
()
sys
.
exit
(
code
)
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