def main(options):
    name = options.name
    ini = options.ini
    ini = _BUZZNI_CONF_PATH + ini + ".ini"

    if not(ini and name):
        print options
        raise Exception, "Check parameters"

    dict_path = ini_parser(read_file(ini, "line_list", "r"))["buzzni"]["dict_path"]

    info_dict = read_json(dict_path+"/dictionary.info")
    if name == "*":
        tmp = info_dict.keys()
        name = ""
        for _name in tmp:
            name += _name+","
        name = name[0:-1]

    name_list = name.split(",")
    for name in name_list:
        pid = info_dict[name]["pid"]
        sock = info_dict[name]["sock"]
        cmd_string = "uwsgi --stop %s" % (pid)
        status, msg = cmd(cmd_string)
        info_dict.pop(name)

        rm_file(pid)
        rm_file(sock)

    write_json(dict_path+"/dictionary.info", info_dict)
def main(options):
    print "[+] starting uwsgi server"
    name = options.name
    ini = options.ini
    ini = _BUZZNI_CONF_PATH + ini + ".ini"

    if not(name and ini):
        print options
        raise Exception, "Check parameters"

    ini_lines = read_file(ini, "line_list", "r")
    ini_info = ini_parser(ini_lines)["buzzni"]

    pid_path = ini_info["pid_path"]
    socket_path = ini_info["socket_path"]
    dict_path = ini_info["dict_path"]

    check_path([pid_path, socket_path, dict_path])

    dict_obj = read_json(dict_path+"/dictionary.info")
    if dict_obj.has_key(name):
        print "\t[!] already exist name!"
    else:
        sock = socket_path+"/"+name
        pid = pid_path+"/"+name+"_pid.pid"

        cmd_string = "uwsgi --pidfile=%s --socket=%s --ini=%s" % (pid, sock, ini)

        status, msg = cmd(cmd_string)

        dict_obj[name] = {
            "date":str(datetime.datetime.now()),
            "sock":sock,
            "pid":pid,
            "ini":ini
        }
        write_json(dict_path+"/dictionary.info", dict_obj)
    print "[+] finish!"
def main(options):
    ini = options.ini
    ini = _BUZZNI_CONF_PATH + ini + ".ini"

    if not(ini):
        print options
        raise Exception, "Check parameters"

    dict_path = ini_parser(read_file(ini, "line_list", "r"))["buzzni"]["dict_path"]

    info_dict = read_json(dict_path+"/dictionary.info")
    if not(info_dict):
        print "[!] not exsit dictionary info.(%s)" % dict_path
        exit(0)

    for name, info in info_dict.iteritems():
        print "-"*50
        print "%s" % (name)
        print "-"*50
        for k, v in info.iteritems():
            print "%s : %s" % (k, v)
        print "-"*50
        print ""