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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
4cd2d756
Commit
4cd2d756
authored
7 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
add colors
parent
1b506a64
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_backup.py
+9
-4
9 additions, 4 deletions
tests/test_backup.py
with
9 additions
and
4 deletions
tests/test_backup.py
+
9
−
4
View file @
4cd2d756
...
@@ -17,6 +17,11 @@ GREEN = '\033[92m'
...
@@ -17,6 +17,11 @@ GREEN = '\033[92m'
RED
=
'
\033
[91m
'
RED
=
'
\033
[91m
'
DEF
=
'
\033
[0m
'
DEF
=
'
\033
[0m
'
def
print_red
(
string
):
print
(
RED
+
string
+
DEF
)
def
print_green
(
string
):
print
(
GREEN
+
string
+
DEF
)
def
test_ssh
(
ip
):
def
test_ssh
(
ip
):
cmd
=
'
ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no %s ls /tmp
'
%
ip
cmd
=
'
ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no %s ls /tmp
'
%
ip
...
@@ -78,15 +83,15 @@ def check_local_backup(path):
...
@@ -78,15 +83,15 @@ def check_local_backup(path):
now
=
datetime
.
now
()
now
=
datetime
.
now
()
diff_seconds
=
(
now
-
d
).
total_seconds
()
diff_seconds
=
(
now
-
d
).
total_seconds
()
if
diff_seconds
>
48
*
3600
:
if
diff_seconds
>
48
*
3600
:
print
(
'
Backup %s is older than 48h (%ih)
'
%
(
backup_folder
,
diff_seconds
/
3600
))
print
_red
(
'
Backup %s is older than 48h (%ih)
'
%
(
backup_folder
,
diff_seconds
/
3600
))
all_ok
=
False
all_ok
=
False
else
:
else
:
print
(
'
Backup %s is fine
'
%
backup_folder
)
print
_green
(
'
Backup %s is fine
'
%
backup_folder
)
elif
os
.
path
.
exists
(
os
.
path
.
join
(
backup_folder
,
'
backup.inprogress
'
)):
elif
os
.
path
.
exists
(
os
.
path
.
join
(
backup_folder
,
'
backup.inprogress
'
)):
print
(
'
Backup %s still running
'
%
backup_folder
)
print
_red
(
'
Backup %s still running
'
%
backup_folder
)
all_ok
=
False
all_ok
=
False
else
:
else
:
print
(
'
Backup %s is not working
'
%
latest
)
print
_red
(
'
Backup %s is not working
'
%
latest
)
all_ok
=
False
all_ok
=
False
return
all_ok
return
all_ok
...
...
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