def UnloadImage(self):
        """
        Unload all loaded sprites
        :return:
        """
        print("Image.Unload : Unloading Images...")
        UTILS.GarbageCollector_Collect()
        del self.Images_Data
        del self.Images_Name
        del CurrentLoadedFonts_Name
        UTILS.GarbageCollector_Collect()

        self.Images_Data = list()
        self.Images_Name = list()

        print("Image.Unload : Done")
    def UnloadSoundTuneCache(self):
        print(
            "ContentManager.UnloadSoundTuneCache : Clearing FrequencyGenerator Cache..."
        )
        self.SoundTuneCache_Cache.clear()
        self.SoundTuneCache_Names.clear()
        UTILS.GarbageCollector_Collect()

        del self.SoundTuneCache_Cache
        del self.SoundTuneCache_Names
        UTILS.GarbageCollector_Collect()

        self.SoundTuneCache_Cache = list()
        self.SoundTuneCache_Names = list()
        UTILS.GarbageCollector_Collect()
        print("ContentManager.UnloadSoundTuneCache : Done")
Exemple #3
0
def NewMusicFile():
    global track_list

    track_list = UI.TrackList()
    Utils.GarbageCollector_Collect()

    # -- Unload the Current SoundCahce -- #
    UI.ContentManager.UnloadSoundTuneCache()

    # -- Update Tittlebar -- #
    var.ProcessReference.TITLEBAR_TEXT = "OneTrack v{0}".format(
        var.ProcessReference.DefaultContents.Get_RegKey("/version"))

    track_list = UI.TrackList()
    track_list.Rectangle = pygame.Rect(0, 100, Core.MAIN.ScreenWidth,
                                       Core.MAIN.ScreenHeight - 200)

    var.BPM = 150
    var.Rows = 32
    var.GenerateSoundCache = True
    var.SelectedTrack = 0
    var.Highlight = 4
    var.HighlightSecond = 16
    var.Patterns = 2

    OptionsBar.UpdateChanger()
    OptionsBar.Update()

    var.ProcessReference.DefaultContents.Write_RegKey(
        "/dialog/imported_older_version/show_once", "False")
    def LoadRegKeysInFolder(self):
        """
        Load all keys on Specified Folder
        :param reg_dir:Specified Folder
        :return:
        """
        if self.Reg_Path == "":
            raise Exception("Registry Path was not set.")

        reg_dir = self.Reg_Path
        # -- FIX for working on Windows -- #
        self.Reg_Path = self.SourceFolder + reg_dir.replace(
            self.SourceFolder, "")
        self.Reg_Path = self.Reg_Path.replace(
            "/", CorePaths.TaiyouPath_CorrectSlash)

        start_time = time.time()
        # -- Unload the Registry -- #
        self.UnloadRegistry()

        print("Taiyou.ContentManager.LoadRegistry : Loading Registry...")

        temp_reg_keys = UTILS.Directory_FilesList(reg_dir)
        index = -1

        for x in temp_reg_keys:
            if self.StopLongOperations:
                break

            index += 1

            CorrectKeyName = x.replace(reg_dir, "").replace(".data", "")
            file = open(x, "r")

            CurrentLine = file.read().splitlines()
            AllData = ""
            for x in CurrentLine:
                if not x.startswith("#"):
                    AllData += x + "\n"

            # -- Format the Text -- #
            AllData = AllData.rstrip().replace("%n", "\n").replace(
                "%t", "\t").replace("%s", " ")

            self.reg_keys.append(CorrectKeyName)
            self.reg_contents.append(AllData)

            print("Taiyou.ContentManager.LoadRegistry : KeyLoaded[" +
                  CorrectKeyName + "]")

        print(
            "Taiyou.ContentManager.LoadRegistry : Total of {0} registry keys loaded. In {1} seconds."
            .format(str(len(self.reg_keys)),
                    UTILS.FormatNumber(time.time() - start_time, 4)))

        UTILS.GarbageCollector_Collect()
    def ReloadRegistry(self):
        """
        Reload all Registry Keys
        :return:
        """
        print("Taiyou.ContentManager.ReloadRegistry : Reloading Registry...")
        self.UnloadRegistry()

        self.LoadRegKeysInFolder()

        UTILS.GarbageCollector_Collect()
    def UnloadRegistry(self):
        """
        Unload all registry keys
        :return:
        """

        # -- Clear the Registry -- #
        print("Taiyou.ContentManager.UnloadRegistry : Unloading Registry")
        self.reg_keys = list()
        self.reg_contents = list()

        UTILS.GarbageCollector_Collect()
def KillProcessByPID(PID):
    global ProcessListChanged
    Index = GetProcessIndexByPID(PID)

    # Call SIG_KILL Function on Process
    ProcessAccess[ProcessAccess_PID.index(PID)].KillProcess(False)

    UTILS.GarbageCollector_Collect()

    print("Taiyou : Finished process index: " + str(Index))

    #ProcessListChanged = True

    ClearPreRendered()
Exemple #8
0
    def KillProcess(self, WhenKilled=True):
        """
        This function is called when the processing is being closed by Taiyou [Unsafe to Override]
        :return:
        """
        print("Process [{0}] has received kill request.".format(self.TITLEBAR_TEXT))
        CoreAccess.RemoveFromCoreAccess(self)
        if self.IS_GRAPHICAL:
            self.KillDrawThread()

        self.Running = False

        if WhenKilled:
            self.WhenKilled()

        del self
        UTILS.GarbageCollector_Collect()
def CreateProcess(Path, ProcessName, pInitArgs=None):
    """
     Set the Application Object
    :param ApplicationFolder:Folder Path
    :return:
    """
    global ProcessNextPID
    global LastProcessWasErrorProcess
    global LastProcess

    print("CoreAccess.CreateProcess : Creating Process: [" + ProcessName +
          "]...")

    try:
        # Get Process Path
        Path = Path.replace("/", CorePaths.TaiyouPath_CorrectSlash)
        ProcessIndex = len(ProcessAccess_PID)
        ProcessNextPID += 1

        # Import Module
        Module = importlib.import_module(Core.Get_MainModuleName(Path))

        try:
            # Get Process Object from Module
            ProcessWax = Module.Process(ProcessNextPID, ProcessName,
                                        Core.Get_MainModuleName(Path),
                                        pInitArgs, ProcessIndex)

        except:
            # Unload Module
            del Module

            # Check if module is imported and remove it
            if Core.Get_MainModuleName(Path) in sys.modules:
                sys.modules.pop(Core.Get_MainModuleName(Path))
            UTILS.GarbageCollector_Collect()

        # Unload Module
        del Module

        # Check if module is imported and remove it
        if Core.Get_MainModuleName(Path) in sys.modules:
            sys.modules.pop(Core.Get_MainModuleName(Path))
        UTILS.GarbageCollector_Collect()

        # Start process thread with UpdateRequest Function
        Thread = threading.Thread(target=ProcessWax.UpdateRequest).start()

        # Set THIS_THREAD Variable to Process
        ProcessWax.THIS_THREAD = Thread

        print("CoreAccess.CreateProcess : Process created sucefully")
        # Return newly created process PID
        LastProcessWasErrorProcess = False
        LastProcess = None
        return ProcessNextPID

    except:
        print("CoreAccess.CreateProcess : Error while creating process.")
        print(traceback.format_exc())

        if not LastProcessWasErrorProcess:
            LastProcessWasErrorProcess = True

            try:
                LastProcess.KillProcess(False)

                LastProcess = None
            except:
                print(
                    "Core.Main.CreateProcess : Error while trying to kill process"
                )

            CreateProcess(
                "System{0}SystemApps{0}crash_dialog".format(
                    CorePaths.TaiyouPath_CorrectSlash), "application_crash",
                (ProcessName, None, None, 1))