Beispiel #1
0
	def __write( self, inLogFile, inDate, inMsg ):
		#############################
		# データを作成
		wTimeDate = inDate[0] + " " + inDate[1]
		
		wSetLine = []
			# 2行目以降のブランク文字列
		wBlank   = " " * len(wTimeDate)
			# 2行目以降の文字列リスト作成
		wMsgLine = inMsg.split('\n')
		wMsg1 = wMsgLine[0]
		del wMsgLine[0]
		
		wOutLine = ""
		#############################
		# 1行目
		wLine = wTimeDate + ' ' + wMsg1 + '\n'
		wSetLine.append( wLine )
		wOutLine = wLine
		
		#############################
		# 2行目以降
		if len(wMsgLine)>0 :
			for wLine in wMsgLine :
				wIncLine = wBlank + ' ' + wLine + '\n'
				wSetLine.append( wIncLine )
				wOutLine = wOutLine + wIncLine
		
		#############################
		# ファイル追加書き込み
		CLS_File.sAddFile( inLogFile, wSetLine, inExist=False )
		
		wOutLine = wOutLine.strip()
		return wOutLine
Beispiel #2
0
    def sChk1HourTime(cls, inPath):
        #############################
        # 記録ファイルをロード
        w1HourTime = []
        wFilePath = inPath + gVal.DEF_STR_FILE['Chk1HourFile']
        if CLS_File.sReadFile(wFilePath, w1HourTime) != True:
            return False  #処理失敗

        try:
            w1HourTime = w1HourTime[0].split(',')
            wHour = w1HourTime[1]
        except:
            return False  #処理失敗

        #############################
        # PC時間を取得
        wGetTime = CLS_OSIF.sGetTime()
        if wGetTime['Result'] != True:
            return False  #処理失敗

        gVal.STR_TimeInfo['Object'] = wGetTime['Object']
        gVal.STR_TimeInfo['TimeDate'] = wGetTime['TimeDate']
        gVal.STR_TimeInfo['Hour'] = wGetTime['Hour']
        gVal.STR_TimeInfo['Week'] = wGetTime['Week']
        gVal.STR_TimeInfo['Result'] = True  #有効

        wGetDate = wGetTime['TimeDate'].split(" ")

        #############################
        # 時間が同じ=少なくとも1時間経ってないか?
        if w1HourTime[0] != "1900-01-01":
            if wHour == wGetTime['Hour']:
                gVal.STR_TimeInfo['OneHour'] = False
                return True
            else:
                gVal.STR_TimeInfo['OneHour'] = True

            if w1HourTime[0] == wGetDate[0]:
                gVal.STR_TimeInfo['OneDay'] = False
##				return True
            else:
                gVal.STR_TimeInfo['OneDay'] = True

        else:
            ##bot起動初回の場合は時間だけ保存する
            gVal.STR_TimeInfo['OneHour'] = False
            gVal.STR_TimeInfo['OneDay'] = False

        #############################
        # 時間をセーブ
        wTime = wGetTime['TimeDate'].split(" ")
        wTime = wTime[0] + ',' + wGetTime['Hour'] + ',' + wGetTime['Week']

        wSaveTime = []
        wSaveTime.append(wTime)
        if CLS_File.sWriteFile(wFilePath, wSaveTime) != True:
            return False  #処理失敗

        return True
Beispiel #3
0
    def sChangeTrafficUser(cls, inUsername):
        #############################
        # 名前の妥当性チェック
        wResUser = cls.sUserCheck(inUsername)
        ##	"Result"	: False,
        ##	"User"		: "",
        ##	"Domain"	: "",
        ##	"Reason"	: "",
        ##	"Registed"	: False,
        if wResUser['Result'] != True:
            return False  #不正

        #############################
        # 読み出し先初期化
        wTrafficUser = []

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['TrafficFile']
        if CLS_File.sReadFile(wFile_path, outLine=wTrafficUser) != True:
            return False  #失敗

        #############################
        # 計測ユーザか
        if inUsername not in wTrafficUser:
            return True  #対象外

        ##自分は抜いておく
        wTrafficUser.remove(inUsername)

        #############################
        # 同一ドメインの別ユーザを検索
        wUserList = cls.sGetUserList()
        wNewUser = None
        for wLine in wUserList:
            if wLine == inUsername:
                continue  #自分は除く

            wDomain = wLine.split("@")
            if wDomain[1] == wResUser['Domain']:
                wNewUser = wLine
                break

        if wNewUser == None:
            ##ありえない
            return False

        #############################
        # 切替
        wTrafficUser.append(wNewUser)

        #############################
        # ファイル書き込み (改行つき)
        wFile_path = gVal.DEF_STR_FILE['TrafficFile']
        if CLS_File.sWriteFile(wFile_path, wTrafficUser, inRT=True) != True:
            return False  #失敗

        return True  #正常
Beispiel #4
0
    def Set_FollowLists(self):
        #############################
        # 更新されてなければ抜ける
        if self.FLG_Update == False:
            return True

        wARR_SetFile = []
        #############################
        # フォロー一覧
        wKeyList = list(self.ARR_FollowTL.keys())
        for wUser in wKeyList:
            wLine = self.ARR_FollowTL[wUser] + gVal.DEF_DATA_BOUNDARY + wUser
            wARR_SetFile.append(wLine)

        #############################
        # フォローファイル書き込み (改行つき)
        wFile_path = self.Obj_Parent.CHR_User_path + gVal.DEF_STR_FILE[
            'FollowListFile']
        ##		if CLS_File.sWriteFile( wFile_path, self.ARR_FollowTL, inRT=True )!=True :
        if CLS_File.sWriteFile(wFile_path, wARR_SetFile, inRT=True) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a',
                "CLS_Follow: Set_FollowLists: Set follow list file is failed: "
                + wFile_path)
            return False  #失敗

        wARR_SetFile = []
        #############################
        # フォロワー一覧
        wKeyList = list(self.ARR_FollowerTL.keys())
        for wUser in wKeyList:
            wLine = self.ARR_FollowerTL[wUser] + gVal.DEF_DATA_BOUNDARY + wUser
            wARR_SetFile.append(wLine)

        #############################
        # フォロワーファイル書き込み (改行つき)
        wFile_path = self.Obj_Parent.CHR_User_path + gVal.DEF_STR_FILE[
            'FollowerListFile']
        ##		if CLS_File.sWriteFile( wFile_path, self.ARR_FollowerTL, inRT=True )!=True :
        if CLS_File.sWriteFile(wFile_path, wARR_SetFile, inRT=True) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a',
                "CLS_Follow: Set_FollowLists: Set follower list file is failed: "
                + wFile_path)
            return False  #失敗

        wStr = "フォローリスト更新あり: follow=" + str(len(
            self.ARR_FollowTL)) + " follower=" + str(len(self.ARR_FollowerTL))
        self.Obj_Parent.OBJ_Mylog.Log('b', wStr)
        return True  #成功
Beispiel #5
0
    def __getTrendPatt(self):
        #############################
        # 読み出し先初期化
        self.ARR_SendDomain = []
        wSendDomain = []  #解析パターンファイル

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['TrendTootFile']
        if CLS_File.sReadFile(wFile_path, outLine=wSendDomain) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a', "CLS_Trend: __getTrendPatt: TrendTootFile read failed: " +
                wFile_path)
            return False  #失敗

        #############################
        # パターンの詰め込み
        for wLine in wSendDomain:
            wLine = wLine.split(gVal.DEF_DATA_BOUNDARY)
            if len(wLine) != 2:
                continue  #フォーマットになってない
            if wLine[0].find("#") == 0:
                continue  #コメントアウト

            #############################
            # ドメイン
            if wLine[0] == "d":
                self.ARR_SendDomain.append(wLine[1])

        return True
Beispiel #6
0
    def __getLucibotVer(cls):
        if CLS_File.sExist(gVal.DEF_STR_FILE['Readme']) != True:
            ###readmeファイル消すなwww
            CLS_OSIF.sPrn(
                "CLS_Main_Console: __getLucibotVer: Readme file is not found: "
                + gVal.DEF_STR_FILE['Readme'])
            return False

        for wLine in open(gVal.DEF_STR_FILE['Readme'], 'r'):  #ファイルを開く
            #############################
            # 分解+要素数の確認
            wLine = wLine.strip()
            wGetLine = wLine.split("= ")
            if len(wGetLine) != 2:
                continue

            wGetLine[0] = wGetLine[0].replace("::", "")
            #############################
            # キーがあるか確認
            if wGetLine[0] not in gVal.STR_SystemInfo:
                continue

            #############################
            # キーを設定
            gVal.STR_SystemInfo[wGetLine[0]] = wGetLine[1]

        return
