Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- from http import client
- from urllib.parse import _NetlocResultMixinBase
- from bas_remote import BasRemoteClient
- from bas_remote import Options
- asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
- class Bas():
- is_client_started = False
- def __init__(self) -> None:
- pass
- async def start_client(self):
- Bas.Bas_client = BasRemoteClient(options=Options(script_name='TestRemoteControl', login='login email', password='login password'))
- await Bas.Bas_client.start()
- if not Bas.is_client_started:
- Bas.is_client_started = True
- print('Client started!')
- else:
- print('Client is already started')
- async def run_function(self):
- if Bas.Bas_client:
- print('Starting Function')
- result = await Bas.Bas_client.run_function('CheckIp')
- return result
- else:
- print('Client not started!')
- async def close_client(self):
- await Bas.Bas_client.close()
- def get_client_status(self):
- return Bas.is_client_started
- if __name__ == '__main__':
- newClient = Bas()
- asyncio.run(newClient.start_client())
- print(newClient.get_client_status())
- asyncio.run(newClient.run_function())
- asyncio.run(newClient.run_function())
- asyncio.run(newClient.close_client())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement