Exemple #1
0
    def updateFileTime(self):
        """
        Updates the file contents associated with this item

        """
        copy = ""
        try:
            if savestate.configList["ListSplit"]:
                if self.parent is savestate.saveLists["Left"]:
                    copy = str(self.path + savestate.configList["LeftListName"] +
                               savestate.symbol + self.ui.label.text() + ".txt")
                elif self.parent is savestate.saveLists["Right"]:
                    copy = str(self.path + savestate.configList["RightListName"] +
                               savestate.symbol + self.ui.label.text() + ".txt")
                else:
                    print(self.parent, savestate.saveLists["Left"])
                    information("This item has no file!")
            else:
                copy = str(self.path + self.ui.label.text() + ".txt")
            with open(copy, "w+") as file:
                file.write(self.getTimeString())
        except FileNotFoundError:
            print("Error in " + self.name + ", the file this link points to does not exist!")
        except UnboundLocalError:
            self.updateFileTime()
        except RuntimeError:
            print("Item deleted due to runtime, rebuilding list...")
def loadConfig(self, basefilepath):
    # Loads a save file
    logWrite("Trying to load a config, waiting on user...")
    information("Loading a config file will delete all current contents!")
    file, ok = QFileDialog.getOpenFileName(self, "Open Save", basefilepath,
                                           "*.oi")
    if ok:
        logWrite("Loading config file...")
        # print(str(file))
        deleteAllItems()
        print("Opening file from: " + str(file))
        createListFiles(str(file))
Exemple #3
0
def getClient(self):
    # init method to call all subsequent functions. Will build up the stats.
    try:
        startConnection(self)
    except IndexError:
        # if there is no = in the found part
        information("Error in collecting process data!")
        self.ui.SummonerName.setStyleSheet("QLineEdit{background: lightred;}")
    except Exception as e:
        print(e)
    tryPollSummonerName(self)
    print(savestate.summoner)
def saveConfig(self, basefilepath):
    """
    saves the current lists and eSports contents to a separate file

    :param self: SettingsWindow
    :param basefilepath: str
    :return: None
    """
    logWrite("Trying to save config, waiting on user...")
    filepath, ok = QFileDialog.getSaveFileName(self, "Create Save",
                                               basefilepath, ".oi")
    if ok:
        logWrite("Saving config...")
        file = str(filepath + ".oi")
        try:
            shutil.copy(
                str(savestate.standardFilePath + savestate.symbol +
                    "autosave.json"), file)
        except FileNotFoundError:
            information("Saving failed, please restart the program!")
            logWrite("Saving failed, please restart the program!")
        print("Exported save to: " + file)
Exemple #5
0
    def getPath(self):

        copy: str = ""

        if savestate.configList["ListSplit"]:
            if self.parent is savestate.saveLists["Left"]:
                copy = str(self.path + savestate.configList["LeftListName"] +
                           savestate.symbol + self.ui.label.text())
            elif self.parent is savestate.saveLists["Right"]:
                copy = str(self.path + savestate.configList["RightListName"] +
                           savestate.symbol + self.ui.label.text())
            else:
                information("This item has no file!")
        else:
            copy = str(self.path + self.ui.label.text())
        try:
            if savestate.symbol == "\\":
                pyperclip.copy(copy.replace("/", "\\"))
            else:
                pyperclip.copy(copy)
        except FileNotFoundError:
            print("This is a test exception")
Exemple #6
0
    def installPaths(self):
        _translate = QtCore.QCoreApplication.translate
        information("Please input the target directory.")
        path = QFileDialog.getExistingDirectory(self.centralwidget,
                                                "Input target directory",
                                                powerPathing["packagePath"])
        powerPathing["userPath"] = path

        information(
            "Please input the JSON-File. Make sure your whole package lies in the same directory"
        )

        file = QFileDialog.getOpenFileName(self.centralwidget,
                                           "Input JSON directory",
                                           powerPathing["packagePath"])

        powerPathing["jsonfile"] = file[0]
        powerPathing["jsonpath"] = os.path.split(powerPathing["jsonfile"])[0]
        print(powerPathing["jsonfile"], powerPathing["jsonpath"])

        subdirlist = powerPathing["jsonpath"].split("/")[-1]
        print("This is the directory list: ", subdirlist)

        try:
            getFilePathsfromJSON(subdirlist)
            getOBSPath(0)
        except FileNotFoundError:
            pass
        try:
            file = open(".config", "r+")
        except FileNotFoundError or PermissionError:
            print("there is not config file yet, creating one...")
            file = open(".config", "w")
        file.truncate(0)
        json.dump(powerPathing, file, sort_keys=True, indent=4)
        file.close()
        os.system("attrib +h " +
                  str(Path(powerPathing["packagePath"] + "/.config")))
Exemple #7
0
def copyFile(source, destination):
    try:
        shutil.copy(source, destination)
    except FileNotFoundError:
        information("File could not be found...")
Exemple #8
0
    def __init__(self):
        super().__init__()

        # set a window icon and show the early access info

        self.setWindowIcon(QIcon("images" + savestate.symbol + "icon.png"))

        # Check if the folder exists
        if savestate.platform == "linux":
            try:
                print("Trying to create the standard Folder under linux...")
                os.mkdir(savestate.home + "/Documents/StreamHelper")
            except FileExistsError:
                print("Folder exists!")
        else:
            try:
                print("Trying to create the standard Folder under windows...")
                os.mkdir(os.getenv('LOCALAPPDATA') + "\\StreamHelper")
            except FileExistsError:
                print("Folder exists!")

        # Lets create all the standard files (json and txt) or at least check if they exist
        createStandardFiles(0)

        # init a logfile
        logCreate()
        logWrite(
            "The Program is in developement! \n"
            "Currently, only the textfiles and numbers are working, the other stuff is WIP."
            "Masks aren't importable yet \n")
        information("The Program is in developement! \n"
                    "Please mind the changelog and updates.")

        # Parse the paths from the xml files so we know where to check for the files
        try:
            readSettings()
            print(savestate.configList)
        except FileNotFoundError:
            print(
                "The config file has not been created yet. Proceeding with standard settings..."
            )
            logWrite(
                "The config file has not been created yet. Proceeding with standard settings..."
            )
        except JSONDecodeError:
            print(
                "There was an error reading the config file! Please try restarting the program. \n"
                "If this error persists, consider reinstalling or contacting the developer."
            )
            logWrite(
                "There was an error reading the config file! Please try restarting the program. \n"
                "If this error persists, consider reinstalling or contacting the developer."
                "Using Standard Values for now.")
        oldFilePath = savestate.standardFilePath
        newFilePath = savestate.configList["CustomFilePath"]

        # Set the read filepath so we got it internally to work with
        # savestate.standardFilePath = newFilePath

        # Create the timer
        savestate.timer = QTimer()
        savestate.timer.setInterval(1000)
        savestate.timer.start()

        # Tell the log whats up
        print("Loading config data")
        print("Standard file path is ", oldFilePath,
              "\n" + "Custom file path is ",
              savestate.configList["CustomFilePath"])
        logWrite("Loading config data")
        logWrite(
            str(("Standard file path is: " + oldFilePath +
                 "   Custom file path is " +
                 savestate.configList["CustomFilePath"])))
        # Make it work

        # Basic loading and startup operations
        window = txlinit(self)

        # Connect the extra window
        savestate.ExtraFieldWidget = eSportsExtensionWidget(self)
        # initConnection(self)

        # Detect the interactions / NOW HANDLED IN DESIGNATED PACKAGES
        # There are only the menu-items binded here in the main package

        # This will be deprecated soon, moved to settings
        # window.actionSetMainFilePath.triggered.connect(lambda: setFilePath(self, newFilePath))
        # Show the documentation (links to online though)
        window.actionStreamHelperDocumentation.triggered.connect(
            lambda: webbrowser.open(
                "https://github.com/xFLLSquadronNorden/StreamHelper.py"))
        # Save and Load configs from files
        window.actionSave.triggered.connect(
            lambda: saveConfig(self, newFilePath))
        window.actionLoad.triggered.connect(
            lambda: loadConfig(self, newFilePath))
        # Quit the application
        window.actionQuit.triggered.connect(lambda: sys.exit(0))

        window.actionLog.triggered.connect(lambda: webbrowser.open(
            standardFilePath + savestate.symbol + "StreamLog.log"))
        # Show the new version Changes
        window.actionVersion_Changes.triggered.connect(
            lambda: webbrowser.open("CHANGELOG.txt"))

        # Load and save settings
        window.actionMain_Settings.triggered.connect(showSettings)

        # Show the bonus Tool
        window.actionPackage_Installer.triggered.connect(
            lambda: showPackageInstaller(self))
Exemple #9
0
def addToList(text: str, itemid: int, value: str, slist: int, pretext: str):
    """
    Creates an item for further usage, saves the item and displays it in the list

    :type pretext: str
    :type text: str
    :type itemid: int
    :type value: str
    :type slist: int
    """
    endlist = savestate.saveLists["Left"]
    suplist = "Left"
    if slist == 1:
        endlist = savestate.saveLists["Right"]
        suplist = "Right"
    elif slist > 1:
        print("There is no list assigned to that number!")

    if itemid == 0:
        # Add a text item
        if not savestate.configList["AllowedItems"]["Text Item"]:
            return
        args = {"name": text, "value": value}
        item = TextItem(endlist, args)
        try:
            savestate.saveListItems[suplist][endlist.count() - 1] = {"item": item}
            savestate.saveListData[suplist][endlist.count() - 1] = {"itemData": item.getProperties()}
        except KeyError:
            pass

        # print("Saved: ", savestate.saveListData)
        # print("Items look like this: ", savestate.saveListItems)

    if itemid == 1:
        # Add a number item
        if not savestate.configList["AllowedItems"]["Number Item"]:
            return
        args = {"name": text, "value": value, "pretext": pretext}
        item = NumberItem(endlist, args)

        try:
            savestate.saveListItems[suplist][endlist.count() - 1] = {"item": item}
            savestate.saveListData[suplist][endlist.count() - 1] = {"itemData": item.getProperties()}
        except KeyError:
            pass

        # print("Saved: ", savestate.saveListData)
        # print("Items look like this: ", savestate.saveListItems)
    if itemid == 2:
        if not savestate.configList["AllowedItems"]["Chrono Item"]:
            return
        # Add a chrono item. Chronotype will be ignored if given in valueTime
        args = {"name": text, "valueTime": value, "chronotype": 0, "returnMsg": pretext}
        item = ChronoItem(endlist, args)

        try:
            savestate.saveListItems[suplist][endlist.count() - 1] = {"item": item}
            savestate.saveListData[suplist][endlist.count() - 1] = {"itemData": item.getProperties()}
        except KeyError:
            pass
    if itemid == 3:
        if not savestate.configList["AllowedItems"]["Image Item"]:
            return
        # Adds an image item to the list, containing the path to an image and a custom name
        args = {"name": text, "path": value, "optionalArgs": pretext}
        item = ImageItem(endlist, args)

        try:
            savestate.saveListItems[suplist][endlist.count() - 1] = {"item": item}
            savestate.saveListData[suplist][endlist.count() - 1] = {"itemData": item.getProperties()}
        except KeyError:
            pass
    elif itemid > 3:
        print("There is no item assigned to this index!")
        information("This item is not implemented in this version!")