Beispiel #7
0
    def Set_CLData(self):
        #############################
        # 書き込みデータの作成
        wCLDataList = []

        wKeylist = list(self.ARR_CLData.keys())
        for wKey in wKeylist:
            if self.ARR_CLData[wKey]["Valid"] == False:
                continue  #無効データ

            wSetLine = self.ARR_CLData[wKey]["Kind"] + ","
            wSetLine = self.ARR_CLData[wKey]["Sended"] + ","
            wSetLine = wSetLine + str(self.ARR_CLData[wKey]["Hour"]) + ","
            wSetLine = wSetLine + str(self.ARR_CLData[wKey]["Minute"]) + ","
            wSetLine = wSetLine + self.ARR_CLData[wKey]["TootFile"]
            wCLDataList.append(wSetLine)

        #############################
        # ファイル書き込み (改行つき)
##		wFile_path = self.Obj_Parent.CHR_User_path + gVal.DEF_STR_FILE['CLDataFile']
        wFile_path = gVal.DEF_STR_FILE[
            'MasterConfig_path'] + gVal.DEF_STR_FILE['CLDataFile']
        if CLS_File.sWriteFile(wFile_path, wCLDataList, inRT=True) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a', "CLS_CircleToot: Set_CLData: CLDataFile read failed: " +
                wFile_path)
            return False  #失敗

        return True  #成功
Beispiel #8
0
    def Get_Anap(self):
        #############################
        # 読み出し先初期化
        self.ARR_AnapTL = {}
        wAnapList = []  #解析パターンファイル

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['PatternPTLFile']
        if CLS_File.sReadFile(wFile_path, outLine=wAnapList) != True:
            return False  #失敗

        #############################
        # データ枠の作成
        wIndex = 0
        for wLine in wAnapList:
            wLine = wLine.split(gVal.DEF_DATA_BOUNDARY)
            if len(wLine) == 2:
                wLine.append("")  #ダミー
            if len(wLine) != 3:
                continue  #フォーマットになってない
            if wLine[0].find("#") == 0:
                continue  #コメントアウト

            self.ARR_AnapTL.update({wIndex: ""})
            self.ARR_AnapTL[wIndex] = {}
            self.ARR_AnapTL[wIndex].update({"Kind": wLine[0]})
            self.ARR_AnapTL[wIndex].update({"Pattern": wLine[1]})
            self.ARR_AnapTL[wIndex].update({"File": wLine[2]})
            wIndex += 1

        ###なしでもOKとする
        return True  #成功
Beispiel #9
0
    def CnfMasterConfig(self):
        #############################
        # ファイルの存在チェック
        if CLS_File.sExist(gVal.DEF_STR_FILE['MasterConfig']) != True:
            ###ありえない
            CLS_OSIF.sPrn(
                "CLS_Config: CnfMasterConfig: MasterConfig file is not found : "
                + gVal.DEF_STR_FILE['MasterConfig'])
            return False  #ない

        #############################
        # 選択画面を表示する
        self.MasterConfig_Disp()
        wSelect = self.__cnfMasterConfig_SelectDisp()
        if wSelect == 'c':
            ###変更してセーブ
            self.__cnfMasterConfig_Change()
            self.sSetMasterConfig()
            CLS_OSIF.sPrn("変更した内容でMaster環境情報をセーブしました。" + '\n')
        elif wSelect == 's':
            ###セーブ
            CLS_Config.sSetMasterConfig()
            CLS_OSIF.sPrn("Master環境情報をセーブしました。" + '\n')

        return True
Beispiel #10
0
    def __openLock(cls, inPath):
        wLock = []
        wFilePath = inPath + gVal.DEF_STR_FILE['LockFile']
        if CLS_File.sReadFile(wFilePath, wLock) != True:
            return "3"  #失敗=排他あり にしてる

        return wLock[0]
