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
Push — master ( 5b1e82...4e029a )
by Benjamin
01:48
created

SpeedOfPi.set_difficulty()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
1
#import smbus
2
import time
3
4
from lib.updater import Updater
5
from lib.configure import Configure
6
from lib.node import Node
7
from lib.difficulty import Difficulty
8
from lib.game import Game
9
10
11
class SpeedOfPi(object):
12
    def __init__(self):
13
        self.bus = '3' #smbus.SMBus(1)
14
        self.nodes = {}
15
16
        self.config = Configure()
17
        self.load_config()
18
19
    def create_nodes(self, node_config):
20
        for node in node_config['nodes']:
21
            try:
22
                node_number = list(node)[0]
23
                button_address = node[node_number][0]['button'][0]['address']
24
                button_port = node[node_number][0]['button'][1]['port']
25
                led_address = node[node_number][1]['led'][0]['address']
26
                led_port = node[node_number][1]['led'][1]['port']
27
28
                self.nodes[node_number] = Node(self.bus, node_number, button_address, button_port, led_address, led_port)
29
            except:
30
                # throw exception here so user checks config file
31
                print('unable to load node ' + node[0])
32
33
    def load_config(self):
34
        if not self.config.read_config():
35
            print('Could not read file. would you like to setup nodes?')
36
            print('Would you like to setup nodes?')
37
            #todo expect keyboad input [Y/n] (Y,y, yes, YES, *enter)
38
            #if no exit else run set_config()
39
            exit()
40
41
        node_config = self.config.get_config()
42
        self.create_nodes(node_config)
43
44
    def set_config(self):
45
        self.config.set_config()
46
47
    def set_difficulty(self):
48
        return Difficulty()
49
50
    def update(self):
51
        updater = Updater()
52
53
        if updater.check():
54
            updater.update()
55
        else:
56
            print("You are up to date!")
57
58
    def multi_player(self):
59
        difficulty = self.set_difficulty()
60
        game = Game(difficulty)
61
        game.multi_player(self.nodes)
62
63
    def single_player(self):
64
        difficulty = self.set_difficulty()
65
        game = Game(difficulty)
66
        game.single_player(self.nodes)
67
68
if __name__ == '__main__':
69
    a = SpeedOfPi()
70
    a.single_player()