Jump to content

[Ajuda] Alterar start.py


Recommended Posts

Pessoal, alguém poderia me ajudar editar este start.py para só iniciar o auth, db, canal 1 e canal 99 ao invés de também iniciar o canal 2, 3 e 4?


#### @martysama0134 start scripts ####
from subprocess import check_output as sp_co, call as sp_call, CalledProcessError as sp_CalledProcessError
from os import getcwd as os_getcwd, chdir as os_chdir

from platform import system as p_system
v_system = p_system()

class M2TYPE:
    NOCHAN = 0

def fShell(szCmd, bRet=False):
        if bRet:
            return sp_co(szCmd, shell=True)[:-1]    # remove final \n
            return sp_call(szCmd, shell=True)
    except sp_CalledProcessError:
        return -1

def keyCheck(dict, key, elem={}):
    except KeyError:

whichlist={"serv":[], "chan":[]}
def staInit():
    global proclist
    ## base
    from json import load as j_loads
    with open("start.list", "r") as fList:
        mList = j_loads(fList)
    for dic1 in mList:
        keyCheck(proclist, dic1["serv"])
        if dic1["type"]==M2TYPE.DB:
            keyCheck(proclist[dic1["serv"]], "db", [])
        elif dic1["type"]==M2TYPE.AUTH or dic1["type"]==M2TYPE.CORE:
            keyCheck(proclist[dic1["serv"]], "core", [])
            if dic1["type"]==M2TYPE.CORE:
                keyCheck(proclist[dic1["serv"]], "chan", set())

def staStart(serv=(), chan={}):
    from time import sleep as t_sleep
    global whichlist
    keyCheck(whichlist["chan"], "all", ())
    def RunInMe(tmpProcList, bSkipCheck=False):
        addFlags = ""
        if dwLogLevel:
            addFlags += " -l %d " % dwLogLevel
        if dwIP:
            addFlags += " -I %s " % dwIP

        for dic1 in tmpProcList:
            # skip not requested servers
            if (whichlist["serv"]) and (dic1["serv"] not in whichlist["serv"]):
            if not bSkipCheck and dic1["type"]==M2TYPE.CORE:
                # skip not requested channels
                keyCheck(whichlist["chan"], dic1["serv"], ())
                if whichlist["chan"]["all"]:
                    # print "all",whichlist["chan"]["all"]
                    if not dic1["chan"] in whichlist["chan"]["all"]:
                if whichlist["chan"][dic1["serv"]]:
                    # print dic1["serv"]
                    if not dic1["chan"] in whichlist["chan"][dic1["serv"]]:
            # print dic1

            if v_system in ("FreeBSD", "Linux"):
                if not fShell("""ps afx | fgrep "./%s" | fgrep -v grep | awk '{print $1}'"""%dic1["name"], True):
                    # print dic1["name"], "not found"
                    # goto process file
                    # print("cd %s"%dic1["path"])
                    # start process
                    # print("./%s &"%dic1["name"])
                    # fShell("./%s &"%dic1["name"])
                    fShell("./%s %s &" % (dic1["name"], addFlags))
                    # goto base again
            elif v_system=="Windows":
                # easy workaround for windows (only for debug purposes)
                # fShell("""tasklist /v | findstr "%s" """%dic1["name"])
                fShell("start /b %s %s" % (dic1["name"], addFlags))
    for k1 in proclist.iterkeys():
        # RunInMe(proclist[k1]["db"], True)

if __name__ == "__main__":
    from getopt import getopt as g_getopt, GetoptError as g_GetoptError
    from sys import exit as s_exit, argv as s_argv
        bIsAll = True
        bHasPrompt = False
        # baseChan = [1,99] # ch1 and ch99 are required
        baseChan = []
        listWhich = []
        szWhichServ = ""
        szWhichChan = {}
        dwLogLevel = 0
        dwIP = ""
        optlist, args = g_getopt(s_argv[1:],"psl:I:",('prompt','selective','whichserv=','whichchan=','level=','IP='))
        for o, a in optlist:
            if o in ('-s', '--selective'):
            elif o in ('-p', '--prompt'):
            elif o in ('-l', '--level'):
            elif o in ('-I', '--IP'):
            elif o in ('-ws', '--whichserv'):
                if szWhichServ:
            elif o in ('-wc', '--whichchan'):
                if szWhichChan:
        if bHasPrompt:
            print "Servers available to run:", " ".join(proclist.iterkeys())
            szTmp1 = raw_input("Enter which servers you want to start: (nothing=all)\ne.g. srv1 srv2 srv3\n>>> ")
            if szTmp1.strip():
                for iChan in szTmp1.strip().split():
                    if iChan not in proclist.iterkeys():
                        print "Server not found:", iChan
                    print "Channels available to run for %s:"%iChan, " ".join([str(i) for i in proclist[iChan]["chan"]])
                    szTmp2 = raw_input("Enter which additional channels you want to start: (nothing=all)\ne.g. 1 2 99\n>>> ")
                    if szTmp2.strip():
                        # print szTmp1, szTmp2
        # print proclist,whichlist
        if bIsAll:
            # print "---",szWhichServ,"---"
            # print "---",szWhichChan,"---"
            if szWhichServ:
            if szWhichChan:
                for iKey in szWhichChan.iterkeys():
                    tmpWhichChan[iKey]=set([int(i) for i in szWhichChan[iKey].split()])
                # tmpWhichChan["all"]=list(set([int(i) for i in szWhichChan["all"].split()] + baseChan))
            # print tmpWhichServ, "\n", tmpWhichChan
            staStart(serv=tmpWhichServ, chan=tmpWhichChan)
    except g_GetoptError, err:



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...