Beispiel #1
0
    def sView_Sysinfo(cls):

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

        #############################
        # ヘッダ表示
        wStr = "--------------------" + '\n'
        wStr = wStr + " システム情報" + '\n'
        wStr = wStr + "--------------------" + '\n'

        #############################
        # 時間の取得
        wRes = CLS_OSIF.sGetTime()
        if wRes['Result'] == True:
            wStr = wStr + wRes['TimeDate'] + '\n'

        #############################
        # 情報組み立て
        wStr = wStr + "Name= " + gVal.STR_SystemInfo['BotName'] + '\n'
        wStr = wStr + "Date= " + gVal.STR_SystemInfo['BotDate'] + '\n'
        wStr = wStr + "Ver = " + gVal.STR_SystemInfo['Version'] + '\n'
        wStr = wStr + "Admin= " + gVal.STR_SystemInfo['Admin'] + '\n'
        wStr = wStr + "github= " + gVal.STR_SystemInfo['github'] + '\n'

        wStr = wStr + "Python= " + str(gVal.STR_SystemInfo['PythonVer']) + '\n'
        wStr = wStr + "HostName= " + gVal.STR_SystemInfo['HostName'] + '\n'

        #############################
        # コンソールに表示
        CLS_OSIF.sPrn(wStr)
        return
Beispiel #2
0
	def MasterLog( self, inAccount, inMsg, inView=False, inHard=False ):
		#############################
		# 時間を取得
		wTD = CLS_OSIF.sGetTime()
		if wTD['Result']!=True :
			###時間取得失敗  時計壊れた?
			CLS_OSIF.sPrn( inMsg )
			return
		wDate = wTD['TimeDate'].split(" ")
		
		#############################
		# ファイルパスを作成する
		wDate = self.CHR_TimeDate.split(" ")
		wDate = wDate.split("-")
		
		if inHard==False :
			### Masterログ
			wLogFile = gVal.DEF_STR_FILE['MasterLog_path'] + wDate[0] + wDate[1] + "_" + inAccount + ".log"
		else :
			### ハードログ
			wLogFile = gVal.DEF_STR_FILE['MasterLog_path'] + wDate[0] + wDate[1] + "_hard" + ".log"
		
		#############################
		# ファイルへ書き出す
		wOutLog = self.__write( wLogFile, wDate, inMsg )
		
		#############################
		# コンソールに表示する
		# = システムログに出る
		if inView==True :
			CLS_OSIF.sPrn( wOutLog )
		
		return
Beispiel #3
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 #4
0
	def Log( self, inLevel, inMsg, inView=False ):
		#############################
		# チェック
		if self.CHR_LogPath==None :
			### パスが無設定
			CLS_OSIF.sPrn( inMsg )
			return
		
		#############################
		# ログレベル:LogLevel
		#  a:全てのログを記録       (LevelA,B,C)
		#  b:重要なログと気になるログを記録(LevelA,Bのみ、LevelCは記録しない)
		#  c:重要なログだけ記録      (LevelAログのみ、LevelB,Cは記録しない)
		
		#############################
		# 設定されたログレベルが適当でなければ
		# 'a'を設定しなおす
		if inLevel != 'a' and inLevel != 'b' and inLevel != 'c' :
			wLevel = 'a'
		else :
			wLevel = inLevel
		
		#############################
		# ログレベルで出力が有効か
		if gVal.STR_MasterConfig['LogLevel'] == 'c' and ( wLevel == 'b' or wLevel == 'c' ) :
			return
		
		if gVal.STR_MasterConfig['LogLevel'] == 'b' and wLevel == 'c' :
			return
		
		###※以下ログ出力
		#############################
		# 時間を取得
		wTD = CLS_OSIF.sGetTime()
		if wTD['Result']!=True :
			###時間取得失敗  時計壊れた?
			CLS_OSIF.sPrn( inMsg )
			return
		wDate = wTD['TimeDate'].split(" ")
		
