Only import virtual functions when needed.

ogClient may runs on an OS that do not have all the dependencies needed
to use virtual functions.

This commit change the behaviour to only import virtual functions when
the ogClient has to work with Virtual Machines. This way ogClient works
on environments which do not need virtual functions.
more_events
Javier Sánchez Parra 2020-05-19 10:24:02 +02:00
parent 2ab5db74fe
commit 6502180fc8
1 changed files with 2 additions and 1 deletions

View File

@ -19,7 +19,6 @@ import signal
from src.restRequest import *
from src.linux.ogOperations import OgLinuxOperations
from src.virtual.ogOperations import OgVirtualOperations, OgVM
class ThreadState(Enum):
IDLE = 0
@ -253,6 +252,8 @@ class ogRest():
if self.mode == 'linux':
self.operations = OgLinuxOperations(self.CONFIG)
elif self.mode == 'virtual':
from src.virtual.ogOperations import (OgVM,
OgVirtualOperations)
self.operations = OgVirtualOperations()
threading.Thread(target=ogThread.check_vm_state_loop,
args=(self,)).start()