def deleteFile(self, name):
     dir = utility.get_dir("timers")
     script_dir = os.path.dirname(
         __file__)  #<-- absolute dir the script is in
     relative_path = name  #+ ".json"
     real_file_path = os.path.join(script_dir, dir, relative_path)
     os.remove(real_file_path)
 def deleteFile(self, fileName):
     dir = utility.get_dir("logs/event_logs")
     script_dir = os.path.dirname(
         __file__)  #<-- absolute dir the script is in
     script_dir = ""
     relative_path = "../Praxis/logs/event_logs/" + fileName + ".json"
     real_file_path = os.path.join(script_dir, relative_path)
     os.remove(real_file_path)
Beispiel #3
0
    def updateChyronFile(self):
        dir = utilities.get_dir("stream_sources")
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in
        script_dir = ""
        relative_path = "../Praxis/stream_sources/chyron.txt"
        real_file_path = os.path.join(script_dir, relative_path)

        file = open(real_file_path, "wb")
        chyron = self.chyron_stringUpdater().encode("utf8")
        file.write(chyron)
        file.close
    def getTempTextFile(self, key):
        dir = utilities.get_dir("stream_sources")
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in
        script_dir = ""
        relative_path = "../Praxis/stream_sources/" + key + ".txt"
        real_file_path = os.path.join(script_dir, relative_path)

        file = open(real_file_path, "rb")
        text = file.read()
        #print(text)
        file.close
        return text
    def update_tempTextFiles(self):
        dir = utilities.get_dir("stream_sources")
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in
        script_dir = ""

        for key in self.tempText_items:
            item = self.tempText_items[key]
            relative_path = "../Praxis/stream_sources/" + item.itemName + ".txt"
            real_file_path = os.path.join(script_dir, relative_path)

            file = open(real_file_path, "wb")
            itemText_ = item.item_stringUpdater().encode("utf8")
            file.write(itemText_)
            file.close
    def updateCredentialsFile(self, token, refreshToken):
        dir = utility.get_dir("credentials")
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in
        relative_path = "credentials/twitch.json"
        real_file_path = os.path.join(script_dir, relative_path)

        with open(real_file_path, 'r') as cred_r:
            data = json.load(cred_r)
            data['pubsub_AccessToken'] = token
            data['pubsub_RefreshToken'] = refreshToken

        os.remove(real_file_path)
        with open(real_file_path, 'w') as cred_w:
            json.dump(data, cred_w, indent=2)
    def readFile(self, name):
        dir = utility.get_dir("timers")
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in
        relative_path = name  #+ ".json"
        real_file_path = os.path.join(script_dir, dir, relative_path)

        with open(real_file_path, 'r') as cred_r:
            data = json.load(cred_r)
            name = data['name']
            startTime = data['startTime']
            endTime = data['endTime']
            trigger = data['trigger']
            trigger_exec = data['trigger_exec']
            timerFormat = data['timerFormat']
            tempTimer = data['tempTimer']
        return name, startTime, endTime, trigger, trigger_exec, timerFormat, tempTimer
    def makeFile(self, timer_obj: timer):
        dir = utility.get_dir("timers")
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in
        relative_path = timer_obj.name + ".json"
        real_file_path = os.path.join(script_dir, dir, relative_path)

        with open(real_file_path, 'w') as cred_w:
            #data = json.load(timer_obj)
            dic = {}
            dic['name'] = timer_obj.name
            dic['startTime'] = str(timer_obj.startTime)
            dic['endTime'] = str(timer_obj.endTime)
            dic['trigger'] = timer_obj.trigger
            dic['trigger_exec'] = timer_obj.trigger_exec
            dic['timerFormat'] = timer_obj.timerFormat
            dic['tempTimer'] = str(timer_obj.tempTimer)
            json.dump(dic, cred_w, indent=2)
    def makeFile(self, fileName):
        dir = utility.get_dir("logs/event_logs")
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in
        script_dir = ""
        relative_path = "../Praxis/logs/event_logs/" + fileName + ".json"
        real_file_path = os.path.join(script_dir, relative_path)

        newList = []
        for event in self.Event_Log_List:
            newDic = {}
            newDic['eventName'] = event.eventName
            newDic['eventTime'] = str(event.eventTime)
            newDic['eventType'] = str(event.eventType)
            newDic['eventSender'] = str(event.eventSender)
            newDic['eventData'] = str(event.eventData)
            newList.append(newDic)
        with open(real_file_path, 'w') as logFile:
            json.dump(newList, logFile, indent=2)
    async def voiceTest(self, filename: str = "68e2183965ed238c82d138030b82986f_tts"):
        praxis_logger_obj.log("\n -Voice Test")
        self.VC_Channel:discord.channel.VoiceChannel = self.get_channel(663970225821188096)
        praxis_logger_obj.log("About to Connect")
        self.voiceClient:discord.VoiceClient = await self.VC_Channel.connect()
        audioFile = utility.get_dir("tts") + "/%s.mp3" % filename
        player = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(audioFile))
        self.voiceClient.play(player)
        #praxis_logger_obj.log("\n -Voice Channel: " + str(self.VC_Channel))
        #praxis_logger_obj.log("\n -Voice Channel Type: " + str(type(self.VC_Channel)))

        #await self.VC.move_to(self.VC_Channel)
        #await self.VC_Channel
        waitBool = True
        while waitBool:
            if self.voiceClient.is_playing():
                await asyncio.sleep(1)
            else:
                waitBool = False
        await self.voiceClient.disconnect()
    def readFile(self, fileName):
        dir = utility.get_dir("logs/event_logs")
        script_dir = os.path.dirname(
            __file__)  #<-- absolute dir the script is in
        script_dir = ""
        relative_path = "../Praxis/logs/event_logs/" + fileName + ".json"
        real_file_path = os.path.join(script_dir, relative_path)

        newList = []
        with open(real_file_path, 'r') as eventlog_:
            data = json.load(eventlog_)
            for d in data:
                eventName = d['eventName']
                eventTime = d['eventTime']
                eventType = d['eventType']
                eventSender = d['eventSender']
                eventData = d['eventData']

                foundLog = event_log(eventName, eventTime, eventType,
                                     eventSender, eventData)
                newList.append(foundLog)
        return newList