##		#############################
##		# パスが無設定 or 時計異常?
##		if self.CHR_LogPath=="" or wDate[0]=="" :
##			###時間取得失敗  時計壊れた?
##			CLS_OSIF.sPrn( inMsg )
##			return
		
		#############################
		# ファイルへ書き出す
		wLogFile = self.CHR_LogPath + wDate[0] + ".log"
		wOutLog = self.__write( wLogFile, wDate, inMsg )
		
		#############################
		# コンソールに表示する
		# = システムログに出る
		if inView==True :
			CLS_OSIF.sPrn( wOutLog )
		
		return
Beispiel #5
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 #6
0
	def Run(self):
		#############################
		# 処理開始の確認
		wStr = "ログのアーカイブを開始します。" + '\n'
		wStr = wStr + "よろしいですか?(y/N)=> "
		wRes = CLS_OSIF.sInp( wStr )
		if wRes!="y" :
			CLS_OSIF.sPrn( "処理を中止しました。" )
			return
		
		#############################
		# ユーザフォルダのアーカイブリスト 作成
		wARR_UserList = CLS_UserData.sGetUserList()
		wARR_ArciveList = []
		wARR_DeleteList = {}
		wIndex = 0
		for wLine in wARR_UserList :
			#############################
			# パス生成
			wPath = gVal.DEF_USERDATA_PATH + wLine + "/log/"
			wARR_ArciveList.append( wPath )
			
			#############################
			# ファイル一覧生成
			wFileList = CLS_File.sFs( wPath )
			wDelList = []
			for wFilePath in wFileList :
##				wFilePath = wPath + wFilePath
				wARR_ArciveList.append( wFilePath )
				wDelList.append( wFilePath )
			
			wARR_DeleteList.update({ wIndex : wDelList })
			wIndex += 1
		
		#############################
		# masterConfigフォルダ 追加
		wPath = gVal.DEF_USERDATA_PATH + gVal.DEF_MASTERCONFIG_NAME + "/log/"
		wARR_ArciveList.append( wPath )
		
		wFileList = CLS_File.sFs( wPath )
		wDelList = []
		for wFilePath in wFileList :
##			wFilePath = wPath + wFilePath
			wARR_ArciveList.append( wFilePath )
			wDelList.append( wFilePath )
		
##		wARR_DeleteList.update({ wIndex : wDelList })
##		wIndex += 1
		
		#############################
		# 各カレントの削除一覧から最後尾を抜く
		wKeyList = wARR_DeleteList.keys()
		for wKey in wKeyList :
			if len(wARR_DeleteList[wKey])>=2 :
				del wARR_DeleteList[wKey][-1]
		
		#############################
		# アーカイブ名の作成
		
		#############################
		# 時間を取得
		wTD = CLS_OSIF.sGetTime()
		if wTD['Result']!=True :
			###時間取得失敗  時計壊れた?
			CLS_OSIF.sPrn( "時間取得失敗。処理を中止しました。" )
			return
		wDate = wTD['TimeDate'].split(" ")
		
		#############################
		# ファイルパスを作成する
##		wLogFile = gVal.DEF_STR_FILE['MasterLog_path'] + "logs" + wDate[0] + wDate[1] + ".zip"
		wNDate = wDate[0].replace( "-", "" )
		wNTime = wDate[1].replace( ":", "" )
		wFileName = "logs_" + wNDate + "_" + wNTime + ".zip"
		wLogFile = gVal.DEF_STR_FILE['MasterConfig_path'] + wFileName
		
		CLS_OSIF.sPrn( '\n' + "アーカイブ実行中..." )
		#############################
		# アーカイブ実行
###		print( "xx1: " + wLogFile )
###		print( "xx2: " + str(wARR_ArciveList) )
		if CLS_File.sFolderArcive( wLogFile, wARR_ArciveList )!=True :
			CLS_OSIF.sPrn( "アーカイブ失敗。処理を中止しました。" )
			return
		
		CLS_OSIF.sPrn( '\n' + "古いログを削除中..." )
		#############################
		# 古いログを削除
		wKeyList = wARR_DeleteList.keys()
		for wKey in wKeyList :
			for wPath in wARR_DeleteList[wKey] :
###				print( wPath )
				if CLS_File.sRemove( wPath )!=True :
					CLS_OSIF.sPrn( "削除失敗。処理を中止しました。" )
					break
		
		CLS_OSIF.sPrn( "処理が完了しました。" )
		return