当前位置: 首页>>代码示例>>Python>>正文


Python CPL.qstr方法代码示例

本文整理汇总了Python中CPL.qstr方法的典型用法代码示例。如果您正苦于以下问题:Python CPL.qstr方法的具体用法?Python CPL.qstr怎么用?Python CPL.qstr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPL的用法示例。


在下文中一共展示了CPL.qstr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dropPrograms

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def dropPrograms(self, programs=[], cmd=None):
        """ Remove a list of programs from the control list.

        Args:
           programs  - a list of programs to register for authorization. Adds all connected
                       programs if empty.
           cmd       - The command to reply to, or .defaultCmd
        """

        if not programs:
            programs = list(self.programs.keys())

        if self.debug > 3:
            CPL.log("auth.dropProgram", "dropping programs %s" % (programs))

        if not cmd:
            cmd = self.defaultCmd

        for program in programs:
            if program in self.gods:
                cmd.warn("permsTxt=%s" % \
                         (CPL.qstr("Super-%s cannot be removed from the list of authorized programs" % (program))))
                self.genAuthKeys([program], cmd)
                continue
            try:
                del self.programs[program]
            except:
                cmd.warn("permsTxt=%s" % \
                         (CPL.qstr("Program %s did not have an authorization entry, so could not be deleted" % (program))))
            
        self.genProgramsKey(cmd=cmd)
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:33,代码来源:Auth.py

示例2: setActorsForProgram

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def setActorsForProgram(self, program, actors, cmd=None):
        """ Define the list of actors that a program can command.
        """

        if self.debug > 3:
            CPL.log("auth.setActors", "setting actors for commander %s: %s" % (program, actors))
            
        if not cmd:
            cmd = self.defaultCmd

        if program not in self.programs:
            cmd.fail("permsTxt=%s" % (CPL.qstr("Program %s did not have an authorization entry, so could not be set" % (program))))
            return
        
        d = {}
        for a in actors:
            if a not in self.actors:
                cmd.warn("permsTxt=%s" % (CPL.qstr("Actor %s is not subject to permissions." % (a))))
            else:
                d[a] = True
            
        # Make sure God-like commanders can always command us...
        #
        if program in self.gods:
            d['perms'] = True
        self.programs[program] = d

        self.genAuthKeys(programs=[program], cmd=cmd)
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:30,代码来源:Auth.py

示例3: genAuthKeys

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def genAuthKeys(self, programs=None, cmd=None):
        """ Generate keys describing some or all programs.

        Args:
           cmd       - if set, the command to reply to. Otherwise use our .defaultCmd
           programs  - if set, a list of programs to generate keys for. Otherwise describe all programs.

        Notes:
           Never finishes the cmd.
        """

        if not cmd:
            cmd = self.defaultCmd
        if not programs:
            programs = list(self.programs.keys())

        programs.sort()
        CPL.log("auth.genAuthKeys", "listing programs: %s" % (programs))

        for prog in programs:
            try:
                pAuth = list(self.programs[prog].keys())
            except KeyError as e:
                raise Exception("No authorization entry found for program %s" % (prog))
            
            pAuth.sort()
            actors = [CPL.qstr(x) for x in pAuth]
            cmd.inform("authList=%s,%s" % (CPL.qstr(prog), ','.join(actors)))
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:30,代码来源:Auth.py

示例4: lockActors

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def lockActors(self, actors, cmd=None):
        """ Block non-APO users form commanding a list of actors.

        Any actors not in .actors will be ignored with a warning. This may not be the right behavior. We may
        actually want to allow actors we do not control to be locked.
        """

        if not cmd:
            cmd = self.defaultCmd
            
        if not actors:
            actors = self.actors
                
        if self.debug > 3:
            CPL.log("auth.lockActor", "locking actors %s" % (actors))

        for a in actors:
            if a in self.lockedActors:
                cmd.warn("permsTxt=%s" % (CPL.qstr("Actor %s is already locked" % (a))))
            elif a not in self.actors:
                cmd.warn("permsTxt=%s" % (CPL.qstr("Actor %s is not subject to permissions and will not be locked" % (a))))
            else:
                self.lockedActors[a] = True

        self.genLockedKey(cmd=cmd)
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:27,代码来源:Auth.py

示例5: sendCommand

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def sendCommand(self, cmd):
        """ 
        """

        CPL.log("%s.cmd" % (self.name), "running cmd=%s" % (CPL.qstr(cmd.cmd)))
        self.totalCommands += 1
        
        cmd.parseArgs()
        words = list(cmd.argDict.keys())
        if len(words) == 0:
            cmd.finish('')
            return
        
        cmdWord = words[0]
        cmdHandler = self.commands.get(cmdWord, None)
        if cmdHandler == None:
            cmd.fail('%sTxt=%s' % \
                     (self.name, CPL.qstr("No command named %s" % (cmdWord))))
            return

        cmd.reportQueued()
        try:
            cmdHandler(cmd)
        except Exception as e:
            CPL.tback('Vocab.sendCommand', e)
            cmd.fail('%sTxt=%s' % (self.name, CPL.qstr(e, tquote='"')))
            return
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:29,代码来源:InternalCmd.py

示例6: reportQueued

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def reportQueued(self):
        if g.hubcmd != None and self.bcastCmdInfo:

            dcmd = self.cmd if len(self.cmd) < 1000 else self.cmd[:1000] + "...."
            g.hubcmd.diag(("CmdQueued=%d,%0.2f,%s,%s,%s,%s,%s" %
                           (self.xid, self.ctime,
                            CPL.qstr(self.cmdrCid), self.cmdrMid,
                            CPL.qstr(self.actorName), self.actorMid,
                            CPL.qstr(dcmd))),
                          src='cmds')
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:12,代码来源:Command.py

示例7: listCommandsCmd

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def listCommandsCmd(self, cmd, doFinish=True):
        """ Send command keywords.
        """

        cmd.inform('actorCmds=%s,%d,%d' % \
                   (CPL.qstr(self.name), len(self.liveCommands), len(self.ourCommands)))

        for id, ourCmd in self.ourCommands.items():
            cmd.inform('actorCmd=%s,%s,%s' % \
                   (CPL.qstr(self.name), CPL.qstr(id), CPL.qstr(ourCmd)))
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:12,代码来源:ActorNub.py

示例8: parseASCIIReply

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
def parseASCIIReply(s, cidFirst=False):
    """ Try to parse a string into a dictionary containing:
         - mid   - the ICC's MID
         - cid   - the ICC's CID
         - flag  - the reply's flag character
         - KVs   - an OrderedDict of (key, value)s
    
        Returns that dictionary, or raises RuntimeError.

        If a reply line cannot be parsed at all, insert the entire line into the key 'RawLine'.
        If a reply line cannot be completely parsed, insert the unparsed section into the key 'UNPARSEDTEXT'.
    """

    if cidFirst:
        match = line_cidmid_re.match(s)
    else:
        match = line_midcid_re.match(s)
        
    if match == None:
        d = {}
        d['mid'] = 0
        d['cid'] = 0                    # or 'hub' or '.hub'?
        d['flag'] = 'w'
        d['RawText'] = s

        kvs = collections.OrderedDict()
        kvs['RawLine'] = [CPL.qstr(s)]
        d['KVs'] = kvs
        return d

    d = match.groupdict()

    try:
        KVs = parseKVs(d['rest'])
    except ParseException as e:
        KVs = e.KVs
        leftoverText = e.leftoverText

        # In this case, quote the offending text.
        KVs['UNPARSEDTEXT'] = [CPL.qstr(leftoverText)]
    except Exception as e:
        CPL.log("parseASCIIReply", "unexpected Exception: %s" % (e))
        KVs = collections.OrderedDict()
        KVs['UNPARSEDTEXT'] = [CPL.qstr(d['rest'])]
        
    d['KVs'] = KVs
    d['RawText'] = s
    del d['rest']
    
    return d
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:52,代码来源:keys.py

示例9: addPrograms

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def addPrograms(self, programs=[], actors=[], cmd=None):
        """ Add a list program to the control list.

        Args:
          program   - a list of program names. Use all connected programs if empty.
          actors    - an optional list of actors that the commander can command.
        """

        if not cmd:
            cmd = self.defaultCmd

        if not programs:
            programs = []
            for name, cmdr in g.commanders.items():
                if cmdr.needsAuth and name not in self.programs:
                    programs.append(name)

        if self.debug > 3:
            CPL.log("auth.addPrograms",
                    "adding programs %s with actors=%s" % (programs, actors))

        for prog in programs:
            if prog in self.programs:
                cmd.warn("permsTxt=%s" % \
                         (CPL.qstr("Program %s already has an authorization entry, which will not be modified." % (prog))))
                continue
            self.programs[prog] = {}
            self.setActorsForProgram(prog, actors, cmd=cmd)
        self.genProgramsKey(cmd=cmd)
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:31,代码来源:Auth.py

示例10: statusCmd

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def statusCmd(self, cmd, doFinish=True):
        """ """

        cmd.inform("vocabStats=%s,%d" % (CPL.qstr(self.name), self.totalCommands))
        
        if doFinish:
            cmd.finish()
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:9,代码来源:InternalCmd.py

示例11: __str__

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
 def __str__(self):
     if self.cmd == None:
         dcmd = None
     else:
         dcmd = self.cmd if len(self.cmd) < 1000 else self.cmd[:1000] + "...."
     return "Command(xid=%s, cmdr=%s, cmdrCid=%s, cmdrMid=%s, actor=%s, cmd=%s)" % \
            (self.xid, self.cmdrName, self.cmdrCid, self.cmdrMid, self.actorName,
             CPL.qstr(dcmd))
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:10,代码来源:Command.py

示例12: statusCmd

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def statusCmd(self, cmd, name, doFinish=True):
        """ Send sundry status information keywords.
        """

        cmd.inform('ioConfig=%s,%d,%d,"%s"' % \
                   (CPL.qstr(name),
                    self.tryToRead, self.tryToWrite, self.tryToWriteMany))
        cmd.inform('ioQueue=%s,%d,%d,%d' % \
                   (CPL.qstr(name),
                    len(self.outQueue), self.totalQueued, self.maxQueue))
        cmd.inform('ioReads=%s,%d,%d,%d' % \
                   (CPL.qstr(name),
                    self.totalReads, self.totalBytesRead, self.largestRead))
        cmd.inform('ioWrites=%s,%d,%d,%d,%d' % \
                   (CPL.qstr(name),
                    self.totalOutputs, self.totalWrites, self.totalBytesWritten, self.largestWrite))
        if doFinish:
            cmd.finish()
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:20,代码来源:IOHandler.py

示例13: match

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
def match(argv, opts):
    """ Searches an OrderedDict for matches.

    Args:
      argv - an OrderedDict of options.
      opts - a list of duples to match against. The duple parts are the option name
             and a converter. If the converter is None, the option takes no argument.

    Returns:
      matches   - an OrderedDict of the matched options, with converted arguments.
      unmatched - a list of unmatched options from opts.
      leftovers - an OrderedDict of unmatched options from argv.

    Raises:
      Error     - Any parsing or conversion error.
    """

    # Convert the request duples to an OrderedDict
    want = collections.OrderedDict()
    for o in opts:
        try:
            a, b = o
        except Exception as e:
            raise Exception("the argument to Command.matchDicts must be a list of duples")

        want[a] = b

    # Walk over the parsed options, and categorize them
    #
    matches = collections.OrderedDict()
    leftovers = collections.OrderedDict()

    for opt, arg in argv.items():
        # If we are looking for the option, match it and convert the argument.
        if opt in want:
            converter = want[opt]
            if converter == None:
                if arg != None:
                    raise Exception("option %s takes no argument" % (CPL.qstr(opt, tquote="'")))
                matches[opt] = None
            else:
                try:
                    convArg = converter(arg)
                except Exception as e:
                    raise Exception("error with option '%s': %s" % (opt, e))

                matches[opt] = convArg

            # Remove the option from the search list.
            del want[opt]

        # If we are not looking for the option, return it as a leftover
        else:
            leftovers[opt] = arg

    return matches, list(want.keys()), leftovers
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:58,代码来源:args.py

示例14: dropActorsFromProgram

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
    def dropActorsFromProgram(self, program, actors, cmd=None):
        """ Remove a list of actors to a commander's authorized list.
        """

        if self.debug > 3:
            CPL.log("auth.dropActors", "dropping actors for program %s: %s" % (program, actors))
            
        try:
            d = self.programs[program]
        except KeyError as e:
            cmd.fail("permsTxt=%s" % (CPL.qstr("Program %s did not have an authorization entry, so could not be modified" % (program))))
            return

        for a in actors:
            try:
                del d[a]
            except KeyError:
                cmd.warn("permsTxt=%s" % (CPL.qstr("Actor %s was not in program %s's athorized list" % (a, program))))

        self.genAuthKeys(programs=[program], cmd=cmd)
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:22,代码来源:Auth.py

示例15: startAllListeners

# 需要导入模块: import CPL [as 别名]
# 或者: from CPL import qstr [as 别名]
def startAllListeners(names):
    """ Create all default connections, as defined by the proper configuration file. """

    for n in names:
        try:
            hub.startNub(n)
        except Exception as e:
            sys.stderr.write("FAILED to start nub %s: %s\n" % (n, e))
            try:
                g.hubcmd.warn('text=%s' % (CPL.qstr('FAILED to start nub %s: %s\n', n, e)))
            except:
                sys.stderr.write("hubcmd.warn failed\n")
开发者ID:Subaru-PFS,项目名称:tron_tron,代码行数:14,代码来源:runhub.py


注:本文中的CPL.qstr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。