Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
GEPARD
GEPARD
Commits
fa0c8b64
Commit
fa0c8b64
authored
Feb 13, 2020
by
Robert
Committed by
Robert Ohmacht
Feb 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
-logging of unsuccessful attempts of calling COM functions in WITecCOM (based on Josefs idea)
parent
900f1adb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
ramancom/WITecCOM.py
ramancom/WITecCOM.py
+13
-5
No files found.
ramancom/WITecCOM.py
View file @
fa0c8b64
...
@@ -60,27 +60,35 @@ class WITecCOM(RamanBase):
...
@@ -60,27 +60,35 @@ class WITecCOM(RamanBase):
"""
"""
def
wrapper
(
*
args
,
**
kwargs
):
def
wrapper
(
*
args
,
**
kwargs
):
def
tryFunctionThreeTimes
():
def
tryFunctionThreeTimes
(
c
):
success
=
False
success
=
False
for
_
in
range
(
3
):
for
_
in
range
(
3
):
result
=
None
result
=
None
c
+=
1
try
:
try
:
result
=
comCallFunction
(
*
args
,
**
kwargs
)
result
=
comCallFunction
(
*
args
,
**
kwargs
)
success
=
True
success
=
True
break
break
except
pythoncom
.
com_error
:
except
pythoncom
.
com_error
:
comObj
.
logger
.
warning
(
f
'Unsuccessful
{
c
}
. attempt for COM call of function
{
comCallFunction
.
__name__
}
\n
{
pythoncom
.
com_error
}
'
)
sleep
(
1.
)
sleep
(
1.
)
return
success
,
result
return
success
,
result
,
c
c
=
0
comObj
=
args
[
0
]
#self is always passed as first argument
comObj
=
args
[
0
]
#self is always passed as first argument
functionSucceeded
,
result
=
tryFunctionThreeTimes
()
functionSucceeded
,
result
,
c
=
tryFunctionThreeTimes
(
c
)
if
not
functionSucceeded
:
if
not
functionSucceeded
:
comObj
.
logger
.
warning
(
f
'Reconnecting for function
{
comCallFunction
.
__name__
}
'
)
comObj
.
disconnect
()
comObj
.
disconnect
()
sleep
(
1.
)
sleep
(
1.
)
comObj
.
connect
()
comObj
.
connect
()
functionSucceeded
,
result
=
tryFunctionThreeTimes
()
functionSucceeded
,
result
,
c
=
tryFunctionThreeTimes
(
c
)
if
not
functionSucceeded
:
if
not
functionSucceeded
:
showErrorMessageAsWidget
(
f
'Com error on function
{
comCallFunction
.
__name__
}
'
)
comObj
.
logger
.
warning
(
f
'COM error: function
{
comCallFunction
.
__name__
}
could not be executed'
)
showErrorMessageAsWidget
(
f
'COM error on function
{
comCallFunction
.
__name__
}
'
)
raise
pythoncom
.
com_error
raise
pythoncom
.
com_error
return
result
return
result
return
wrapper
return
wrapper
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment