Example #1
0
    def __init__(self, currVersion):
        global instance
        instance = self
        self.currVersion = currVersion
        self.cV = "".join(self.currVersion.split("."))
        if len(self.cV) < 4:
            self.cV = self.cV[0] + self.cV[1] + "0" + self.cV[2]

        try:
            if Config.instance.cfgEnableUpdater == 1:
                conn = http.client.HTTPSConnection("raw.githubusercontent.com", 443)
                conn.request("GET", "/Turnermator13/ArduinoRacingDash/master/version.txt")
                versionStr = re.findall(r"\'(.+?)\'", str(conn.getresponse().read()))[0].split("|")
                self.remoteVersion = versionStr[0]
                self.reqArduinoUpdate = versionStr[1]
                self.changeLog = versionStr[2]
                self.statsURL = versionStr[3]
                conn.close()
        except Exception as e:
            Log.error("Couldn't get Version Information: %s" % e)
            self.updaterError = True
        logStats("Login")

        self.rV = "".join(self.remoteVersion.split("."))
        if len(self.rV) < 4:
            self.rV = self.rV[0] + self.rV[1] + "0" + self.rV[2]

        if (self.remoteVersion != 0) and (self.remoteVersion != Config.instance.cfgRemoteVersion)\
                and (int(self.rV) > int(self.cV)):
            self.isOpen = True
            if self.reqArduinoUpdate == "1":
                Log.info("New acSLI Version Available: v" + self.remoteVersion + ". Requires Arduino Sketch Update")
            else:
                Log.info("New acSLI Version Available: v" + self.remoteVersion)

            self.appWindow = Window("acSLI Updater", 400, 120).setVisible(1).setPos(760, 350)\
                .setBackgroundTexture("apps/python/acSLI/image/backUpdater.png")
            self.btnYes = Button(self.appWindow.app, bFunc_Yes, 110, 20, 20, 90, "Update")\
                .setAlign("center").hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backBtnUpdater.png")
            self.btnNo = Button(self.appWindow.app, bFunc_No, 110, 20, 145, 90, "Not Now")\
                .setAlign("center").hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backBtnUpdater.png")
            self.btnIgnore = Button(self.appWindow.app, bFunc_Ignore, 110, 20, 270, 90, "Ignore Version")\
                .setAlign("center").hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backBtnUpdater.png")

            self.lblVersionTxt = Label(self.appWindow.app, "New acSLI Version Available: v" + self.remoteVersion, 20, 30)\
                .setSize(360, 10).setAlign("center").setFontSize(20).setColor(Utils.rgb(Utils.colours["red"]))
            self.lblLog = Label(self.appWindow.app, self.changeLog, 20, 60)\
                .setSize(360, 10).setAlign("center").setColor(Utils.rgb(Utils.colours["green"]))
        else:
            if self.updaterError:
                Log.info("Updater Encounter an Error. Version Check Incomplete")
            elif Config.instance.cfgEnableUpdater == 1:
                Log.info("Running Latest Version (v%s)" % self.remoteVersion)
    def __init__(self):
        global instance
        instance = self

        self.appWindow = Window("acSLI Com Selector", 650, 360).setPos(635, 240)\
            .setBackgroundTexture("apps/python/acSLI/image/backSelector.png")

        self.btnUP = Button(self.appWindow.app, bFunc_UP, 80, 40, 285, 90, "").setAlign("center").hasCustomBackground()
        self.btnDN = Button(self.appWindow.app, bFunc_DN, 80, 40, 285, 310, "").setAlign("center").hasCustomBackground()

        self.lblMsg = Label(self.appWindow.app, "", 30, 47).setSize(590, 10).setAlign("center").setFontSize(18)\
            .setColor(Utils.rgb(Utils.colours["red"]))
        self.btnAUTO = Button(self.appWindow.app, bFunc_AUTO, 160, 20, 440, 98, "Enable AUTO Mode").setAlign("center")\
            .hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backBtnAuto.png")

        self.btnB0 = Button(self.appWindow.app, bFunc_B0, 600, 20, 25, 150, "").setAlign("center")\
            .hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backList.png")
        self.btnB1 = Button(self.appWindow.app, bFunc_B1, 600, 20, 25, 190, "").setAlign("center")\
            .hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backList.png")
        self.btnB2 = Button(self.appWindow.app, bFunc_B2, 600, 20, 25, 230, "").setAlign("center")\
            .hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backList.png")
        self.btnB3 = Button(self.appWindow.app, bFunc_B3, 600, 20, 25, 270, "").setAlign("center")\
            .hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backList.png")

        self.appWindow.setVisible(0)
Example #3
0
    def __init__(self):
        global instance, progInstance
        progInstance = self

        try:
            self.appWindow = Window("acSLI Update Progress", 800, 100).setVisible(1).setPos(560, 350)\
                    .setBackgroundTexture("apps/python/acSLI/image/backError.png")
            self.lblMsg = Label(self.appWindow.app, "Downloading[0/0][0%]: ", 20, 32)\
                    .setSize(760, 10).setAlign("center").setFontSize(20).setColor(Utils.rgb(Utils.colours["green"]))
        except Exception as e:
                    Log.error("On Update: %s" % e)
Example #4
0
    def __init__(self):
        self.simInfo = Info()
        self.appWindow = Window("acSLI", 250, 260).setBackgroundTexture("apps/python/acSLI/image/backMain.png")

        self.lblPort = Label(self.appWindow.app, "Connected COM Port: {}".format(Config.instance.cfgPort), 15, 40)\
            .setSize(220, 10).setAlign("center").setColor(Utils.rgb(Utils.colours["red"]))
        self.btnUnits = Button(self.appWindow.app, bFunc_SpeedUnits, 200, 20, 25, 90, "Speed Units: {}".format(Config.instance.cfgSpeedUnit))\
                .setAlign("center").hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backBtnLarge.png")
        self.btnFuel = Button(self.appWindow.app, bFunc_FuelDisp, 200, 20, 25, 120, "Fuel Display: {}".format(Config.instance.cfgFuelDisp))\
                .setAlign("center").hasCustomBackground().setBackgroundTexture("apps/python/acSLI/image/backBtnLarge.png")

        self.spnStartPage = Spinner(self.appWindow.app, sFunc_StartPage, 220, 20, 15, 165, "Startup Page", 0, 7, Config.instance.cfgStartPage)
        self.spnIntensity = Spinner(self.appWindow.app, sFunc_Intensity, 220, 20, 15, 215, "Display Intensity", 0, 7, Config.instance.cfgIntensity)
def _findConnect():
    global instance
    portValid = False
    instance.handshake = False
    instance.dispSelect = False

    for sPort, desc, hwid in sorted(serial.tools.list_ports.comports()):
        Log.log("%s: %s [%s]" % (sPort, desc, hwid))

        if Config.instance.cfgPort == "AUTO":
            if "Arduino" in desc:
                instance.port = sPort
                portValid = True
        else:
            if Config.instance.cfgPort == sPort:
                instance.port = sPort
                portValid = True

        if portValid:
            break

    if portValid:
        try:
            instance.ser = serial.Serial(instance.port, 9600, timeout=5)
            time.sleep(2)
            instance.ser.write(bytes([1, 1]))
            arduinoVer = instance.ser.read(5)

            if str(arduinoVer) == "b''":
                instance.port = "----"
                Log.warning(
                    "No Response From Arduino. Please Ensure Arduino is running at least v"
                    + acSLI.App.ArduinoVersion)
                instance.dispSelect = True
                instance.dispSelectMsg = "No Response from Arduino"
                instance.ser.close()
            else:
                aV = re.findall(r"\'(.+?)\'", str(arduinoVer))[0].split('.')[1]
                if len(aV) < 4:
                    aV = aV[0] + aV[1] + "0" + aV[2]

                aLV = "".join(acSLI.App.ArduinoVersion.split("."))
                if len(aLV) < 4:
                    aLV = aLV[0] + aLV[1] + "0" + aLV[2]

                if aLV > aV:
                    instance.port = "----"
                    instance.ser.close()
                    Log.warning(
                        "Arduino Code Outdated(v%s). Please Update Arduino to at least v%s and then Restart AC"
                        % (arduinoVer, acSLI.App.ArduinoVersion))
                    Error.ErrorBox(
                        "Arduino Code Outdated. Please Update Arduino to at least v"
                        + acSLI.App.ArduinoVersion + " and then Restart AC")
                else:
                    instance.handshake = True
                    Log.info("Connected to Arduino running v" + aV[0] + '.' +
                             aV[1] + '.' + aV[2] + aV[3] + " on port " +
                             instance.port)
        except Exception as e:
            Log.error("On Open Port: %s" % e)
    else:
        instance.port = "----"
        if Config.instance.cfgPort == "AUTO":
            Log.warning("No Arduino Detected")
            instance.dispSelect = True
            instance.dispSelectMsg = "No Arduino Detected"
        else:
            Log.warning("Invalid COM Port Configured")
            instance.dispSelect = True
            instance.dispSelectMsg = "Invalid COM Port Configured"

    if instance.port != "----":
        acSLI.acSLI.lblPort.setText("Connected COM Port: {}".format(
            instance.port)).setColor(Utils.rgb(Utils.colours["green"]))
    else:
        acSLI.acSLI.lblPort.setText("Connected COM Port: {}".format(
            instance.port)).setColor(Utils.rgb(Utils.colours["red"]))
