Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
647166f2
authored
Aug 12, 2013
by
user
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing decorator to use decorator module properly
parent
ef7ca318
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
21 deletions
+19
-21
vmdriver.py
+19
-21
No files found.
vmdriver.py
View file @
647166f2
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
libvirt
import
libvirt
import
logging
import
logging
import
os
import
os
import
decorator
from
decorator
import
decorator
connection
=
None
connection
=
None
...
@@ -18,28 +18,26 @@ state_dict = {0: 'NOSTATE',
...
@@ -18,28 +18,26 @@ state_dict = {0: 'NOSTATE',
}
}
@decorator
.decorator
@decorator
def
req_connection
(
original_function
):
def
req_connection
(
original_function
,
*
args
,
**
kw
):
'''Connection checking decorator for libvirt.
'''Connection checking decorator for libvirt.
'''
'''
def
new_function
(
*
args
,
**
kwargs
):
logging
.
debug
(
"Decorator running"
)
logging
.
debug
(
"Decorator running"
)
global
connection
global
connection
if
connection
is
None
:
if
connection
is
None
:
connect
()
connect
()
try
:
try
:
logging
.
debug
(
"Decorator calling original function"
)
logging
.
debug
(
"Decorator calling original function"
)
return_value
=
original_function
(
*
args
,
**
kw
)
return_value
=
original_function
(
*
args
,
**
kwargs
)
finally
:
finally
:
logging
.
debug
(
"Finally part of decorator"
)
logging
.
debug
(
"Finally part of decorator"
)
disconnect
()
disconnect
()
return
return_value
return
return_value
else
:
else
:
logging
.
debug
(
"Decorator calling original
\
logging
.
debug
(
"Decorator calling original
\
function with active connection"
)
function with active connection"
)
return_value
=
original_function
(
*
args
,
**
kw
)
return_value
=
original_function
(
*
args
,
**
kwargs
)
return
return_value
return
return_value
return
new_function
def
connect
(
connection_string
=
'qemu:///system'
):
def
connect
(
connection_string
=
'qemu:///system'
):
...
...
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