Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hidra
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
steinbac
hidra
Commits
a0c5f5a3
Commit
a0c5f5a3
authored
9 years ago
by
Manuela Kuhn
Browse files
Options
Downloads
Patches
Plain Diff
First version of file removal at start up of receiverLiveViewer
parent
f66a1f66
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/receiverLiveViewer.py
+1
-0
1 addition, 0 deletions
src/receiverLiveViewer.py
src/shared/helperScript.py
+63
-0
63 additions, 0 deletions
src/shared/helperScript.py
with
64 additions
and
0 deletions
src/receiverLiveViewer.py
+
1
−
0
View file @
a0c5f5a3
...
...
@@ -76,6 +76,7 @@ def argumentParsing():
# check target directory for existance
helperScript
.
checkDirExistance
(
targetDir
)
# helperScript.checkDirEmpty(targetDir)
# check if logfile is writable
helperScript
.
checkLogFileWritable
(
logfilePath
,
logfileName
)
...
...
This diff is collapsed.
Click to expand it.
src/shared/helperScript.py
+
63
−
0
View file @
a0c5f5a3
...
...
@@ -79,6 +79,69 @@ class FakeSecHead(object):
else
:
return
self
.
fp
.
readline
()
# http://code.activestate.com/recipes/541096-prompt-the-user-for-confirmation/
def
confirm
(
prompt
=
None
,
resp
=
False
):
"""
prompts for yes or no response from the user. Returns True for yes and
False for no.
'
resp
'
should be set to the default value assumed by the caller when
user simply types ENTER.
>>>
confirm
(
prompt
=
'
Create Directory?
'
,
resp
=
True
)
Create
Directory
?
[
y
]
|
n
:
True
>>>
confirm
(
prompt
=
'
Create Directory?
'
,
resp
=
False
)
Create
Directory
?
[
n
]
|
y
:
False
>>>
confirm
(
prompt
=
'
Create Directory?
'
,
resp
=
False
)
Create
Directory
?
[
n
]
|
y
:
y
True
"""
if
prompt
is
None
:
prompt
=
'
Confirm
'
if
resp
:
prompt
=
'
%s [%s]|%s:
'
%
(
prompt
,
'
y
'
,
'
n
'
)
else
:
prompt
=
'
%s [%s]|%s:
'
%
(
prompt
,
'
n
'
,
'
y
'
)
while
True
:
try
:
ans
=
raw_input
(
prompt
)
except
KeyboardInterrupt
:
logging
.
error
(
"
Keyboard Interruption detected.
"
)
break
except
Exception
as
e
:
logging
.
error
(
"
Something went wrong with the confirmation.
"
)
logging
.
debug
(
"
Error was:
"
+
str
(
e
))
break
if
not
ans
:
return
resp
if
ans
not
in
[
'
y
'
,
'
Y
'
,
'
n
'
,
'
N
'
]:
logging
.
error
(
"
please enter y or n.
"
)
continue
if
ans
==
'
y
'
or
ans
==
'
Y
'
:
return
True
if
ans
==
'
n
'
or
ans
==
'
N
'
:
return
False
def
checkDirEmpty
(
dirPath
):
#check if directory is empty
if
os
.
listdir
(
dirPath
):
logging
.
info
(
"
Directory
'
%s
'
is not empty.
"
%
str
(
dirPath
))
if
confirm
(
prompt
=
"
Directory
"
+
str
(
dirPath
)
+
"
is not empty.
\n
Should its content be removed?
"
,
resp
=
True
):
for
element
in
os
.
listdir
(
dirPath
):
print
"
Removing elements
"
os
.
remove
(
element
)
def
checkSubDirExistance
(
dirPath
,
subDirs
):
"""
...
...
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