def _findConnect():
    global instance
    portValid = False
    instance.handshake = False
    instance.dispSelect = False

    for sPort, desc, hwid in sorted(serial.tools.list_ports.comports()):
        Log.log("%s: %s [%s]" % (sPort, desc, hwid))

        if Config.instance.cfgPort == "AUTO":
            if "Arduino" in desc:
                instance.port = sPort
                portValid = True
        else:
            if Config.instance.cfgPort == sPort:
                instance.port = sPort
                portValid = True

        if portValid:
            break

    if portValid:
        try:
            instance.ser = serial.Serial(instance.port, 9600, timeout=5)
            time.sleep(2)
            instance.ser.write(bytes([1, 1]))
            arduinoVer = instance.ser.read(5)

            if str(arduinoVer) == "b''":
                instance.port = "----"
                Log.warning("No Response From Arduino. Please Ensure Arduino is running at least v" +
                            acSLI.App.ArduinoVersion)
                instance.dispSelect = True
                instance.dispSelectMsg = "No Response from Arduino"
                instance.ser.close()
            else:
                aV = re.findall(r"\'(.+?)\'", str(arduinoVer))[0].split('.')[1]
                if len(aV) < 4:
                    aV = aV[0] + aV[1] + "0" + aV[2]

                aLV = "".join(acSLI.App.ArduinoVersion.split("."))
                if len(aLV) < 4:
                    aLV = aLV[0] + aLV[1] + "0" + aLV[2]

                if aLV > aV:
                    instance.port = "----"
                    instance.ser.close()
                    Log.warning("Arduino Code Outdated(v%s). Please Update Arduino to at least v%s and then Restart AC" % (arduinoVer, acSLI.App.ArduinoVersion))
                    Error.ErrorBox("Arduino Code Outdated. Please Update Arduino to at least v" +
                                   acSLI.App.ArduinoVersion + " and then Restart AC")
                else:
                    instance.handshake = True
                    Log.info("Connected to Arduino running v" + aV[0] + '.' + aV[1] + '.' + aV[2] + aV[3] + " on port " + instance.port)
        except Exception as e:
            Log.error("On Open Port: %s" % e)
    else:
        instance.port = "----"
        if Config.instance.cfgPort == "AUTO":
            Log.warning("No Arduino Detected")
            instance.dispSelect = True
            instance.dispSelectMsg = "No Arduino Detected"
        else:
            Log.warning("Invalid COM Port Configured")
            instance.dispSelect = True
            instance.dispSelectMsg = "Invalid COM Port Configured"

    if instance.port != "----":
        acSLI.acSLI.lblPort.setText("Connected COM Port: {}".format(instance.port)).setColor(Utils.rgb(Utils.colours["green"]))
    else:
        acSLI.acSLI.lblPort.setText("Connected COM Port: {}".format(instance.port)).setColor(Utils.rgb(Utils.colours["red"]))
