コード例 #1
0
def addCommonPackageInfo(lastPackage, package, writeTar):
    # 加入updateInfo.json和前一次的安装json
    lastInfos = {}
    lastInfos["fileInfos"] = {}
    lastInfos["xtDir"] = package.machine.xtDir
    if lastPackage is not None:
        for detail in lastPackage.files:
            lastInfos["fileInfos"][detail.filePath] = detail.toDict()
    jsonInfo = json.dumps(lastInfos, indent=4)
    jsonInfo = replaceStr(jsonInfo, {"xtDir": package.machine.xtDir})
    addfilefromstring(writeTar, "lastUpdate.json", jsonInfo)

    # updateInfo
    infos = {}
    infos["fileInfos"] = {}
    # 写入产生信息
    infos["xtDir"] = package.machine.xtDir
    infos["packageName"] = package.version
    infos["branches"] = package.branches
    for detail in package.files:
        infos["fileInfos"][detail.filePath] = detail.toDict()
    jsonInfo = json.dumps(infos, indent=4)
    jsonInfo = replaceStr(jsonInfo, {"xtDir": package.machine.xtDir})
    addfilefromstring(writeTar, "update.json", jsonInfo)

    localDir = os.path.dirname(os.path.abspath(__file__))
    files = ["update.sh", "Deploy.py", "README"]
    for file in files:
        path = localDir + "/../deploy/" + file
        addfile(writeTar, file, path)
コード例 #2
0
ファイル: RemoteDeploy.py プロジェクト: NolanZhao/TTEngine
def addCommonPackageInfo(lastPackage, package, writeTar):
    # 加入updateInfo.json和前一次的安装json
    lastInfos = {}
    lastInfos["fileInfos"] = {}
    lastInfos["xtDir"] = package.machine.xtDir
    if lastPackage is not None:
        for detail in lastPackage.files:
            lastInfos["fileInfos"][detail.filePath] = detail.toDict()
    jsonInfo = json.dumps(lastInfos, indent=4)
    jsonInfo = replaceStr(jsonInfo, {"xtDir": package.machine.xtDir})
    addfilefromstring(writeTar, "lastUpdate.json", jsonInfo)

    # updateInfo
    infos = {}
    infos["fileInfos"] = {}
    # 写入产生信息
    infos["xtDir"] = package.machine.xtDir
    infos["packageName"] = package.version
    infos["branches"] = package.branches
    for detail in package.files:
        infos["fileInfos"][detail.filePath] = detail.toDict()
    jsonInfo = json.dumps(infos, indent=4)
    jsonInfo = replaceStr(jsonInfo, {"xtDir": package.machine.xtDir})
    addfilefromstring(writeTar, "update.json", jsonInfo)

    localDir = os.path.dirname(os.path.abspath(__file__))
    files = ["update.sh", "Deploy.py", "README"]
    for file in files:
        path = localDir + "/../deploy/" + file
        addfile(writeTar, file, path)
コード例 #3
0
ファイル: models.py プロジェクト: NolanZhao/TTEngine
 def getRunScript(self, os, dir):
     path = None
     script = None
     if self.runType == RUN_TYPE_MASTER_ALWAYS:
         if not isWindows(os):
             path = getMonitorDir(os) + "run_" + self.run_info_name.strip() + ".sh"
             script = replaceStr(
                 RUN_PROCESS_SCRIPT,
                 {"run_info_name": self.run_info_name, "workingDir": self.workingDir, "runParam": self.runParam},
             )
             script = replaceStr(script, {"xtDir": dir})
         else:
             path = getMonitorDir(os) + "run_win" + self.run_info_name.strip() + ".bat"
             script = replaceStr(
                 WIN_RUN_PROCESS_SCRIPT, {"run_info_name": self.run_info_name, "workingDir": self.workingDir}
             )
             script = replaceStr(script, {"xtDir": dir})
     elif self.runType == RUN_TYPE_ALL_ALWAYS:
         if not isWindows(os):
             path = "/service/%s/run" % self.run_info_name.strip()
             script = replaceStr(
                 DAEMON_RUN_SCRIPT,
                 {"run_info_name": self.run_info_name, "workingDir": self.workingDir, "runParam": self.runParam},
             )
             script = replaceStr(script, {"xtDir": dir})
         else:
             path = "/service/%s.bat/run" % self.run_info_name.strip()
             script = replaceStr(
                 WIN_RUN_PROCESS_SCRIPT, {"run_info_name": self.run_info_name, "workingDir": self.workingDir}
             )
             script = replaceStr(script, {"xtDir": dir})
     return path, script
コード例 #4
0
ファイル: Timing.py プロジェクト: nobodybut/TTEngine
def win_getCrontable(runInfos, xtDir):
    strRuns = []
    weekset = ['SUN','MON','TUE','WED','THU','FRI','SAT']
    hourset = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23']
    minuteset = ['00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59']
    dict = {}
    for info in runInfos:
        if info.runType == RUN_TYPE_TIMER:
            runParam = info.runParam.strip()
            name = runParam.split('/')[-1]
            name = name.split('.')[0]
            if name in dict:
                i = dict[name] + 1
            else:
                dict[name] = 0
                i = dict[name]
            print "dict[name] :%s" % dict[name]
            xe = "c:\windows\system32\schtasks /create "  + "/tr %s " % runParam
            x = ""
            restarts = info.timerParam.split()
            st,dict[name] = wek(restarts,weekset,name,i,xe,hourset,minuteset,dict)
            print st
            if len(st) > 0:
                st = "\n".join(st)
                strRuns.append(st)

    ret = "\n".join(strRuns)
    ret = ret + "\n"
    ret = replaceStr(ret, {"xtDir":xtDir})

    return ret
コード例 #5
0
ファイル: RunInfo.py プロジェクト: nobodybut/TTEngine
def getCrontable(runInfos, xtDir):
    strRuns = []
    for info in runInfos:
        if info.runType == RunInfo.RUN_TYPE_TIMER:
            runParam = info.runParam.strip()
            runParam = "`%s`" % runParam
            str = info.timerParam + " " + runParam
            if len(str) > 0:
                strRuns.append(str)
    ret = "\n".join(strRuns)
    ret = ret + "\n"
    ret = replaceStr(ret, {"xtDir": xtDir})
    return ret
コード例 #6
0
ファイル: RunInfo.py プロジェクト: NolanZhao/TTEngine
def getCrontable(runInfos, xtDir):
    strRuns = []
    for info in runInfos:
        if info.runType == RunInfo.RUN_TYPE_TIMER:
            runParam = info.runParam.strip()
            runParam = "`%s`" % runParam
            str = info.timerParam + " " + runParam
            if len(str) > 0:
                strRuns.append(str)
    ret = "\n".join(strRuns)
    ret = ret + "\n"
    ret = replaceStr(ret, {"xtDir":xtDir})
    return ret
コード例 #7
0
def win_genDailyRestart(runInfos):
    restarts = []
    for info in runInfos :
        if info.runType == RUN_TYPE_MASTER_ALWAYS:
            items = info.runParam.strip().split()
            if len(items) > 0:
                processName = items[0].split("/")[-1]
                if processName == "python" or processName == "lua":
                    continue
                restarts.append(processName)
    restarts = list(set(restarts))
    str = " ".join(restarts)
    ret = WIN_DAILY_RESTART
    ret = replaceStr(ret, {"Processes":str})
    return ret
コード例 #8
0
ファイル: models.py プロジェクト: nobodybut/TTEngine
 def getRunScript(self, os, dir):
     path = None
     script = None
     if self.runType == RUN_TYPE_MASTER_ALWAYS:
         if not isWindows(os):
             path = getMonitorDir(
                 os) + "run_" + self.run_info_name.strip() + ".sh"
             script = replaceStr(
                 RUN_PROCESS_SCRIPT, {
                     "run_info_name": self.run_info_name,
                     "workingDir": self.workingDir,
                     "runParam": self.runParam
                 })
             script = replaceStr(script, {"xtDir": dir})
         else:
             path = getMonitorDir(
                 os) + "run_win" + self.run_info_name.strip() + ".bat"
             script = replaceStr(
                 WIN_RUN_PROCESS_SCRIPT, {
                     "run_info_name": self.run_info_name,
                     "workingDir": self.workingDir
                 })
             script = replaceStr(script, {"xtDir": dir})
     elif self.runType == RUN_TYPE_ALL_ALWAYS:
         if not isWindows(os):
             path = "/service/%s/run" % self.run_info_name.strip()
             script = replaceStr(
                 DAEMON_RUN_SCRIPT, {
                     "run_info_name": self.run_info_name,
                     "workingDir": self.workingDir,
                     "runParam": self.runParam
                 })
             script = replaceStr(script, {"xtDir": dir})
         else:
             path = "/service/%s.bat/run" % self.run_info_name.strip()
             script = replaceStr(
                 WIN_RUN_PROCESS_SCRIPT, {
                     "run_info_name": self.run_info_name,
                     "workingDir": self.workingDir
                 })
             script = replaceStr(script, {"xtDir": dir})
     return path, script
コード例 #9
0
def getCrontable(runInfos, xtDir):
    strRuns = []
    for info in runInfos:
        if info.runType == RUN_TYPE_TIMER:
            runParam = info.runParam.strip()
            workingDir = info.workingDir.strip()
            str = ""
            if len(workingDir) > 0:
                runParam = "`cd %s; %s`" % (workingDir, runParam)
                str = info.timerParam + " %s" % runParam
            else:
                runParam = "`%s`" % runParam
                str = info.timerParam + " %s" % runParam
            if len(str) > 0:
                strRuns.append(str)
    ret = "\n".join(strRuns)
    ret = ret + "\n"
    ret = replaceStr(ret, {"xtDir":xtDir})
    return ret
コード例 #10
0
ファイル: RunInfo.py プロジェクト: nobodybut/TTEngine
 def genAlwaysCheck(self, dir):
     ret = replaceStr(self.RUN_PROCESS_ALWAYS_CHECK, self.__dict__)
     ret = replaceStr(ret, {"xtDir": dir})
     return ret
コード例 #11
0
ファイル: RunInfo.py プロジェクト: nobodybut/TTEngine
 def genAlwaysScript(self, dir):
     ret = replaceStr(self.RUN_PROCESS_SCRIPT, self.__dict__)
     ret = replaceStr(ret, {"xtDir": dir})
     return ret
コード例 #12
0
def genCheckAll(runInfos, xtDir):
    ret = "\n".join([replaceStr(CHECK_PROCESS_SCRIPT, {"runInfo":info.run_info_name}) for info in runInfos if info.runType == RUN_TYPE_MASTER_ALWAYS])
    ret = replaceStr(ret, {"xtDir":xtDir})
    return ret
コード例 #13
0
ファイル: RunInfo.py プロジェクト: NolanZhao/TTEngine
 def genAlwaysCheck(self, dir):
     ret = replaceStr(self.RUN_PROCESS_ALWAYS_CHECK, self.__dict__)
     ret = replaceStr(ret, {"xtDir":dir})
     return ret
コード例 #14
0
ファイル: RunInfo.py プロジェクト: NolanZhao/TTEngine
 def genAlwaysScript(self, dir):
     ret = replaceStr(self.RUN_PROCESS_SCRIPT, self.__dict__)
     ret = replaceStr(ret, {"xtDir":dir})
     return ret