Skip to content

Commit c241b53

Browse files
Juliana MashonJuliana Mashon
Juliana Mashon
authored and
Juliana Mashon
committed
Token handling still not fixed but better
1 parent b5e59db commit c241b53

13 files changed

+144
-119
lines changed

functions/authentication.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from .imports import *
1313

1414
class Authentication():
15-
def __init__(self):
16-
self.token = None
15+
def __init__(self, token):
16+
self.token = token
1717
self.error = None
1818

1919
def request_handling(self, response):

functions/basic_commands.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from .broker import BrokerConnect
1414

1515
class BasicCommands():
16-
def __init__(self):
17-
self.token = None
18-
self.broker = BrokerConnect()
16+
def __init__(self, token):
17+
self.token = token
18+
self.broker = BrokerConnect(token)
1919

2020
def wait(self, duration):
2121
# Tell bot to wait for some time

functions/broker.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from .imports import *
1515

1616
class BrokerConnect():
17-
def __init__(self):
18-
self.token = None
17+
def __init__(self, token):
18+
self.token = token
1919
self.client = None
2020

2121
self.last_message = None

functions/camera.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from .broker import BrokerConnect
1212

1313
class Camera():
14-
def __init__(self):
15-
self.token = None
16-
self.broker = BrokerConnect()
14+
def __init__(self, token):
15+
self.token = token
16+
self.broker = BrokerConnect(token)
1717

1818
def calibrate_camera(self):
1919
# Execute calibrate camera script

functions/information.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@
1818
from .authentication import Authentication
1919

2020
class Information():
21-
def __init__(self):
22-
self.token = None
23-
24-
self.broker = BrokerConnect()
25-
self.auth = Authentication()
21+
def __init__(self, token):
22+
self.token = token
23+
self.broker = BrokerConnect(token)
24+
self.auth = Authentication(token)
2625

2726
def get_info(self, endpoint, id=None):
2827
# Get endpoint info

functions/jobs.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
from .resources import Resources
1515

1616
class JobHandling():
17-
def __init__(self):
18-
self.token = None
19-
20-
self.broker = BrokerConnect()
21-
self.info = Information()
22-
self.resource = Resources()
17+
def __init__(self, token):
18+
self.token = token
19+
self.broker = BrokerConnect(token)
20+
self.info = Information(token)
21+
self.resource = Resources(token)
2322

2423
def get_job(self, job_str):
2524
# Get all or single job by name

functions/messages.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
from .authentication import Authentication
1414

1515
class MessageHandling():
16-
def __init__(self):
17-
self.token = None
18-
19-
self.broker = BrokerConnect()
20-
self.auth = Authentication()
16+
def __init__(self, token):
17+
self.token = token
18+
self.broker = BrokerConnect(token)
19+
self.auth = Authentication(token)
2120

2221
def log(self, message_str, type=None, channel=None):
2322
# Send new log message via API

functions/movements.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
from .information import Information
1616

1717
class MovementControls():
18-
def __init__(self):
19-
self.token = None
20-
21-
self.broker = BrokerConnect()
22-
self.info = Information()
18+
def __init__(self, token):
19+
self.token = token
20+
self.broker = BrokerConnect(token)
21+
self.info = Information(token)
2322

2423
def move(self, x, y, z):
2524
def axis_overwrite(axis, value):

functions/peripherals.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
from .information import Information
1515

1616
class Peripherals():
17-
def __init__(self):
18-
self.token = None
19-
20-
self.broker = BrokerConnect()
21-
self.info = Information()
17+
def __init__(self, token):
18+
self.token = token
19+
self.broker = BrokerConnect(token)
20+
self.info = Information(token)
2221

2322
def control_servo(self, pin, angle):
2423
# Change servo values

functions/resources.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
from .information import Information
1818

1919
class Resources():
20-
def __init__(self):
21-
self.token = None
22-
23-
self.broker = BrokerConnect()
24-
self.info = Information()
20+
def __init__(self, token):
21+
self.token = token
22+
self.broker = BrokerConnect(token)
23+
self.info = Information(token)
2524

2625
def mark_coord(self, x, y, z, property, mark_as): # TODO: Fix "label" and TODO: rename mark_point()
2726
# Mark xyz coordinate

functions/tools.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
from .resources import Resources
1515

1616
class ToolControls():
17-
def __init__(self):
18-
self.token = None
19-
20-
self.broker = BrokerConnect()
21-
self.resource = Resources()
17+
def __init__(self, token):
18+
self.token = token
19+
self.broker = BrokerConnect(token)
20+
self.resource = Resources(token)
2221

2322
# TODO: verify_tool() --> get broker message example
2423
# Verify tool exists at xyz coord

imports.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
# Classes
2020

21-
auth = Authentication()
22-
basic = BasicCommands()
23-
broker = BrokerConnect()
24-
camera = Camera()
25-
info = Information()
26-
job = JobHandling()
27-
message = MessageHandling()
28-
move = MovementControls()
29-
peripheral = Peripherals()
30-
resource = Resources()
31-
tool = ToolControls()
21+
# auth = Authentication()
22+
# basic = BasicCommands()
23+
# broker = BrokerConnect()
24+
# camera = Camera()
25+
# info = Information()
26+
# job = JobHandling()
27+
# message = MessageHandling()
28+
# move = MovementControls()
29+
# peripheral = Peripherals()
30+
# resource = Resources()
31+
# tool = ToolControls()

0 commit comments

Comments
 (0)