Example #1
0
 def test10_creation(self):
     gui = mock.MagicMock()
     game_factory = mock.MagicMock()
     c = MainController(gui, game_factory)
     self.assertEqual(c.gui, gui)
     self.assertEqual(c.game_factory, game_factory)
     c.gui.show_select_game.assert_not_called()
     c.start()
     c.gui.show_select_game.assert_called_once_with()
Example #2
0
def main():
    app = QApplication()
    #iccstate = IccStateHandler( "ftp.ini")
    setScreenSize(app)
    env = "DEVELOP"
    if not runningInDev():
        # release version running
        terminate_if_running()  # one instance only
        # try:
        #     iccstate.startApplication() # download immo.db from server and set is-in-use flag
        # except Exception as ex:
        #     print( str(ex) )
        #     box = ErrorBox( "ImmoControlCenter", "Failed starting application", str( ex ) )
        #     box.exec_()
        #     return
        createControlFile()  # flag file showing application is running
        env = "RELEASE"
    win = IccMainWindow(env)
    # see: https://stackoverflow.com/questions/53097415/pyside2-connect-close-by-window-x-to-custom-exit-method
    shutDownFilter = ShutDownFilter(win, app)
    win.installEventFilter(shutDownFilter)
    win.show()
    try:
        pos_size = getGeometryOnLastShutdown()
        win.move(pos_size["x"], pos_size["y"])
        #win.resize( pos_size["w"], pos_size["h"] )
        win.setFixedWidth(1100)
        win.setFixedHeight(63)
    except:
        win.resize(1900, 1000)

    MainController(win)

    icon = QIcon("./images/houses.png")
    app.setWindowIcon(icon)

    app.exec_()

    if not runningInDev():
        try:
            # iccstate.stopApplication() # upload immo.db to server and set not-in-use flag
            pass
        except Exception as ex:
            print(str(ex))
            box = ErrorBox("ImmoControlCenter",
                           "Failed shutting down application", str(ex))
            box.exec_()
        finally:
            deleteControlFile()
Example #3
0
class LedControllerServer(BaseHTTPRequestHandler):

    controller = MainController()
    def _set_headers(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()

    def do_POST(self):
        self._set_headers()
        self.data_string = self.rfile.read(int(self.headers['Content-Length']))

        print "in post method " + self.data_string

        self.send_response(200)
        self.end_headers()
        self.controller.changeMode(json.loads(self.data_string))
        self.wfile.write("Ok!")
        return
Example #4
0
 def test11_add_and_list_game(self):
     c = MainController(mock.MagicMock(), mock.MagicMock())
     c.add_game('a_name', 'a_type', dict(x=1))
     c.add_game('b_name', 'b_type', dict(x=2))
     self.assertEqual(['a_name', 'b_name'], sorted(c.list_games()))
Example #5
0
def make_mock_controller(names='a b'.split()):
    c = MainController(mock.MagicMock(), make_mock_game_factory())
    for i, name in enumerate(sorted(names)):
        c.add_game(name + '_name', name + '_type', dict(x=i + 1))

    return c.start()
Example #6
0
 def __init__(self):
     self.mainLogic = MainLogic(testing=True, localhost=True, nosynch=True)
     self.mainController = MainController(self.mainLogic)
     self.mainLogic.loadAppdata()
     self.mainLogic.loadConfig()
Example #7
0
from flask import Flask
from flask_cors import CORS
from flask import request
from maincontroller import MainController
import json
import sys

app = Flask(__name__)
CORS(app)
controller = MainController()


def RGBtoBGR(stringRGB):
    result = "\"#"
    result += stringRGB[3:5]
    result += stringRGB[5:7]
    result += stringRGB[1:3]
    result += "\""
    return result


def changeColor(requestData):
    if requestData and "\"color\"" in requestData:
        i = requestData.index("\"color\"")
        newColor = RGBtoBGR(requestData[i + 17:i + 24])
        newData = requestData[:i + 16]
        newData += newColor
        newData += requestData[i + 25:]
        return newData
    else:
        return requestData
Example #8
0
import sys
from PyQt5.QtWidgets import QApplication
from maincontroller import MainController

if __name__ == '__main__':
    a = QApplication(sys.argv)
    w = MainController()
    w.start()
    sys.exit(a.exec_())