Example #7
0
    def run(self):
        global instance, progInstance

        try:
            Log.info("Updating Files. Please Wait.")
            UpdateProg()
            logStats("Update")
            Log.info("Creating Backup")
            progInstance.setMsg("Creating Backup")
            shutil.copytree('apps/python/acSLI', 'apps/python/acSLI-BACKUP', ignore=shutil.ignore_patterns("stdlib", "stdlib64", ".idea", "acSLI.txt", "acSLI.ini"))

            conn = http.client.HTTPSConnection("raw.githubusercontent.com", 443)
            conn.request("GET", "/Turnermator13/ArduinoRacingDash/v" + instance.remoteVersion + "/fileList.txt")
            Files = re.findall(r"\'(.+?)\'", str(conn.getresponse().read()))[0].split('\\n')
            Files.append("ArduinoDash.ino")
            lenFiles = len(Files) + 1
            i = 0
            error = "N"

            for filename in Files:
                if filename == "ArduinoDash.ino":
                    conn.request("GET", "/Turnermator13/ArduinoRacingDash/v" + instance.remoteVersion + "/ArduinoDash/" + filename)
                else:
                    conn.request("GET", "/Turnermator13/ArduinoRacingDash/v" + instance.remoteVersion + "/acSLI/" + filename)
                i += 1
                Log.info("Downloading: " + filename)
                progInstance.setMsg("Downloading[%s/%s][%s]: '%s'" % (str(i), str(lenFiles), str(round((i/lenFiles)*100)) + "%", filename))
                if (filename.split('/')[0] == "stdlib" or filename.split('/')[0] == "stdlib64") and os.path.isfile("apps/python/acSLI/" + filename):
                    Log.info("DLL Exists, Skipping")
                    conn.getresponse().read()
                else:
                    res = conn.getresponse().read()
                    if re.findall(r"\'(.+?)\'", str(res))[0] == "Not Found":
                        error = "Couldn't Find File '%s'?? Please report this to the App Author" % filename
                        Log.info("Couldn't Find File '%s'?? Please report this to the App Author" % filename)
                        break
                    else:
                        try:
                            localfile = open("apps/python/acSLI/" + filename,'wb')
                            localfile.write(res)
                            localfile.close()
                        except FileNotFoundError:
                            os.makedirs(filename.split('/')[0])
                            localfile = open("apps/python/acSLI/" + filename,'wb')
                            localfile.write(res)
                            localfile.close()
                        except Exception as e:
                            Log.error("On Update: %s" % e)

            conn.close()

            if error == "N":
                shutil.rmtree("apps/python/acSLI-BACKUP")
                Log.info("Successfully Updated to " + instance.remoteVersion + " , please restart AC Session")
                progInstance.setMsg("Update Successful. Please Restart Session")
                if instance.reqArduinoUpdate == "1":
                    progInstance.setMsg("Success, Please Update Arduino (latest sketch in apps/python/acsli) and Restart Session")
            else:
                progInstance.setColour(Utils.rgb(Utils.colours["red"]))
                progInstance.setMsg("Error Updating. Restoring from Backup")
                Log.info("Error Updating, Restoring from Backup")

                for obj in os.listdir("apps/python/acSLI/"):
                    if not (str(obj) == "stdlib" or str(obj) == "stdlib64" or str(obj) == ".idea" or str(obj) == "acSLI.txt" or str(obj) == "acSLI.ini"):
                        if not "." in str(obj):
                            shutil.rmtree("apps/python/acSLI/" + obj)
                        else:
                            os.remove("apps/python/acSLI/" + obj)

                for obj in os.listdir("apps/python/acSLI-BACKUP/"):
                    if not "." in str(obj):
                        shutil.copytree("apps/python/acSLI-BACKUP/" + obj, "apps/python/acSLI/" + obj)
                    else:
                        shutil.copy("apps/python/acSLI-BACKUP/" + obj, "apps/python/acSLI/" + obj)

                shutil.rmtree("apps/python/acSLI-BACKUP")
                progInstance.setMsg(error)
            progInstance.dispButton()
        except Exception as e:
                    Log.error("On Update: %s" % e)