Advertisement
Guest User

Untitled

a guest
May 29th, 2022
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. import asyncio
  2. from http import client
  3. from urllib.parse import _NetlocResultMixinBase
  4.  
  5. from bas_remote import BasRemoteClient
  6. from bas_remote import Options
  7.  
  8. asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
  9.  
  10.  
  11. class Bas():
  12.     is_client_started = False
  13.  
  14.  
  15.     def __init__(self) -> None:
  16.         pass
  17.  
  18.  
  19.     async def start_client(self):
  20.         Bas.Bas_client = BasRemoteClient(options=Options(script_name='TestRemoteControl', login='login email', password='login password'))
  21.         await Bas.Bas_client.start()
  22.  
  23.         if not Bas.is_client_started:
  24.            
  25.             Bas.is_client_started = True
  26.             print('Client started!')
  27.         else:
  28.             print('Client is already started')
  29.  
  30.  
  31.     async def run_function(self):
  32.         if Bas.Bas_client:
  33.             print('Starting Function')
  34.             result = await Bas.Bas_client.run_function('CheckIp')
  35.             return result
  36.         else:
  37.             print('Client not started!')
  38.  
  39.  
  40.     async def close_client(self):
  41.         await Bas.Bas_client.close()
  42.  
  43.  
  44.    
  45.     def get_client_status(self):
  46.         return Bas.is_client_started
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57. if __name__ == '__main__':
  58.     newClient = Bas()
  59.     asyncio.run(newClient.start_client())
  60.     print(newClient.get_client_status())
  61.     asyncio.run(newClient.run_function())
  62.     asyncio.run(newClient.run_function())
  63.     asyncio.run(newClient.close_client())
  64.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement