def GetList(self, inCommand=None): ############################# # 応答形式の取得 # "Result" : False, "Reason" : None, "Responce" : None wRes = CLS_OSIF.sGet_Resp() ############################# # カレントパスを取得 wCHR_Curr = CLS_OSIF.sGetCwd() ############################# # cronが有効か? if self.FLG_Cron != True: wRes['Reason'] = " GetJoblist: Cron disabled" return wRes ############################# # jobの文字列リスト化 wRes['Responce'] = {} wRes['Responce'].update({'isJob': False, 'List': []}) for wJob in self.OBJ_Cron: wJobStr = str(wJob) if wJobStr.find(wCHR_Curr) < 0: #同一カレントか continue if inCommand != None: #ダブってるJobがあればTrue if wJobStr.find(inCommand) >= 0: wRes['Responce']['isJob'] = True wRes['Responce']['List'].append(str(wJob)) wRes['Result'] = True return wRes
def __init__(self): ############################# # cron control生成 self.OBJ_CronCtrl = CLS_CronCtrl(gVal.STR_CronInfo['CronName']) if self.OBJ_CronCtrl.Check() != True: return #controlが出してくれる ############################# # commandテンプレートの組み立て self.Command_Temp = "cd " + CLS_OSIF.sGetCwd() + "; python3 " ## ## self.FLG_CronCtrl = True #有効 return
def Run(self): ############################# # 応答形式の取得 # "Result" : False, "Reason" : None, "Responce" : None wRes = CLS_OSIF.sGet_Resp() ############################# # 引数取得 wArg = CLS_OSIF.sGetArg() if len(wArg) == 3: #テストモードか if wArg[2] == gVal.DEF_TEST_MODE: gVal.FLG_Test_Mode = True elif len(wArg) != 2: #引数が足りない wStr = "CLS_CronTest: Argument deficiency: argument=" + str(wArg) CLS_OSIF.sPrn(wStr) #メールに頼る return wRes wKind = wArg[0] wAccount = wArg[1] ## ############################# ## # Backgroundのチェックは別でやる ## if wKind==gVal.DEF_CRON_BACK and wAccount==gVal.DEF_CRON_ACCOUNT_BACKGROUND : ## wRes = self.__backgroundTest( outRes=wRes ) ## return wRes ############################# # 1.jobチェック # 実行ファイルチェック # ユーザ登録チェック(Master、Subの場合) wCLS_Botjob = CLS_Botjob() wRes = wCLS_Botjob.isJob(wKind, wAccount) if wRes['Result'] != True: wStr = "CLS_CronTest: Job check NG: " + wRes['Reason'] CLS_OSIF.sPrn(wStr) #メールに頼る return wRes if wRes['Responce']['isJob'] == False and gVal.FLG_Test_Mode == False: ## wStr = "CLS_CronTest: Job is not found: kind=" + wKind + ": account=" + wAccount wStr = "CLS_CronTest: Job is not found: kind=" + wKind + ": account=" + wAccount + " current: " + CLS_OSIF.sGetCwd( ) CLS_OSIF.sPrn(wStr) #メールに頼る wRes['Result'] = False #テストはNG return wRes wFlg_ok = True ############################# # 2.データフォルダのチェック if CLS_File.sExist(gVal.DEF_USERDATA_PATH) != True: wFlg_ok = False ############################# # 3.Master環境情報の読み込み if CLS_Config.sGetMasterConfig() != True: wFlg_ok = False ############################# # Master環境情報に異常はないか if wFlg_ok == False: ## wRes = wCLS_Botjob.Stop() #全cronを削除する ## if wRes['Result']!=True : ## wStr = "CLS_CronTest: Cron stop failed: " + wRes['Reason'] ## CLS_OSIF.sPrn( wStr ) #メールに頼る ## ## wStr = "Master環境情報に異常があったため、" + gVal.STR_SystemInfo['Client_Name'] ## wStr = wStr + "で登録した全cronを停止しました。" wStr = "Master環境情報に異常があったため、処理を中止します。" CLS_OSIF.sPrn(wStr) #メールに頼る wRes['Result'] = False #テストはNG return wRes ############################# # 4.Userフォルダチェック wRes = CLS_UserData.sGetUserPath(wAccount) if wRes['Result'] != True: wRes = wCLS_Botjob.Del(wKind, wAccount) #cronを削除する if wRes['Result'] != True: wStr = "CLS_CronTest: Cron delete failed: " + wRes['Reason'] CLS_OSIF.sPrn(wStr) #メールに頼る wStr = "Userフォルダが存在しないため、" + wAccount wStr = wStr + "のcronを停止しました。" CLS_OSIF.sPrn(wStr) #メールに頼る wRes['Result'] = False #テストはNG return wRes wUserPath = wRes['Responce'] ## ############################# ## # 5.User環境情報の読み込み ## wRes = CLS_Config.sGetUserConfig( wAccount ) ## if wRes['Result']!=True : ## wRes = wCLS_Botjob.Del( wKind, wAccount ) #cronを削除する ## if wRes['Result']!=True : ## wStr = "CLS_CronTest: Cron delete failed: " + wRes['Reason'] ## CLS_OSIF.sPrn( wStr ) #メールに頼る ## ## wStr = "User環境情報に異常があったため、" + wAccount ## wStr = wStr + "のcronを停止しました。" ## CLS_OSIF.sPrn( wStr ) #メールに頼る ## ## wRes['Result'] = False #テストはNG ## return wRes ############################# # 5.実行権限チェック wFlg_Authority = True ############################# # コマンドの組み立て if wKind == gVal.DEF_CRON_MASTER: # Masuer User以外か if wAccount != gVal.STR_MasterConfig['MasterUser']: wFlg_Authority = False ## elif wKind==gVal.DEF_CRON_BACK : # Background以外か ## if wAccount!=gVal.DEF_CRON_ACCOUNT_BACKGROUND : ## wFlg_Authority = False elif wKind == gVal.DEF_CRON_SUB: # Sub以外か ## if wAccount==gVal.STR_MasterConfig['MasterUser'] or \ ## wAccount==gVal.DEF_CRON_ACCOUNT_BACKGROUND : if wAccount == gVal.STR_MasterConfig['MasterUser']: wFlg_Authority = False else: ###ここではありえない wFlg_Authority = False if wFlg_Authority == False: wRes = wCLS_Botjob.Del(wKind, wAccount) #cronを削除する if wRes['Result'] != True: wStr = "CLS_CronTest: Cron delete failed: " + wRes['Reason'] CLS_OSIF.sPrn(wStr) #メールに頼る wStr = "実行権限に問題があったため、" + wAccount wStr = wStr + "のcronを停止しました。" CLS_OSIF.sPrn(wStr) #メールに頼る wRes['Result'] = False #テストはNG return wRes # ここまででtestは合格してる ############################# ############################# # 6.testログ self.__testLog(wKind, wAccount) wRes['Responce'] = {} wRes['Responce'].update({ "Kind": wKind, "Account": wAccount, "User_path": wUserPath }) wRes['Result'] = True return wRes