feat: adding ruff linting support
This commit is contained in:
18
mta_test.py
18
mta_test.py
@@ -2,7 +2,7 @@ import os
|
||||
from dotenv import load_dotenv
|
||||
from mta_manager import MTA
|
||||
import threading
|
||||
import time
|
||||
|
||||
from time import sleep
|
||||
from pprint import pprint
|
||||
|
||||
@@ -15,13 +15,15 @@ mtaController = MTA(
|
||||
["127S", "127N", "A27N", "A27S"]
|
||||
)
|
||||
|
||||
|
||||
async def mta_callback(trains):
|
||||
print("We are inside of the call back now")
|
||||
print(len(trains))
|
||||
pprint([str(route) for route in trains])
|
||||
pprint(mtaController.get_time_arriving_at_stations(trains))
|
||||
|
||||
class threadWrapper(threading.Thread):
|
||||
|
||||
class Threadwrapper(threading.Thread):
|
||||
def __init__(self, run):
|
||||
threading.Thread.__init__(self)
|
||||
self.run = run
|
||||
@@ -29,21 +31,23 @@ class threadWrapper(threading.Thread):
|
||||
def run(self):
|
||||
self.run()
|
||||
|
||||
|
||||
def start_mta():
|
||||
mtaController.add_callback(mta_callback)
|
||||
mtaController.start_updates()
|
||||
|
||||
|
||||
def stop_mta():
|
||||
sleep(10)
|
||||
mtaController.stop_updates()
|
||||
|
||||
|
||||
threadLock = threading.Lock()
|
||||
threads = []
|
||||
|
||||
# Create new threads
|
||||
thread1 = threadWrapper(start_mta)
|
||||
thread2 = threadWrapper(stop_mta)
|
||||
|
||||
thread1 = Threadwrapper(start_mta)
|
||||
thread2 = Threadwrapper(stop_mta)
|
||||
|
||||
thread1.start()
|
||||
thread2.start()
|
||||
@@ -54,5 +58,5 @@ threads.append(thread2)
|
||||
|
||||
# Wait for all threads to complete
|
||||
for t in threads:
|
||||
t.join()
|
||||
print ("Exiting Main Thread")
|
||||
t.join()
|
||||
print("Exiting Main Thread")
|
||||
|
||||
Reference in New Issue
Block a user