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
b7fad39c
Commit
b7fad39c
authored
9 years ago
by
Manuela Kuhn
Browse files
Options
Downloads
Patches
Plain Diff
argument parsing in DirectoryWatcher only done if main
parent
2aca1b42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sender/DirectoryWatcher.py
+39
-45
39 additions, 45 deletions
src/sender/DirectoryWatcher.py
with
39 additions
and
45 deletions
src/sender/DirectoryWatcher.py
+
39
−
45
View file @
b7fad39c
...
...
@@ -48,28 +48,21 @@ class DirectoryWatcher():
self
.
fileEventPort
=
fileEventPort
self
.
monitoredEventType
=
monitoredEventType
or
None
self
.
log
.
info
(
"
Monitored event type is:
"
+
str
(
monitoredEventType
))
self
.
monitoredDefaultSubdirs
=
monitoredDefaultSubdirs
or
None
self
.
monitoredSuffixes
=
monitoredSuffixes
or
None
self
.
log
.
info
(
"
Monitored suffixes are:
"
+
str
(
monitoredSuffixes
))
monitoredDirs
=
[
self
.
watchDir
]
self
.
eventDetector
=
EventDetector
(
monitoredDirs
,
self
.
monitoredEventType
,
self
.
monitoredDefaultSubdirs
,
self
.
monitoredSuffixes
)
# assert isinstance(self.zmqContext, zmq.sugar.context.Context)
self
.
createSockets
()
try
:
self
.
process
()
except
KeyboardInterrupt
:
self
.
log
.
debug
(
"
Keyboard interruption detected. Shuting down
"
)
# finally:
# self.eventDetector.stop()
# self.stop()
def
getLogger
(
self
):
...
...
@@ -149,60 +142,61 @@ class DirectoryWatcher():
def
argumentParsing
()
:
if
__name__
==
'
__main__
'
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
--watchDir
"
,
type
=
str
,
help
=
"
directory you want to monitor for changes
"
)
parser
.
add_argument
(
"
--staticNotification
"
,
help
=
"
disables new file-events. just sends a list of currently available files within the defined
'
watchDir
'
.
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
--logfilePath
"
,
type
=
str
,
help
=
"
path where logfile will be created
"
,
default
=
"
/tmp/log/
"
)
parser
.
add_argument
(
"
--logfileName
"
,
type
=
str
,
help
=
"
filename used for logging
"
,
default
=
"
watchDir.log
"
)
parser
.
add_argument
(
"
--fileEventIp
"
,
type
=
str
,
help
=
"
zqm endpoint (IP-address) to send file events to
"
,
default
=
"
127.0.0.1
"
)
parser
.
add_argument
(
"
--fileEventPort
"
,
type
=
str
,
help
=
"
zqm endpoint (port) to send file events to
"
,
default
=
"
6060
"
)
parser
.
add_argument
(
"
--verbose
"
,
help
=
"
more verbose output
"
,
action
=
"
store_true
"
)
def
argumentParsing
():
arguments
=
parser
.
parse_args
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
--watchDir
"
,
type
=
str
,
help
=
"
directory you want to monitor for changes
"
)
parser
.
add_argument
(
"
--staticNotification
"
,
help
=
"
disables new file-events. just sends a list of currently available files within the defined
'
watchDir
'
.
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
--logfilePath
"
,
type
=
str
,
help
=
"
path where logfile will be created
"
,
default
=
"
/tmp/log/
"
)
parser
.
add_argument
(
"
--logfileName
"
,
type
=
str
,
help
=
"
filename used for logging
"
,
default
=
"
watchDir.log
"
)
parser
.
add_argument
(
"
--fileEventIp
"
,
type
=
str
,
help
=
"
zqm endpoint (IP-address) to send file events to
"
,
default
=
"
127.0.0.1
"
)
parser
.
add_argument
(
"
--fileEventPort
"
,
type
=
str
,
help
=
"
zqm endpoint (port) to send file events to
"
,
default
=
"
6060
"
)
parser
.
add_argument
(
"
--verbose
"
,
help
=
"
more verbose output
"
,
action
=
"
store_true
"
)
# TODO: check watchDir-directory for existance
arguments
=
parser
.
parse_args
()
watchDir
=
str
(
arguments
.
watchDir
)
assert
isinstance
(
type
(
watchDir
),
type
(
str
))
# TODO: check watchDir-directory for existance
#exit with error if no watchDir path was provided
if
(
watchDir
==
None
)
or
(
watchDir
==
""
)
or
(
watchDir
==
"
None
"
):
print
"""
You need to set the following option:
--watchDir {DIRECTORY}
"""
sys
.
exit
(
1
)
watchDir
=
str
(
arguments
.
watchDir
)
assert
isinstance
(
type
(
watchDir
),
type
(
str
))
#exit with error if no watchDir path was provided
if
watchDir
in
[
None
,
""
,
"
None
"
]:
print
"""
You need to set the following option:
--watchDir {DIRECTORY}
"""
sys
.
exit
(
1
)
#abort if watchDir does not exist
helperScript
.
checkDirExistance
(
watchDir
)
#abort if watchDir does not exist
helperScript
.
checkDirExistance
(
watchDir
)
#error if logfile cannot be written
try
:
fullPath
=
os
.
path
.
join
(
arguments
.
logfilePath
,
arguments
.
logfileName
)
logFile
=
open
(
fullPath
,
"
a
"
)
except
:
print
"
Unable to create the logfile
"""
+ str(fullPath)
print
"""
Please specify a new target by setting the following arguments:
--logfileName
--logfilePath
"""
sys.exit(1)
#check logfile-path for existance
helperScript.checkDirExistance(arguments.logfilePath)
#error if logfile cannot be written
try
:
fullPath
=
os
.
path
.
join
(
arguments
.
logfilePath
,
arguments
.
logfileName
)
logFile
=
open
(
fullPath
,
"
a
"
)
except
:
print
"
Unable to create the logfile
"""
+ str(fullPath)
print
"""
Please specify a new target by setting the following arguments:
--logfileName
--logfilePath
"""
sys.exit(1)
#check logfile-path for existance
helperScript.checkDirExistance(arguments.logfilePath)
return arguments
return arguments
if __name__ ==
'
__main__
'
:
BASE_PATH = os.path.dirname ( os.path.dirname ( os.path.dirname ( os.path.realpath ( __file__ ) )))
SRC_PATH = BASE_PATH + os.sep +
"
src
"
...
...
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