Exemplo n.º 1
0
def transform_response(_json: dict) -> str:
    """Transform message format from sports db to lite version for display via API"""
    my_list = dict(_json).pop("results")
    converted_list = []
    for fix in my_list:
        converted_list.append(Fixture(fix))
    return json.dumps([f.dump() for f in converted_list])
Exemplo n.º 2
0
    def singlesend(self):
        cmd_text = self.textcombox3.currentText()
        self.label_showresult.clear()
        self.label_showmax.setText('')
        self.label_showmin.setText('')
        self.label_showmean.setText('')

        if self.bg.checkedId() != -1:
            try:
                t = Fixture().senddir(cmd_text)
                print(t)
                num_value = re.compile('[+-][0-9.]+[0-9]+[E|e|^][+-][0-9]+')
                result = num_value.match(t)
                if t.startswith('Keysight'):
                    self.label_showresult.appendPlainText(t)
                    return

                if result.group(0):
                    text = self.changeformat(t) + self.unit
                    self.label_showresult.appendPlainText(text)
            except Exception as e:
                self.label_showresult.appendPlainText(str(Exception) + str(e))

        elif self.bg.checkedId() == -1:
            QMessageBox.information(self, '提示',
                                    'Need to choose the testing model',
                                    QMessageBox.Ok)
Exemplo n.º 3
0
 def setUp(self):
   self.build_mvine = Mvine.build
   Mvine.build = Mock(return_value = True)
   self.cs = ConstraintSystem()
   self.cs._propagate_walk_strength = Mock(return_value = True)
   self.cs.collect_unenforced = Mock(return_value = True)
   self.f = Fixture()
Exemplo n.º 4
0
 def addNewFixture(self):
     newIdNumber = len(self.fixtures)+1
     fixture = Fixture(self.graphicsView, newIdNumber);
     self.fixtures.append(fixture)
     self.fixtureChooser.addItem(str(len(self.fixtures)))
     self.fixtureChooser.setCurrentIndex(len(self.fixtures))
     self.chosen(len(self.fixtures))
Exemplo n.º 5
0
async def load():
    # Init fixture array & node dict
    fixtures = []
    nodes = {}
    for dirpath, dirs, files in os.walk("./active/"):
        for filename in files:
            # Load config file
            fname = os.path.join(dirpath, filename)
            config = configparser.ConfigParser()
            config.read(fname)

            # Init fixtureconfig object
            fixtureconfig = {}

            # Load values from config to fixtureconfig
            # Needs to made prettier
            for key in config['position']:
                fixtureconfig[key] = float(config['position'][key])
            for key in config['channels']:
                fixtureconfig[key] = int(config['channels'][key])
            for key in config['location']:
                fixtureconfig[key] = float(config['location'][key])

            fixtureconfig['start_channel'] = int(
                config['DMX']['start_channel'])
            fixtureconfig['universe'] = int(config['DMX']['universe'])
            fixtureconfig['node_ip'] = config['DMX']['node_ip']

            fixtureconfig['prefer_tilt'] = config['misc'].getboolean(
                'prefer_tilt')
            fixtureconfig['default_fade_time'] = int(
                config['misc']['default_fade_time'])
            fixtureconfig['invert_tilt'] = config['misc'].getboolean(
                'invert_tilt')
            fixtureconfig['invert_pan'] = config['misc'].getboolean(
                'invert_pan')

            node_ip = fixtureconfig['node_ip']
            universe = fixtureconfig['universe']

            # Create node, universe and fixture objects
            if not node_ip in nodes:
                # Create new node if it doesn't exist
                nodeobj = ArtNetNode(node_ip, max_fps=44, refresh_every=5)
                await nodeobj.start()
                nodes[node_ip] = {'node': nodeobj, 'universes': {}}
            if not universe in nodes[node_ip]['universes']:
                # Create new universe if it doesn't exist
                nodeobj = nodes[node_ip]['node']
                universeobj = nodeobj.add_universe(universe)
                nodes[node_ip]['universes'][universe] = universeobj

            # Create fixture and init
            fixture = Fixture(fixtureconfig)
            fixture.start(nodes[node_ip]['universes'][universe])

            fixtures.append(fixture)
    return (fixtures, nodes)
Exemplo n.º 6
0
	def __init__(self):
		DATA.Readini()
		self.ll = localLog.LocalLog()
		self.sfis = SFIS.SFIS()
		self.fix = Fixture()


		self.windowname = DATA.WindowName
		self.id = 0
		self.ISNid_list = []
Exemplo n.º 7
0
 def setUp(self):
     mock_config_parser = configparser.ConfigParser()
     mock_os = mock.Mock()
     mock_config_parser["kong-apikey"] = {"apikey": "testing_api_key"}
     mock_config_parser.read = mock.MagicMock()
     mock_config_parser.ConfigParser = mock.MagicMock(
         return_value=mock_config_parser)
     mock_os.environ = {
         "kong_apikey_file": "secrets.ini"
     }
     sys.modules['configparser'] = mock_config_parser
     sys.modules['os'] = mock_os
     from fixture import Fixture
     self.subject = Fixture()
Exemplo n.º 8
0
    def add_result(self, player_id, gameweek, fixture_set, league):
        result = Fixture(player_id, gameweek, fixture_set)
        
        league.at[player_id, "GD"] = league["GD"][player_id] + result.team_score
        
        if result.outcome_points == 3:
            league.at[player_id, "Wins"] = league["Wins"][player_id] + 1
            league.at[player_id, "Points"] = league["Points"][player_id] + 3

        elif result.outcome_points == 1:
            league.at[player_id, "Draws"] = league["Draws"][player_id] + 1
            league.at[player_id, "Points"] = league["Points"][player_id] + 1
        
        elif result.outcome_points == 0:
            league.at[player_id, "Losses"] = league["Losses"][player_id] + 1

        return league
Exemplo n.º 9
0
    def __init__(self, fixture_data, start_index, teams):
       fixture_index = start_index
       self.table = Table(teams)
       self.fixtures = []
       self.number = int(start_index / 10.0)
       for i in range(start_index, start_index+10):
           current_fixture = Fixture()
           current_fixture.hteam = fixture_data[cst.HOME_TEAM][i]
           current_fixture.ateam = fixture_data[cst.AWAY_TEAM][i]
           current_fixture.hg = int(fixture_data[cst.HG][i])
           current_fixture.ag = int(fixture_data[cst.AG][i])

           self.fixtures.append(current_fixture)
           self.table.add_fixture(current_fixture)

       if len(self.fixtures) != 10:
           print('Error - should be 10 fixtures, there are {0}'
               .format(len(self.fixtures)))
           return
Exemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     super(MyGraphicsView, self).__init__()
     scene = QGraphicsScene(self)
     self.mainWindow = args[0]
     self.actFixture = Fixture(self)
     self.conf = loadconf()
     self.scene = scene
     scene.setItemIndexMethod(QGraphicsScene.NoIndex)
     scene.setSceneRect(0, 0, self.conf['x_max'], self.conf['y_max'])
     self.setScene(scene)
     self.setCacheMode(QGraphicsView.CacheBackground)
     self.setCacheMode(QGraphicsView.CacheNone)
     self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
     self.setResizeAnchor(QGraphicsView.AnchorViewCenter)
     self.grabbed = None
     self.selected = None
     self.bgImage = None
     self.mainSprite = None
     self.zoom = 1
     self.zoomStep = 2  # used by menu commands
     self.zoomScale = 1  # used by mouse zoom
     self.signalZoomByMouse.connect(self.slotZoom, Qt.QueuedConnection)
     self.setTransformationAnchor(QGraphicsView.NoAnchor)
Exemplo n.º 11
0
 def fixtures(self):
     if self._fixtures is None and self._data.get("fixtures", None):
         self._fixtures = [Fixture(fd) for fd in self._data["fixtures"]]
     else:
         self._fixtures = []
     return self._fixtures
Exemplo n.º 12
0
from fixture import Fixture

fixture = Fixture()
fixture.run()
Exemplo n.º 13
0
                  preferredday=row[4],
                  preferredtime=row[5],
                  weight=int(row[6])))
print(len(potential_matches))

print("Loading all available spots")
with open('resources/all_available_spots.csv',
          mode='r',
          newline='',
          encoding='utf-8') as csvfile:
    csvreader = csv.reader(csvfile, delimiter=',')
    for row in csvreader:
        fixtures.append(
            Fixture(round=row[0],
                    when=datetime.strptime(row[1] + " " + row[3],
                                           "%d/%m/%Y %H:%M"),
                    venue=row[4],
                    capacity=int(row[5])))
print(len(fixtures))

with open("resources/generated_fixtures.txt",
          mode='w',
          newline='',
          encoding='utf-8') as outfile:
    print(
        "Randomly assign a potential match to an available spot i.e. create a fixture"
    )
    for fixture in fixtures:  # Fill all available fixtures
        while fixture.available_capacity != 0:  # Fill all capacity for a given venue
            filtered_matches = list(
                filter(
Exemplo n.º 14
0
 def sendcmd(self, cmd):
     try:
         text = Fixture().senddir(cmd)
         return text
     except Exception as e:
         return str(Exception) + str(e)