GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#1)
by
unknown
01:30
created

train_light.Train.run()   A

Complexity

Conditions 4

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 14
nop 1
dl 0
loc 16
rs 9.7
c 0
b 0
f 0
1
import logging
2
from curio import sleep
3
from bricknil import attach, start
4
from bricknil.hub import PoweredUpHub
5
from bricknil.sensor import Light
6
7
8
@attach(Light, name='light')
9
class Train(PoweredUpHub):
10
11
    async def run(self):
12
        self.message_info("Running")
13
        self.keep_running = True
14
        brightness = 0
15
        delta = 10
16
17
        while self.keep_running:
18
            # change the brightness up and down between -100 and 100
19
            brightness += delta
20
            if brightness >= 100:
21
                delta = -10
22
            elif brightness <= -100:
23
                delta = 10
24
            self.message_info("Brightness: {}".format(brightness))
25
            await self.light.set_brightness(brightness)
26
            await sleep(1)
27
28
29
async def system():
30
    Train('My Train')
31
32
if __name__ == '__main__':
33
    logging.basicConfig(level=logging.INFO)
34
    start(system)
35