def main(): logging.basicConfig(format='%(asctime)s %(levelname)-8s %(message)s', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S') logging.info(".started logging.") obj = SystemPerformanceAdaptor.SystemPerformanceAdaptor( 10) #Calling SystemPerformanceAdaptor Class Instance obj.start() #Starting Thread
def setUp(self): #instantiate the tasks self.systemCpuUtilTask = SystemCpuUtilTask.SystemCpuUtilTask() self.systemMemUtilTask = SystemMemUtilTask.SystemMemUtilTask() #instantiate the adaptor self.systemPerformanceAdaptor = SystemPerformanceAdaptor.SystemPerformanceAdaptor( )
''' Created on 02-Feb-2019 @author: Adhira ''' # Import libraries from time import sleep from labs.module01 import SystemPerformanceAdaptor # Instantiate the adaptor class sysPerfAdaptor = SystemPerformanceAdaptor.module01() # Set the daemon to True so as the thread stops at system shutdown sysPerfAdaptor.daemon = True # Indicate the starting of thread print("Starting system performance app daemon thread...") # Set the status of the adaptor to ON sysPerfAdaptor.EnableAdaptor = True # Start the adaptor sysPerfAdaptor.start() # Run the application continuously while (True): # Delay the command to access the information via app by 5 seconds sleep(5)
''' Created on 20-Jan-2020 @author: deepak NUID: 001316769 ''' from labs.module01 import SystemPerformanceAdaptor systemAdaptorObject = None #creating an instance of SystemPerformanceAdaptor systemAdaptorObject = SystemPerformanceAdaptor.SystemPerformanceAdaptor() #set true to the begin for threading systemAdaptorObject.setAdaptor(True) #start the thread systemAdaptorObject.start()
''' Created on Sep 15, 2018 @author: stannis ''' from time import sleep from labs.module01 import SystemPerformanceAdaptor sysPerfAdaptor = SystemPerformanceAdaptor.SystemPerformanceAdaptor() #SystemPerformanceAdaptor.SystemPerformanceAdaptor().daemon = True print("Starting system performance app daemon thread...") sysPerfAdaptor.enableAdaptor = True #SystemPerformanceAdaptor.SystemPerformanceAdaptor().daemon = True #SystemPerformanceAdaptor.SystemPerformanceAdaptor().start() sysPerfAdaptor.start() while (True): sleep(5) pass
''' Created on Jan 18, 2019 @author: Navin Raman ''' from time import sleep #importing sleep function from time library to set delay from labs.module01 import SystemPerformanceAdaptor #importing SystemperformaceAdaptor class for executing system performance value sys_Perf_Adaptor = SystemPerformanceAdaptor.SystemPerformanceAdaptor( ) #New thread to measure system performance values sys_Perf_Adaptor.daemon = True #setting this Thread as Daemon thread sys_Perf_Adaptor.en_Adaptor( ) #To start the thread to running, enabling the adaptor print("Starting system performance app daemon thread...\n") sys_Perf_Adaptor.start() #starting the Thread while (True): sleep( 7 ) #setting the running time for 7 seconds but since it is in while loop, this will automatically start the next 7 seconds and run until the loop is false pass
import time from labs.module01 import SystemPerformanceAdaptor thread1 = SystemPerformanceAdaptor.SystemPerformanceAdaptor(1, "Thread-1", 1) print("Starting system performance app daemon thread...") thread1.start() while (True): time.sleep(5) pass
def testSystemAdapterRun(self): self.assertEqual( True, SystemPerformanceAdaptor.run(), "SystemPerformanceAdapter run() not working. The method did not return True" )
''' Created on Jan 18, 2019 @author: GANESHRAM KANAKASABAI ''' from time import sleep from labs.module01 import SystemPerformanceAdaptor system_performance = SystemPerformanceAdaptor.SystemPerformanceAdaptor( "performance calculation", 10) system_performance.daemon = True #=============================================================================== # system_performance.daemon = True creates the daemon thread.When the program quits,any daemon threads are killed automatically. #=============================================================================== system_performance.enableThread() system_performance.start() #=============================================================================== # system_performance.start() starts the activity of the thread. #=============================================================================== while True: sleep(2) #=========================================================================== # The sleep() suspends the execution for the fixed number of seconds. #=========================================================================== pass
''' Created on Jan 20, 2020 @author: Siddhartha ''' import logging from time import sleep from labs.module01 import SystemPerformanceAdaptor logging.basicConfig(format='%(asctime)s:%(levelname)s:%(message)s', level=logging.DEBUG) logging.info("Starting system performance app ") i=0; while (i<15): SystemPerformanceAdaptor.run() #Running adaptor code in intervals i+=1 sleep(5)
''' Created on Jan 21, 2019 @author: suraj ''' from labs.module01 import SystemPerformanceAdaptor from time import sleep # Importing the necessary libraries and modules SysPerApp = SystemPerformanceAdaptor.SystemPerformanceAdaptor( 1, "System Performance Adaptor", 1) # Specifying the thread ID, Thread Name and number of threads to be created in SysPerApp object SysPerApp.daemon = True # SysPerApp will be created as daemon process print("Starting system performance reading application as background process") SysPerApp.enableAdaptor() # Changing the enable_Adaptor from False to True wait = 5 # Wait time of 5 seconds for CPU to give it a break SysPerApp.start( ) # The thread to collect system performance will be started here while (True): # infinite loop sleep(wait) # method for giving CPU a break of 5 seconds called pass # executes the current loop and the execution goes to second loop after this