Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pavel Valach
Warden
Commits
45657b64
Commit
45657b64
authored
10 years ago
by
Tomáš Plesník
Browse files
Options
Downloads
Patches
Plain Diff
pridana funkce trim(); otrimovani chybovych hlasek
parent
508e03b3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/warden-client/lib/WardenClientCommon.pm
+23
-11
23 additions, 11 deletions
src/warden-client/lib/WardenClientCommon.pm
with
23 additions
and
11 deletions
src/warden-client/lib/WardenClientCommon.pm
+
23
−
11
View file @
45657b64
...
@@ -19,6 +19,18 @@ use Carp;
...
@@ -19,6 +19,18 @@ use Carp;
our
$VERSION
=
"
2.2
";
our
$VERSION
=
"
2.2
";
#-------------------------------------------------------------------------------
# trim - remove whitespace from the start and end of the string
#-------------------------------------------------------------------------------
sub
trim
{
my
$string
=
shift
;
$string
=~
s/^\s+//
;
$string
=~
s/\s+$//
;
return
$string
;
}
# End of trim
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# errMsg - prints error msg and returns undef or prints warning and returns 1
# errMsg - prints error msg and returns undef or prints warning and returns 1
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
...
@@ -68,11 +80,11 @@ sub c2s
...
@@ -68,11 +80,11 @@ sub c2s
# create SOAP::Transport::HTTP:Client object
# create SOAP::Transport::HTTP:Client object
eval
{
eval
{
$client
=
SOAP::Transport::HTTP::
Client
->
new
();
$client
=
SOAP::Transport::HTTP::
Client
->
new
();
}
or
return
errMsg
("
Error in function 'c2s()' when creating SOAP::Transport::HTTP::Client object:
"
.
$@
);
}
or
return
errMsg
("
Error in function 'c2s()' when creating SOAP::Transport::HTTP::Client object:
"
.
trim
(
$@
)
)
;
# setting of connection timeout
# setting of connection timeout
eval
{
$client
->
timeout
(
$
WardenClientCommon::
CONNECTION_TIMEOUT
);}
eval
{
$client
->
timeout
(
$
WardenClientCommon::
CONNECTION_TIMEOUT
);}
or
return
errMsg
("
Error in function 'c2s()' when setting connection timeout:
"
.
$@
);
or
return
errMsg
("
Error in function 'c2s()' when setting connection timeout:
"
.
trim
(
$@
)
)
;
# setting of SSL options
# setting of SSL options
eval
{
eval
{
...
@@ -83,24 +95,24 @@ sub c2s
...
@@ -83,24 +95,24 @@ sub c2s
SSL_cert_file
=>
$
WardenClientCommon::
SSL_CERT
,
SSL_cert_file
=>
$
WardenClientCommon::
SSL_CERT
,
SSL_ca_file
=>
$
WardenClientCommon::
SSL_CA_CERT
);
SSL_ca_file
=>
$
WardenClientCommon::
SSL_CA_CERT
);
return
1
;
# fix of eval triggering 'or' statement
return
1
;
# fix of eval triggering 'or' statement
}
or
return
errMsg
("
Ërror in function 'c2s()' when setting SSL options:
"
.
$@
);
}
or
return
errMsg
("
Ërror in function 'c2s()' when setting SSL options:
"
.
trim
(
$@
)
)
;
# setting of service URI
# setting of service URI
my
$soap
;
my
$soap
;
eval
{
eval
{
$soap
=
SOAP::
Lite
->
uri
(
$service
)
->
proxy
(
$
WardenClientCommon::
URI
);
$soap
=
SOAP::
Lite
->
uri
(
$service
)
->
proxy
(
$
WardenClientCommon::
URI
);
}
or
return
errMsg
("
Error in function 'c2s()' when setting service URI:
"
.
$@
);
}
or
return
errMsg
("
Error in function 'c2s()' when setting service URI:
"
.
trim
(
$@
)
)
;
# serialize SOAP envelope or SOAP envelope and data object
# serialize SOAP envelope or SOAP envelope and data object
my
$envelope
;
my
$envelope
;
if
(
!
defined
$data
)
{
if
(
!
defined
$data
)
{
eval
{
eval
{
$envelope
=
$soap
->
serializer
->
envelope
(
method
=>
$method
);
$envelope
=
$soap
->
serializer
->
envelope
(
method
=>
$method
);
}
or
return
errMsg
("
Error in function 'c2s()' when serializing envelope:
"
.
$@
);
}
or
return
errMsg
("
Error in function 'c2s()' when serializing envelope:
"
.
trim
(
$@
)
)
;
}
else
{
}
else
{
eval
{
eval
{
$envelope
=
$soap
->
serializer
->
envelope
(
method
=>
$method
,
$data
);
$envelope
=
$soap
->
serializer
->
envelope
(
method
=>
$method
,
$data
);
}
or
return
errMsg
("
Error in function 'c2s()' when serializing envelope and data:
"
.
$@
);
}
or
return
errMsg
("
Error in function 'c2s()' when serializing envelope and data:
"
.
trim
(
$@
)
)
;
}
}
# setting of complete HTTPs URI and send serialized SOAP envelope and data
# setting of complete HTTPs URI and send serialized SOAP envelope and data
...
@@ -108,7 +120,7 @@ sub c2s
...
@@ -108,7 +120,7 @@ sub c2s
my
$result
;
my
$result
;
eval
{
eval
{
$result
=
$client
->
send_receive
(
envelope
=>
$envelope
,
endpoint
=>
$server_uri
);
$result
=
$client
->
send_receive
(
envelope
=>
$envelope
,
endpoint
=>
$server_uri
);
}
or
return
errMsg
("
Error in function 'c2s()' when sending SOAP envelope and data:
"
.
$@
);
}
or
return
errMsg
("
Error in function 'c2s()' when sending SOAP envelope and data:
"
.
trim
(
$@
)
)
;
# check server response
# check server response
if
(
!
defined
$result
)
{
if
(
!
defined
$result
)
{
...
@@ -118,9 +130,9 @@ sub c2s
...
@@ -118,9 +130,9 @@ sub c2s
my
$response
;
my
$response
;
eval
{
eval
{
$response
=
$soap
->
deserializer
->
deserialize
(
$result
);
$response
=
$soap
->
deserializer
->
deserialize
(
$result
);
}
or
return
errMsg
("
Error in deserialization of server response:
"
.
$@
.
"
\n
Received response:
"
.
$result
);
}
or
return
errMsg
("
Error in deserialization of server response:
"
.
trim
(
$@
)
.
"
\n
Received response:
"
.
trim
(
$result
)
)
;
# check SOAP fault status
# check SOAP fault status
$response
->
fault
?
return
errMsg
("
Server sent error message:
"
.
$response
->
faultstring
)
:
return
$response
;
$response
->
fault
?
return
errMsg
("
Server sent error message:
"
.
trim
(
$response
->
faultstring
)
)
:
return
$response
;
}
}
}
}
...
@@ -144,8 +156,8 @@ sub loadConf
...
@@ -144,8 +156,8 @@ sub loadConf
our
$SYSLOG_FACILITY
=
undef
;
our
$SYSLOG_FACILITY
=
undef
;
unless
(
do
$conf_file
)
{
unless
(
do
$conf_file
)
{
die
("
Errors in config file '
$conf_file
': $@
"
)
if
$@
;
die
("
Errors in config file '
$conf_file
':
"
.
trim
(
$@
)
)
if
$@
;
die
("
Can't read config file '
$conf_file
': $!
"
)
unless
defined
$_
;
die
("
Can't read config file '
$conf_file
':
"
.
trim
(
$!
)
)
unless
defined
$_
;
# if $_ defined, it's retvalue of last statement of conf, for which we don't care
# if $_ defined, it's retvalue of last statement of conf, for which we don't care
}
}
}
# End of loadConf
}
# End of loadConf
...
...
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