コード例 #1
0
ファイル: getdate.py プロジェクト: whm/kafs-utils
def main(params):
    cell = params["cell"]
    bos_conn = cell.open_bos_server(params["server"], params)

    if "dir" in params:
        d = params["dir"]
    else:
        d = "/usr/afs/bin"

    for f in params["file"]:
        i = f.rfind('/')
        if i > -1:
            f = f[i + 1:]
        f = d + "/" + f

        verbose("Asking about ", f, "\n")
        ret = kafs.BOZO_GetDates(bos_conn, f)

        if ret.newtime == 0:
            s = "File " + f + "does not exist, "
        else:
            s = "File {:s} dated {:s}, ".format(f, time2str(ret.newtime))
        if ret.baktime == 0:
            s += "no .BAK file, "
        else:
            s += ".BAK file dated " + time2str(ret.baktime) + ", "
        if ret.oldtime == 0:
            s += "no .OLD file."
        else:
            s += ".OLD file dated " + time2str(ret.oldtime) + "."

        output(s, "\n")
コード例 #2
0
ファイル: bash-comp-helper.py プロジェクト: whm/kafs-utils
def expand_from_stringlist(comp_words, comp_cword, names):
    reply = ""
    for i in names:
        if i.startswith(comp_words[comp_cword]):
            reply += " " + i
    output(reply.lstrip(), "\n")
    sys.exit(0)
コード例 #3
0
ファイル: status.py プロジェクト: whm/kafs-utils
def display_instance_long(params, bos_conn, name):
    info, status = display_instance_normal(params, bos_conn, name)

    outputf("    Process last started at {:s} ({:d} proc starts)",
            time2str(info.status.porcStartTime), info.status.procStarts)

    if info.status.lastAnyExit != 0:
        output("    Last exit at ", time2str(info.status.lastAnyExit), "\n")

    if info.status.lastErrorExit != 0:
        output("    Last error exit ", info.status.lastErrorExit, "\n")
        s = "    Last error exit at " + time2str(
            info.status.lastErrorExit) + ","
        istr = kafs.BOZO_GetInstanceStrings(bos_conn, name)
        if istr.errorname != "":
            s += " by " + istr.errorname + ","
        if info.status.errorSignal == signal.SIGTERM:
            s += " due to shutdown request."
        elif info.status.errorSignal != 0:
            s += " due to signal {:d}.".format(info.status.errorSignal)
        else:
            s += " due to exit {:d}.".format(info.status.errorCode)
        output(s, "\n")

    try:
        i = 0
        while True:
            ret = kafs.BOZO_GetInstanceParm(bos_conn, name, i)
            i += 1
            output("    Command ", i, " is '", ret.parm, "'\n")
    except kafs.AbortBZDOM:
        pass

    output("\n")
コード例 #4
0
def main(params):
    exitcode = 0
    cell = params["cell"]
    prcache = cell.get_prcache(params)

    names = params["name"]
    if "id" in params:
        ids = params["id"]
    else:
        ids = []
    for i in range(0, len(names)):
        try:
            name = names[i]
            verbose("Adding user ", name, "\n")
            if i < len(ids):
                new_id = int(ids[i])
                ret = cell.call_pt_server(params, kafs.PR_NewEntry, name,
                                          new_id, 0)
            else:
                ret = cell.call_pt_server(params, kafs.PR_NewEntry, name, 0, 0)
                new_id = ret.id
            output("User ", name, " has id ", new_id, "\n")
            prcache.evict_name(name)
            prcache.evict_id(new_id)
        except kafs.AbortPREXIST:
            error("Entry for name already exists ; unable to create user ",
                  name, "\n")
            if "force" not in params:
                break
        except kafs.AbortPRIDEXIST:
            error("Entry for id already exists ; unable to create user ", name,
                  " with id ", new_id, "\n")
            if "force" not in params:
                break
    return exitcode
コード例 #5
0
ファイル: status.py プロジェクト: whm/kafs-utils
def main(params):
    cell = params["cell"]
    bos_conn = cell.open_bos_server(params["server"], params)

    if "instance" not in params:
        instances = []
        try:
            i = 0
            while True:
                verbose("Enum ", i, ": ")
                ret = kafs.BOZO_EnumerateInstance(bos_conn, i)
                i += 1
                verbose_cont(ret.iname, "\n")
                instances.append(ret.iname)
        except kafs.AbortBZDOM:
            verbose_cont("<empty slot>\n")
    else:
        instances = params["instance"]

    for i in instances:
        try:
            verbose("Displaying ", i, "\n")
            if "long" in params:
                display_instance_long(params, bos_conn, i)
            else:
                display_instance_normal(params, bos_conn, i)
        except kafs.AbortBZNOENT:
            error("failed to get instance info for '", i,
                  "' (no such entity)\n")

    if "_baddiraccess" in params and "long" in params:
        output(
            "Bosserver reports inappropriate access on server directories\n")
コード例 #6
0
def main(params):
    cell = params["cell"]
    bos_conn = cell.open_bos_server(params["server"], params)

    split = split_handler()

    output("Fetching log file '", params["file"], "'...\n")
    output_flush()
    ret = kafs.BOZO_GetLog(bos_conn, params["file"], split)
コード例 #7
0
ファイル: getrestricted.py プロジェクト: whm/kafs-utils
def main(params):
    cell = params["cell"]
    bos_conn = cell.open_bos_server(params["server"], params)

    ret = kafs.BOZO_GetRestricted(bos_conn)
    if ret.isrestricted:
        output("Restricted mode is on\n")
    else:
        output("Restricted mode is off\n")
コード例 #8
0
ファイル: apropos.py プロジェクト: whm/kafs-utils
def main(params):
    matches = search_help(params["_prog"], params["_cmdsetmod"],
                          params["_commands"], params["topic"].casefold())

    if not matches:
        output("Sorry, no commands found\n")
    else:
        for i in sorted(matches.keys()):
            output(i, ": ", matches[i], "\n")
コード例 #9
0
def display_vldb(params, vldb):
    if vldb.volumeId[kafs.RWVOL] != 0:
        outputf("    RWrite: {:<10d}", vldb.volumeId[kafs.RWVOL])
    if vldb.volumeId[kafs.ROVOL] != 0:
        outputf("    ROnly: {:<10d}", vldb.volumeId[kafs.ROVOL])
    if vldb.volumeId[kafs.BACKVOL] != 0:
        outputf("    Backup: {:<10d}", vldb.volumeId[kafs.BACKVOL])
    output("\n")

    display_vldb_site_list(params, vldb, "    ")
コード例 #10
0
def main(params):
    cell = params["cell"]

    if "users" in params and "groups" in params:
        flags = kafs.PRWANTUSERS | kafs.PRWANTGROUPS
    elif "groups" in params:
        flags = kafs.PRWANTGROUPS
    else:
        flags = kafs.PRWANTUSERS

    ret = cell.call_pt_server(params, kafs.PR_ListEntries, flags, 0)

    output("Name                          ID   Owner Creator\n")
    for i in ret.entries:
        outputf("{:24s} {:7d} {:7d} {:7d}\n", i.name, i.id, i.owner, i.creator)
コード例 #11
0
def display_command_list(prog, cmdsetmod, commands):
    output(prog, ": Commands are:\n")
    for i in sorted(commands):
        if i == "help":
            desc = "Get help on commands"
        elif i == "apropos":
            desc = "Search by help text"
        else:
            command = cmdsetmod.get_command(i)
            if hasattr(command, "alias"):
                desc = "Alias for '" + command.alias + "'"
            elif not hasattr(command, "help"):
                desc = "** no help **"
            else:
                desc = command.help
        outputf("{:<15s} {:s}\n", i, desc)
コード例 #12
0
ファイル: status.py プロジェクト: whm/kafs-utils
def display_instance_normal(params, bos_conn, name):
    info = kafs.BOZO_GetInstanceInfo(bos_conn, name)
    status = kafs.BOZO_GetStatus(bos_conn, name)

    if info.status.flags & kafs.BOZO_BADDIRACCESS:
        params["_baddiraccess"] = True

    s = "Instance " + name + ","

    if "long" in params:
        s += " (type is " + info.type + ")"

    # The instance's permanent state is shown by the goals returned by
    # GetInstanceInfo()
    if info.status.fileGoal == kafs.BSTAT_SHUTDOWN:
        if info.status.goal == kafs.BSTAT_SHUTDOWN:
            s += " disabled,"
        else:
            s += " temporarily enabled,"
    else:
        if info.status.goal == kafs.BSTAT_SHUTDOWN:
            s += " temporarily disabled,"
        else:
            pass

    # Supplementary data is found in the flags
    if info.status.flags & kafs.BOZO_HASCORE:
        s += " has core file,"
    if info.status.flags & kafs.BOZO_ERRORSTOP:
        s += " stopped for too many errors,"

    # The instance's actual state is returned by GetStatus()
    if status.inStat == kafs.BSTAT_SHUTDOWN:
        s += " currently shut down."
    elif status.inStat == kafs.BSTAT_NORMAL:
        s += " currently running normally."
    elif status.inStat == kafs.BSTAT_SHUTTINGDOWN:
        s += " currently shutting down."
    elif status.inStat == kafs.BSTAT_STARTINGUP:
        s += " currently starting up."
    output(s, "\n")
    if status.statdescr != "":
        output("    Auxiliary status is: ", status.statdescr, "\n")
    return (info, status)
コード例 #13
0
def main(params):
    cell = params["cell"]
    bos_conn = cell.open_bos_server(params["server"], params)

    users = ""
    try:
        i = 0
        while True:
            ret = kafs.BOZO_ListSUsers(bos_conn, i)
            i += 1
            users += " " + ret.name
    except kafs.RemoteAbort as msg:
        if str(msg) == "Aborted 1":
            pass
        else:
            raise

    output("SUsers are:", users, "\n")
    output("\n")
コード例 #14
0
def display_command_arguments(args):
    for arg in args:
        if arg[2] == "fn" or arg[2][0] == "o":
            opt_o = "["
            opt_c = "]"
        else:
            opt_o = ""
            opt_c = ""
        output(" ", opt_o, "-", arg[0])
        if arg[2] != "fn":
            output(" ", arg[3])
        output(opt_c)
    output(" [-help]")
コード例 #15
0
ファイル: listowned.py プロジェクト: whm/kafs-utils
def main(params):
    cell = params["cell"]
    prcache = cell.get_prcache(params)

    for name in params["nameorid"]:
        prcache.precache_name_or_id(name)

    results = []
    for name in params["nameorid"]:
        uid = prcache.name_or_id_to_id(name)
        if uid == None:
            error("User or group doesn't exist so couldn't look up id for " +
                  name + "\n")
            if "force" not in params:
                break
            continue

        try:
            verbose("Listing entries owned by user ", uid, " (", name, ")\n")
            ret = cell.call_pt_server(params, kafs.PR_ListOwned, uid, 0)
            elist = ret.elist
            for entry in elist:
                prcache.precache_id(entry)
            results.append((uid, elist))

        except kafs.AbortPRNOENT:
            error("User or group doesn't exist deleting ", name, " (id ", uid,
                  ")\n")
            if "force" not in params:
                break
        except kafs.AbortPRPERM:
            error("Permission denied deleting ", name, " (id: ", uid, ")\n")
            if "force" not in params:
                break

    for (uid, elist) in results:
        output("Groups owned by ", prcache.id_to_name(uid), " (id: ", uid,
               ") are:\n")
        for entry in elist:
            output("  ", prcache.id_to_name(entry), "\n")
コード例 #16
0
def print_record(params, vldb):
    """Display a single VLDB record"""
    output(vldb.name, "\n")
    output("   ")
    flags = vldb.serverFlags[0]
    if flags & kafs.VLSF_RWVOL:
        outputf(" RWrite: {:<12d}", vldb.volumeId[0])
    if flags & kafs.VLSF_ROVOL:
        outputf(" ROnly: {:<12d}", vldb.volumeId[1])
    if flags & kafs.VLSF_BACKVOL:
        outputf(" Backup: {:<12d}", vldb.volumeId[2])
    output("\n")
    display_vldb_site_list(params, vldb, "    ")
    output("\n")
コード例 #17
0
ファイル: voldisplay.py プロジェクト: whm/kafs-utils
def display_vol_mp_basic_information(params, vol):
    server = params["server"]
    output("BEGIN_OF_ENTRY\n")
    outputf("name\t\t{:s}\n", vol.name)
    outputf("id\t\t{:d}\n", vol.volid)
    outputf("serv\t\t{:<15s}\t{:s}\n", str(server), server.addr())
    outputf("part\t\t{:s}\n", params["_partname"])
    outputf("status\t\t{:s}\n", vol_status(vol))
    outputf("backupID\t{:d}\n", vol.backupID)
    outputf("parentID\t{:d}\n", vol.parentID)
    outputf("cloneID\t\t{:d}\n", vol.cloneID)
    outputf("inUse\t\t{:s}\n", yes_or_no(vol.inUse))
    try:
        outputf("needsSalvaged\t{:s}\n", yes_or_no(vol.needsSalvaged))
        outputf("destroyMe\t{:s}\n", yes_or_no(vol.destroyMe))
    except AttributeError:
        pass
    outputf("type\t\t{:s}\n", vol_type(vol))
    outputf("creationDate\t{:<10d}\t{:s}\n", vol.creationDate,
            time2str(vol.creationDate))
    outputf("accessDate\t{:<10d}\t{:s}\n", vol.accessDate,
            time2str(vol.accessDate))
    outputf("updateDate\t{:<10d}\t{:s}\n", vol.updateDate,
            time2str(vol.updateDate))
    outputf("backupData\t{:<10d}\t{:s}\n", vol.backupDate,
            time2str(vol.backupDate))
    outputf("copyDate\t{:<10d}\t{:s}\n", vol.copyDate, time2str(vol.copyDate))
    try:
        outputf("flags\t\t{:<7d}\t(Optional)\n", vol.flags)
    except AttributeError:
        pass
    outputf("diskused\t{:d}\n", vol.size)
    outputf("maxquota\t{:d}\n", vol.maxquota)
    try:
        outputf("minquota\t{:<7d}\t(Optional)\n", vol.spare0)
    except AttributeError:
        pass
    outputf("filecount\t{:d}\n", vol.filecount)
    outputf("dayUse\t\t{:d}\n", vol.dayUse)
コード例 #18
0
def main(params):
    # Get a list of VLDB servers to query
    cell = params["cell"]
    z_conn = cell.open_vl_server(params)
    quiet = "quiet" in params

    if "name" in params:
        ret = kafs.VL_GetEntryByName(z_conn, params["name"])
        vldb = ret.entry
        print_record(params, vldb)
        return

    attributes = kafs.VldbListByAttributes()
    attributes.Mask = 0

    if "server" in params:
        attributes.Mask |= kafs.VLLIST_SERVER
        attributes.server = params["server"].integer_addr()
    if "partition" in params:
        attributes.Mask |= kafs.VLLIST_PARTITION
        attributes.partition = params["partition"]
    if "locked" in params:
        attributes.Mask |= kafs.VLLIST_FLAG
        attributes.flag = kafs.VLOP_MOVE | kafs.VLOP_RELEASE | kafs.VLOP_BACKUP | kafs.VLOP_DELETE | kafs.VLOP_DUMP

    ret = kafs.VL_ListAttributes(z_conn, attributes)
    blkentries = ret.blkentries

    if not quiet and "server" in params:
        output("VLDB entries for server ", params["server"], "\n")

    if "nosort" not in params:
        blkentries.sort(key=lambda vldb: vldb.name)

    for vldb in blkentries:
        print_record(params, vldb)

    if not quiet:
        output("Total entries: ", len(blkentries), "\n")
コード例 #19
0
ファイル: install.py プロジェクト: whm/kafs-utils
def main(params):
    cell = params["cell"]
    bos_conn = cell.open_bos_server(params["server"], params)

    if "dir" in params:
        d = params["dir"]
    else:
        d = "/usr/afs/bin"

    for f in params["file"]:
        stat = os.stat(f)
        fd = open(f, "rb")
        split = split_handler(f, fd, stat.st_size)

        i = f.rfind('/')
        if i > -1:
            f = f[i + 1:]
        remote_file = d + "/" + f

        verbose("Installing file ", remote_file, "\n")
        ret = kafs.BOZO_Install(bos_conn, remote_file, stat.st_size, 0,
                                int(stat.st_mtime), split)
        output(program_name, ": installed file ", f, "\n")
コード例 #20
0
def main(params):
    cell = params["cell"]
    vol_conn = cell.open_volume_server(params["server"], params)

    if "partition" not in params:
        ret = kafs.VOLSER_ListPartitions(vol_conn)
        partitions = ret.partIDs.partIds
    else:
        partitions = [params["partition"]]

    for i in partitions:
        if i != 0xffffffff:
            partname = partition.id2part(i)

            try:
                ret = kafs.VOLSER_PartitionInfo(vol_conn, partname)
                part = ret.partition

                output("Free space on partition ", part.name, ": ", part.free,
                       " K blocks out of total ", part.totalUsable, "\n")
            except kafs.AbortVOLSERILLEGAL_PARTITION:
                error("partition ", partname,
                      " does not exist on the server\n")
コード例 #21
0
ファイル: getrestart.py プロジェクト: whm/kafs-utils
def display_restart_time(params, desc, time):
    if time.mask & kafs.KTIME_NEVER:
        t = "never"
    elif time.mask & kafs.KTIME_NOW:
        t = "never"
    elif time.mask & (kafs.KTIME_DAY | kafs.KTIME_TIME) == 0:
        t = "[unspecified time]"
    else:
        t = "[unspecified time]"
        if time.mask & kafs.KTIME_DAY:
            t = restart_days[time.day] + " "
        else:
            t = ""
        if time.mask & kafs.KTIME_TIME:
            if not (time.mask & kafs.KTIME_MIN):
                time.min = 0
            if time.mask & kafs.KTIME_HOUR:
                h = time.hour
                if h > 12:
                    h -= 12
                if h == 0:
                    h = 12
                t += "{:d}:{:02d}".format(h, time.min)
            else:
                t += "xx:{:02d}".format(time.min)
            if time.mask & kafs.KTIME_SEC:
                t += ":{:02d}".format(time.sec)
            if time.mask & kafs.KTIME_HOUR:
                if time.hour < 12:
                    t += " am"
                else:
                    t += " pm"
        else:
            pass

    output(desc, t, "\n")
コード例 #22
0
ファイル: listaddrs.py プロジェクト: whm/kafs-utils
def list_one(params, vl_conn, attributes):
    ret = kafs.VL_GetAddrsU(vl_conn, attributes)
    if "printuuid" in params:
        output("UUID: ", uuid2str(ret.uuidp1), "\n")

    addrs = ret.blkaddrs
    for a in addrs:
        output(addrcache.resolve(params, a), "\n")
    if "printuuid" in params:
        output("\n")
コード例 #23
0
ファイル: listpart.py プロジェクト: whm/kafs-utils
def main(params):
    cell = params["cell"]
    vol_conn = cell.open_volume_server(params["server"], params)

    ret = kafs.VOLSER_ListPartitions(vol_conn)
    partitions = ret.partIDs.partIds

    output("The partitions on the server are:\n")

    parts = ""
    n = 0

    for i in partitions:
        if i != 0xffffffff:
            n += 1
            output("    ", partition.id2part(i))
    output("\n")

    output("Total: ", n, "\n")
コード例 #24
0
def display_aliases(prog, cmdsetmod, commands, topic):
    aliases = []
    for i in commands:
        if i == "help" or i == "apropos":
            continue
        command = cmdsetmod.get_command(i)
        if hasattr(command, "alias"):
            if command.alias == topic:
                aliases.append(i)
    if aliases:
        output("aliases: ", aliases[0])
        if len(aliases) > 1:
            for i in range(1, len(aliases)):
                output(", ", aliases[i])
        output("\n")
コード例 #25
0
ファイル: listvol.py プロジェクト: whm/kafs-utils
def display_format_extended(params, vol):
    if vol.status == kafs.VBUSY:
        output("VOLUME_BUSY\t{:d}\n", vol.volid)
        return
    elif vol.status != kafs.VOK:
        output("COULD_NOT_ATTACH_VOLUME\t{:d}\n", vol.volid)
        return

    display_vol_mp_basic_information(params, vol)

    for i in range(0, 4):
        outputf("{:s}\t{:8d}\n", reads_labels[i], vol.stat_reads[i])
    for i in range(0, 4):
        outputf("{:s}\t{:8d}\n", writes_labels[i], vol.stat_writes[i])
    for i in range(0, 6):
        outputf("file_same_author_idx_{:d}\t{:8d}\n", i, vol.stat_fileSameAuthor[i])
        outputf("file_diff_author_idx_{:d}\t{:8d}\n", i, vol.stat_fileDiffAuthor[i])
        outputf("dir_same_author_idx_{:d}\t{:8d}\n", i, vol.stat_dirSameAuthor[i])
        outputf("dir_dif_author_idx_{:d}\t{:8d}\n", i, vol.stat_dirDiffAuthor[i])

    output("END_OF_ENTRY")
コード例 #26
0
def main(params):
    cell = params["cell"]

    ret = cell.call_pt_server(params, kafs.PR_ListMax)
    output("Max user id is ", ret.uid, " and max group id is ", ret.gid, ".\n")
コード例 #27
0
def display_format(params, vldb, vol):
    display_vol_mp_information(params, vol)
    output("\n")
    display_vldb(params, vldb)
コード例 #28
0
ファイル: membership.py プロジェクト: whm/kafs-utils
def main(params):
    cell = params["cell"]
    prcache = cell.get_prcache(params)

    for name in params["nameorid"]:
        prcache.precache_name_or_id(name)

    requests = []
    memberships = dict()

    for name in params["nameorid"]:
        gid = prcache.name_or_id_to_id(name)
        if gid == None:
            error("User or group doesn't exist so couldn't look up id for " +
                  name + "\n")
            if "force" not in params:
                break
            continue

        if gid not in requests:
            try:
                if gid < 0:
                    # Group
                    verbose("Listing membership of ", gid, " (", name, ")\n")
                    group = prcache.id_to_group(gid)
                    prcache.precache_ids(group)
                else:
                    # User - ListElements returns the ancestry of a non-group
                    ret = cell.call_pt_server(params, kafs.PR_ListElements,
                                              gid)
                    elist = ret.elist
                    memberships[gid] = elist
                    prcache.precache_ids(elist)
                    for i in elist:
                        if i < 0:
                            prcache.id_to_group(i)
                requests.append(gid)

            except kafs.AbortPRNOENT:
                error("User or group doesn't exist ", name, " (id ", gid,
                      ")\n")
                prcache.id_is_unknown(gid)
                if "force" not in params:
                    break
            except kafs.AbortPRPERM:
                error("Permission denied on ID ", name, " (id: ", gid, ")\n")
                prcache.id_is_unknown(gid)
                if "force" not in params:
                    break

    if "expandgroups" in params:
        groups_needing_expansion = set(prcache.known_groups())
        verbose("Expand groups ", groups_needing_expansion, "\n")
        while groups_needing_expansion:
            gid = groups_needing_expansion.pop()
            members = prcache.id_to_group(gid)
            for m in members:
                prcache.precache_id(m)
                if m < 0 and not prcache.have_group(
                        m) and m not in groups_needing_expansion:
                    groups_needing_expansion.add(m)

    if "supergroups" in params:
        for r in requests:
            if r < 0:
                ret = cell.call_pt_server(params, kafs.PR_ListGroupsMemberOf,
                                          r)
                glist = ret.glist
                memberships[r] = glist

    for r in requests:
        # Display members of a group
        if r < 0:
            if "expandgroups" in params:
                output("Expanded Members of ", prcache.id_to_name(r), " (id: ",
                       r, ") are:\n")
                for m in prcache.id_to_expanded_group(r):
                    if m > 0:
                        output("  ", prcache.id_to_name(m), "\n")
            else:
                output("Members of ", prcache.id_to_name(r), " (id: ", r,
                       ") are:\n")
                for m in prcache.id_to_group(r):
                    output("  ", prcache.id_to_name(m), "\n")

        # Display membership of a user or a group
        if r > 0 and "expandgroups" in params:
            output("Expanded Groups ", prcache.id_to_name(r), " (id: ", r,
                   ") is a member of:\n")
            member_of = memberships[r]
            expanded = set(member_of)
            for gid in member_of:
                expanded |= prcache.id_to_expanded_group(gid)
            for m in expanded:
                if m < 0:
                    output("  ", prcache.id_to_name(m), "\n")
        elif r > 0 or "supergroups" in params:
            output("Groups ", prcache.id_to_name(r), " (id: ", r,
                   ") is a member of:\n")
            for gid in memberships[r]:
                output("  ", prcache.id_to_name(gid), "\n")
コード例 #29
0
def display_help_on_topics(prog, cmdsetmod, commands, topics):
    for topic in topics:
        if topic == "help":
            output("bos help: ", help, "\n")
            display_command_arguments(command_arguments)
            continue

        if topic == "apropos":
            command = __import__("afs.apropos", globals(), locals(), ['*'])
            output("bos apropos: ", command.help, "\n")
            display_command_arguments(command.command_arguments)
            continue

        # See if the command is in the set
        try:
            found = False
            for i in commands:
                if i == topic:
                    found = topic
                    break
                if i.startswith(topic):
                    if found:
                        raise RuntimeError("Ambiguous topic '" + topic +
                                           "'; use 'apropos' to list\n")
                    found = i
            if not found:
                raise RuntimeError("Unknown topic '" + topic + "'\n")
            topic = found
        except RuntimeError as e:
            error(e)
            set_exitcode(5)
            continue

        # Load the command module
        command = cmdsetmod.get_command(topic)

        # If it's an alias, then switch to the real module
        if hasattr(command, "alias"):
            alias = " (alias for " + command.alias + ")"
            command = cmdsetmod.get_command(command.alias)
        else:
            alias = ""

        output(prog, " ", topic, ": ", command.help, alias, "\n")
        display_aliases(prog, cmdsetmod, commands, topic)
        output("Usage: ", prog, " ", topic)
        display_command_arguments(command.command_arguments)
        output("\n")
        desc = command.description
        if desc[0] == "\n":
            desc = desc[1:]
        output(desc)
コード例 #30
0
def helpflag(prog, cmdsetmod, topic, command):
    output("Usage: ", prog, " ", topic)
    display_command_arguments(command.command_arguments)
    output("\n")