Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pre_processor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
IA2
pre_processor
Commits
de5c9932
Commit
de5c9932
authored
11 years ago
by
Marco De Marco
Browse files
Options
Downloads
Patches
Plain Diff
Directory and file check added
parent
fd8da9e0
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/PreProcessor.cpp
+90
-5
90 additions, 5 deletions
src/PreProcessor.cpp
src/PreProcessor.h
+6
-0
6 additions, 0 deletions
src/PreProcessor.h
with
96 additions
and
5 deletions
src/PreProcessor.cpp
+
90
−
5
View file @
de5c9932
...
...
@@ -298,12 +298,18 @@ void PreProcessor::get_device_property()
if
(
watchPath
.
empty
())
throw
(
invalid_argument
(
"WatchPath property is empty or not defined"
));
checkIfDirectoryExists
(
watchPath
);
if
(
destPath
.
empty
())
throw
(
invalid_argument
(
"DestPath property is empty or not defined"
));
checkIfDirectoryExists
(
destPath
);
if
(
scriptPath
.
empty
())
throw
(
invalid_argument
(
"ScriptPath property is empty or not defined"
));
checkIfFileExists
(
scriptPath
);
if
(
eventList
.
empty
())
throw
(
invalid_argument
(
"EventList property is empty or not defined"
));
...
...
@@ -316,7 +322,6 @@ void PreProcessor::get_device_property()
throw
(
invalid_argument
(
event_list_error
.
str
()));
}
//Create i-notify mask from event list property
const
uint32_t
inotifyMask
=
create_inotify_mask
(
eventList
);
if
(
sleepTime
<
MIN_SLEEP_TIME
||
sleepTime
>
MAX_SLEEP_TIME
)
...
...
@@ -411,7 +416,23 @@ void PreProcessor::on()
DEBUG_STREAM
<<
"PreProcessor::On() - "
<<
device_name
<<
endl
;
/*----- PROTECTED REGION ID(PreProcessor::on) ENABLED START -----*/
// Add your own code
try
{
if
(
m_eventThread_sp
)
m_eventThread_sp
->
start
();
}
catch
(
std
::
exception
&
ex
)
{
set_state
(
Tango
::
ALARM
);
std
::
stringstream
error_stream
;
error_stream
<<
"PreProcessor::On() "
<<
ex
.
what
()
<<
std
::
endl
;
set_status
(
error_stream
.
str
());
}
catch
(...)
{
set_state
(
Tango
::
ALARM
);
set_status
(
"PreProcessor::On() unknown error"
);
}
/*----- PROTECTED REGION END -----*/
// PreProcessor::on
}
...
...
@@ -427,7 +448,23 @@ void PreProcessor::off()
DEBUG_STREAM
<<
"PreProcessor::Off() - "
<<
device_name
<<
endl
;
/*----- PROTECTED REGION ID(PreProcessor::off) ENABLED START -----*/
// Add your own code
try
{
if
(
m_eventThread_sp
)
m_eventThread_sp
->
stop
();
}
catch
(
std
::
exception
&
ex
)
{
set_state
(
Tango
::
ALARM
);
std
::
stringstream
error_stream
;
error_stream
<<
"PreProcessor::Off() "
<<
ex
.
what
()
<<
std
::
endl
;
set_status
(
error_stream
.
str
());
}
catch
(...)
{
set_state
(
Tango
::
ALARM
);
set_status
(
"PreProcessor::Off() unknown error"
);
}
/*----- PROTECTED REGION END -----*/
// PreProcessor::off
}
...
...
@@ -452,7 +489,7 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event
for
(
it
=
event_list
.
begin
();
it
!=
event_list
.
end
();
it
++
)
{
std
::
stringstream
event_stream
;
event_stream
<<
"
FitsImporte
r::create_inotify_mask() "
;
event_stream
<<
"
PreProcesso
r::create_inotify_mask() "
;
if
(
it
->
compare
(
"IN_ACCESS"
)
==
0
)
{
...
...
@@ -521,7 +558,7 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event
iNotifyMask
+=
IN_ALL_EVENTS
;
}
else
throw
std
::
invalid_argument
(
"
FitsImporte
r::create_inotify_mask() "
throw
std
::
invalid_argument
(
"
PreProcesso
r::create_inotify_mask() "
"string
\"
"
+
*
it
+
"
\"
is invalid inotify event"
);
INFO_STREAM
<<
event_stream
.
str
()
<<
endl
;
...
...
@@ -530,5 +567,53 @@ uint32_t PreProcessor::create_inotify_mask(const std::vector<std::string>& event
return
iNotifyMask
;
}
//==============================================================================
// PreProcessor::checkIfFileExists()
//==============================================================================
void
PreProcessor
::
checkIfFileExists
(
std
::
string
fileName
)
throw
(
std
::
invalid_argument
)
{
DEBUG_STREAM
<<
"PreProcessor::checkIfFileExists() - "
<<
device_name
<<
endl
;
boost
::
filesystem
::
path
path
(
fileName
);
if
(
!
boost
::
filesystem
::
exists
(
path
))
{
std
::
stringstream
errorStream
;
errorStream
<<
"File "
<<
fileName
<<
" not exists"
<<
std
::
endl
;
throw
std
::
invalid_argument
(
errorStream
.
str
());
}
INFO_STREAM
<<
"PreProcessor::checkIfFileExists() "
<<
fileName
<<
endl
;
}
//==============================================================================
// PreProcessor::checkIfDirectoryExists()
//==============================================================================
void
PreProcessor
::
checkIfDirectoryExists
(
std
::
string
directoryName
)
throw
(
std
::
invalid_argument
)
{
DEBUG_STREAM
<<
"PreProcessor::checkIfFileExists() - "
<<
device_name
<<
endl
;
boost
::
filesystem
::
path
path
(
directoryName
);
if
(
!
boost
::
filesystem
::
exists
(
path
))
{
std
::
stringstream
errorStream
;
errorStream
<<
"Directory "
<<
directoryName
<<
" not exists"
<<
std
::
endl
;
throw
std
::
invalid_argument
(
errorStream
.
str
());
}
if
(
!
boost
::
filesystem
::
is_directory
(
path
))
{
std
::
stringstream
errorStream
;
errorStream
<<
directoryName
<<
" is not a directory"
<<
std
::
endl
;
throw
std
::
invalid_argument
(
errorStream
.
str
());
}
INFO_STREAM
<<
"PreProcessor::checkIfDirectoryExists() "
<<
directoryName
<<
endl
;
}
/*----- PROTECTED REGION END -----*/
// PreProcessor::namespace_ending
}
// namespace
This diff is collapsed.
Click to expand it.
src/PreProcessor.h
+
6
−
0
View file @
de5c9932
...
...
@@ -203,6 +203,12 @@ private:
uint32_t
create_inotify_mask
(
const
std
::
vector
<
std
::
string
>&
)
throw
(
std
::
invalid_argument
);
virtual
void
checkIfFileExists
(
std
::
string
)
throw
(
std
::
invalid_argument
);
virtual
void
checkIfDirectoryExists
(
std
::
string
)
throw
(
std
::
invalid_argument
);
/*----- PROTECTED REGION END -----*/
// PreProcessor::Additional Method prototypes
};
...
...
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