Beispiel #11
0
    def sViewDisp(cls, inDisp):
        #############################
        # ディスプレイファイルの確認
        wKeylist = gVal.DEF_STR_DISPFILE.keys()
        if inDisp not in wKeylist:
            ###キーがない(指定ミス)
            CLS_OSIF.sPrn(
                "CLS_Main_Console: __viewDisp: Display key is not found: inDisp= "
                + inDisp)
            return False

        if CLS_File.sExist(gVal.DEF_STR_DISPFILE[inDisp]) != True:
            ###ファイルがない...(消した?)
            CLS_OSIF.sPrn(
                "CLS_Main_Console: __viewDisp: Display file is not found: " +
                gVal.DEF_STR_DISPFILE[inDisp])
            return False

        #############################
        # 画面クリア
        CLS_OSIF.sDispClr()

        #############################
        # 中身表示
        wStr = ""
        for wLine in open(gVal.DEF_STR_DISPFILE[inDisp], 'r'):  #ファイルを開く
            wStr = wStr + wLine

        CLS_OSIF.sPrn(wStr)
        return True
Beispiel #12
0
    def sCheckTrafficUser(cls, inUsername):
        #############################
        # 名前の妥当性チェック
        wResUser = cls.sUserCheck(inUsername)
        ##	"Result"	: False,
        ##	"User"		: "",
        ##	"Domain"	: "",
        ##	"Reason"	: "",
        ##	"Registed"	: False,
        if wResUser['Result'] != True:
            return False  #不正

        #############################
        # 読み出し先初期化
        wTrafficUser = []

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['TrafficFile']
        if CLS_File.sReadFile(wFile_path, outLine=wTrafficUser) != True:
            return False  #失敗

        #############################
        # 対象ユーザか
        if inUsername in wTrafficUser:
            return True  #対象外

        return False  #対象ではない
Beispiel #13
0
	def __setTrafficUser( self, inUserList ):
		#############################
		# ファイル書き込み (改行つき)
		wFile_path = gVal.DEF_STR_FILE['TrafficFile']
		if CLS_File.sWriteFile( wFile_path, inUserList, inRT=True )!=True :
			return False	#失敗
		
		return True			#成功
Beispiel #14
0
    def __recovery_TBL_TRAFFIC_DATA(self):
        #############################
        # 読み出し先初期化
        wTrafficUser = []

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['TrafficFile']
        if CLS_File.sReadFile(wFile_path, outLine=wTrafficUser) != True:
            wStr = "CLS_Regist : __recovery_TBL_TRAFFIC_DATA: TrafficFile read is failed: " + gVal.DEF_STR_FILE[
                'TrafficFile']
            CLS_OSIF.sPrn(wStr)
            return False

        #############################
        # DBの接続
        wOBJ_DB = CLS_PostgreSQL_Use(gVal.DEF_STR_FILE['DBinfo_File'])
        wRes = wOBJ_DB.GetIniStatus()
        if wRes['Result'] != True:
            ###失敗
            wStr = "CLS_Regist : __recovery_TBL_TRAFFIC_DATA: DB connect error: " + wRes[
                'Reason']
            CLS_OSIF.sPrn(wStr)
            return False

        #############################
        # 修復
        for wLine in wTrafficUser:
            wDomain = wLine.split("@")
            if len(wDomain) != 2:
                wStr = "CLS_Regist : __recovery_TBL_TRAFFIC_DATA: Traffic user is invalid: user="******"insert into TBL_TRAFFIC_DATA values (" + \
               "'" + wDomain + "'," + \
               "0," + \
               "-1," + \
               "-1," + \
               "-1," + \
               "0" + \
               ") ;"
            wDBRes = wOBJ_DB.RunQuery(wQuery)
            wDBRes = wOBJ_DB.GetQueryStat()
            if wDBRes['Result'] != True:
                ##失敗
                wStr = "CLS_Regist : __recovery_TBL_TRAFFIC_DATA: DB insert is failed: " + wDBRes[
                    'Reason']
                CLS_OSIF.sPrn(wStr)
                wOBJ_DB.Close()
                return False

        #############################
        # DBのクローズ
        wOBJ_DB.Close()
        return True
Beispiel #15
0
    def Set_RateTwitterTL(self):
        #############################
        # ファイル書き込み (改行つき)
        wFile_path = gVal.DEF_MASTERCONFIG + gVal.DEF_STR_FILE['TweetFile']
        if CLS_File.sWriteFile(wFile_path, self.ARR_UpdateTL,
                               inRT=True) != True:
            return False  #失敗

        return True  #成功
Beispiel #16
0
    def sGetUserList(cls):
        wList = CLS_File.sLs(gVal.DEF_USERDATA_PATH)

        #############################
        # masterConfigを抜く
        if gVal.DEF_MASTERCONFIG_NAME in wList:
            wList.remove(gVal.DEF_MASTERCONFIG_NAME)

        return wList
Beispiel #17
0
	def __init__( self, inPath=None ):
		#############################
		# ログフォルダの存在チェック
		if CLS_File.sExist( inPath )!=True :
			self.CHR_LogPath = ""
			return 		#ない
		
		self.CHR_LogPath = inPath
		return
Beispiel #18
0
    def Set_RateLTL(self):
        #############################
        # ファイル書き込み (改行つき)
        wFile_path = self.Obj_Parent.CHR_User_path + gVal.DEF_STR_FILE[
            'Rate_LTLFile']
        if CLS_File.sWriteFile(wFile_path, self.ARR_UpdateTL,
                               inRT=True) != True:
            return False  #失敗

        return True  #成功
Beispiel #19
0
    def __getTwitterPatt(self):
        #############################
        # 読み出し先初期化
        self.ARR_AnapTL = {}
        wARR_TwitterReader = []  #解析パターンファイル

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['TwetterReaderFile']
        if CLS_File.sReadFile(wFile_path, outLine=wARR_TwitterReader) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a',
                "CLS_TwitterReader: __getTwitterPatt: TwetterReaderFile read failed: "
                + wFile_path)
            return False  #失敗

        #############################
        # パターンの詰め込み
        wIndex = 0
        for wLine in wARR_TwitterReader:
            wLine = wLine.split(gVal.DEF_DATA_BOUNDARY)
            if len(wLine) == 2:
                ##				#############################
                ##				# 範囲
                ##				if wLine[0]=="r" :
                ##					if wLine[1] in self.DEF_SENDRANGE :
                ##						self.CHR_SendRange = wLine[1]
                ##
                ##				elif wLine[0]=="T" and self.CHR_TrendSender=="" :
                #############################
                # トレンド送信ユーザ
                if wLine[0] == "T" and self.CHR_TrendSender == "":
                    self.CHR_TrendSender = wLine[1]

                continue

##			if len(wLine)!=4 :
            if len(wLine) != 5:
                continue  #フォーマットになってない
            if wLine[0].find("#") == 0:
                continue  #コメントアウト

            #############################
            # アカウント
            if wLine[0] == "P":
                self.ARR_AnapTL.update({wIndex: ""})
                self.ARR_AnapTL[wIndex] = {}
                self.ARR_AnapTL[wIndex].update({"user": wLine[1]})
                self.ARR_AnapTL[wIndex].update({"patt": wLine[2]})
                self.ARR_AnapTL[wIndex].update({"send": wLine[3]})
                self.ARR_AnapTL[wIndex].update({"tags": wLine[4]})
                wIndex += 1

        return True
Beispiel #20
0
    def Get_RateTwitterTL(self):
        #############################
        # 読み出し先初期化
        self.ARR_RateTL = []

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_MASTERCONFIG + gVal.DEF_STR_FILE['TweetFile']
        if CLS_File.sReadFile(wFile_path, outLine=self.ARR_RateTL) != True:
            return False  #失敗

        return True  #成功
Beispiel #21
0
    def __get_Rip(self, inFilename):
        #############################
        # 読み出し先初期化
        wARR_Load = []

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['Toot_path'] + inFilename
        if CLS_File.sReadFile(wFile_path, outLine=wARR_Load) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a',
                "CLS_LookPTL: __get_Rip: File read is failure: " + wFile_path)
            return []
        if len(wARR_Load) == 0:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a',
                "CLS_LookPTL: __get_Rip: The file is empty: " + wFile_path)
            return []

        #############################
        # 候補一覧を取得する
        wARR_RipKouho = []
        for wLine in wARR_Load:
            ###文字がない行
            if len(wLine) == 0:
                continue
            ###コメントアウト
            if wLine.find("#") == 0:
                continue
            ###フォーマット
            wLine = wLine.split(gVal.DEF_DATA_BOUNDARY)
            if len(wLine) != 2:
                continue
            wARR_RipKouho.append(wLine)

        if len(wARR_RipKouho) == 0:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a', "CLS_LookPTL: __get_Rip: Riply kouho is zero")
            return []

        #############################
        # 乱数の取得
        wRand = CLS_OSIF.sGetRand(len(wARR_RipKouho))
        if wRand < 0:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a', "CLS_LookPTL: __get_Rip: sGetRand error: " + str(wRand))
            return []

        #############################
        # リプを出力
        wLine = wARR_RipKouho[wRand]
        return wLine
Beispiel #22
0
    def Get_RateLTL(self):
        #############################
        # 読み出し先初期化
        self.ARR_RateTL = []

        #############################
        # ファイル読み込み
        wFile_path = self.Obj_Parent.CHR_User_path + gVal.DEF_STR_FILE[
            'Rate_LTLFile']
        if CLS_File.sReadFile(wFile_path, outLine=self.ARR_RateTL) != True:
            return False  #失敗

        return True  #成功
Beispiel #23
0
    def __testLog(self, inKind, inAccount):
        #############################
        # TestLog有効か
        if gVal.STR_CronInfo[inKind] != True:
            ##			return		#ログ無効
            return None  #ログ無効

        wExeName = inKind.split(".")

        #############################
        # 時間取得
        ##		wTime = CLS_OSIF.sGetTime()
        ##		wDate = wTime['TimeDate'].split(" ")
        ##		if wDate['Result']!=True :
        wTime = CLS_OSIF.sGetTime()
        if wTime['Result'] != True:
            return None  #時間取得失敗

        #############################
        # パスの生成
##		wDate = wTime['TimeDate'].split(" ")
##		wDate = wDate.split("-")
        wDate = wTime['TimeDate'].split(" ")
        wDate = wDate[0].split("-")
        wLogFile = gVal.DEF_STR_FILE['MasterLog_path'] + wDate[0] + wDate[
            1] + "_" + inAccount + ".log"

        #############################
        # 書き込みデータを作成
        wSetLine = []
        wLine = wTime['TimeDate'] + " cron run: " + inKind + '\n'
        wSetLine.append(wLine)

        #############################
        # テストログ書き込み
        ##		wLogFile = gVal.STR_CronInfo['Log_path'] + wDate[0] + "_cron" + wExeName[0] + "_" + inAccount + ".log"
        CLS_File.sAddFile(wLogFile, wSetLine, inExist=False)
        return wLogFile
Beispiel #24
0
    def __setDomainsFile(self):
        #############################
        # ファイル書き込み (改行つき)
        ##		wFile_path = gVal.DEF_STR_FILE['MstdnDomains_File']
        wFile_path = gVal.DEF_STR_FILE[
            'MasterConfig_path'] + gVal.DEF_STR_FILE['MstdnDomains_File']
        if CLS_File.sWriteFile(wFile_path, self.ARR_Domains,
                               inRT=True) != True:
            ##			wStr = "CLS_DBedit: __setDomainsFile: MstdnDomains_File write is failed: " + gVal.DEF_STR_FILE['MstdnDomains_File']
            wStr = "CLS_DBedit: __setDomainsFile: MstdnDomains_File write is failed: " + wFile_path
            CLS_OSIF.sPrn(wStr)
            return False  #失敗

        return True  #成功
Beispiel #25
0
    def GetWordREM(self):
        #############################
        # 初期化
        gVal.STR_WordREM = []

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['WordREMFile']
        if CLS_File.sReadFile(wFile_path, outLine=gVal.STR_WordREM) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a', "CLS_WordCorr: GetWordREM: WordREM file read failed: " +
                wFile_path)
            return False  #失敗

        return True  #成功
Beispiel #26
0
    def Get_Anap(self):
        #############################
        # 読み出し先初期化
        self.ARR_AnapTL = {}
        self.ARR_NoBoost = []
        wAnapList = []  #解析パターンファイル

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['HTLBoostFile']
        if CLS_File.sReadFile(wFile_path, outLine=wAnapList) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a', "CLS_LookHTL: Get_Anap: HTLBoostFile read failed: " +
                wFile_path)
            return False  #失敗

        #############################
        # データ枠の作成
        wIndex = 0
        for wLine in wAnapList:
            wLine = wLine.split(gVal.DEF_DATA_BOUNDARY)
            if len(wLine) == 3:
                #旧フォーマット
                wLine.append("")
            if len(wLine) != 4:
                continue  #フォーマットになってない
            if wLine[0].find("#") == 0:
                continue  #コメントアウト

            if wLine[0] == "n":  #ブースト外
                self.ARR_NoBoost.append(wLine[1])
                continue

            self.ARR_AnapTL.update({wIndex: ""})
            self.ARR_AnapTL[wIndex] = {}
            self.ARR_AnapTL[wIndex].update({"Kind": wLine[0]})
            self.ARR_AnapTL[wIndex].update({"Tag": wLine[1]})
            self.ARR_AnapTL[wIndex].update({"Fulluser": wLine[2]})
            self.ARR_AnapTL[wIndex].update({"TwitterTags": wLine[3]})
            wIndex += 1

        if len(self.ARR_AnapTL) == 0:
            self.Obj_Parent.OBJ_Mylog.Log(
                'c', "CLS_LookHTL: Get_Anap: HTLBoostFile in none pattern: " +
                wFile_path)
            return False  #パターンなし

        return True
Beispiel #27
0
    def sSetMasterConfig(cls):
        #############################
        # 書き込みデータを作成
        wSetLine = []
        wKeylist = gVal.STR_MasterConfig.keys()
        for iKey in wKeylist:
            wLine = iKey + "=" + str(gVal.STR_MasterConfig[iKey]) + '\n'
            wSetLine.append(wLine)

        #############################
        # ファイル上書き書き込み
        if CLS_File.sWriteFile(gVal.DEF_STR_FILE['MasterConfig'],
                               wSetLine) != True:
            return False  #失敗

        return True
Beispiel #28
0
    def __getDomainsFile(self):
        #############################
        # 読み出し先初期化
        self.ARR_Domains = []

        #############################
        # ファイル読み込み
        ##		wFile_path = gVal.DEF_STR_FILE['MstdnDomains_File']
        wFile_path = gVal.DEF_STR_FILE[
            'MasterConfig_path'] + gVal.DEF_STR_FILE['MstdnDomains_File']
        if CLS_File.sReadFile(wFile_path, outLine=self.ARR_Domains) != True:
            ##			wStr = "CLS_DBedit: __getDomainsFile: MstdnDomains_File read is failed: " + gVal.DEF_STR_FILE['MstdnDomains_File']
            wStr = "CLS_DBedit: __getDomainsFile: MstdnDomains_File read is failed: " + wFile_path
            CLS_OSIF.sPrn(wStr)
            return False  #失敗

        return True  #成功
Beispiel #29
0
    def __getTrafficPatt(self):
        #############################
        # 読み出し先初期化
        self.CHR_SendRange = self.DEF_SENDRANGE
        self.ARR_SendDomain = []
        wSendDomain = []  #解析パターンファイル
        ##		wFLG_Range  = False

        #############################
        # ファイル読み込み
        wFile_path = gVal.DEF_STR_FILE['TrafficTootFile']
        if CLS_File.sReadFile(wFile_path, outLine=wSendDomain) != True:
            self.Obj_Parent.OBJ_Mylog.Log(
                'a',
                "CLS_Traffic: __getTrafficPatt: TrafficTootFile read failed: "
                + wFile_path)
            return False  #失敗

        #############################
        # パターンの詰め込み
        for wLine in wSendDomain:
            wLine = wLine.split(gVal.DEF_DATA_BOUNDARY)
            if len(wLine) != 2:
                continue  #フォーマットになってない
            if wLine[0].find("#") == 0:
                continue  #コメントアウト

            #############################
            # 公開範囲
            if wLine[0] == "r":
                if CLS_UserData.sCheckRange(wLine[1]) == True:
                    self.CHR_SendRange = wLine[1]
                    wFLG_Range = True
                    continue

            #############################
            # ドメイン
            if wLine[0] == "d":
                self.ARR_SendDomain.append(wLine[1])

##		if wFLG_Range==False :
##			###デフォルトだと指定あるのでいちお入れる
##			self.Obj_Parent.OBJ_Mylog.Log( 'c', "__getTrafficPatt: トラヒック送信の公開範囲なし(内部設定=" + self.DEF_SENDRANGE + ")" )

        return True
Beispiel #30
0
    def sGetUserPath(cls, inFulluser):
        #############################
        # 応答形式の取得
        #   "Result" : False, "Reason" : None, "Responce" : None
        wRes = CLS_OSIF.sGet_Resp()

        #############################
        # フォルダの存在チェック
        wFilename = gVal.DEF_USERDATA_PATH + inFulluser + "/"
        ##		if CLS_File.sExist( wFilename )!=True :
        ##			wRes['Reason'] = "CLS_UserData: sGetUserPath: User Folder is not found: " + wFilename
        ##			return wRes
        if CLS_File.sExist(wFilename) == True:
            wRes['Result'] = True

        wRes['Responce'] = wFilename
        ##		wRes['Result'] = True
        return wRes