• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python smart._函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中smart._函数的典型用法代码示例。如果您正苦于以下问题:Python _函数的具体用法?Python _怎么用?Python _使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _exec

 def _exec(self, command, **kwargs):
     p = pexpect.spawn(command, timeout=1)
     p.setecho(False)
     outlist = []
     while True:
         i = p.expect([pexpect.EOF, pexpect.TIMEOUT,
                       r"assword:", r"passphrase for key '.*':",
                       r"\(yes/no\)?"])
         if i == 0:
             outlist.append(p.before)
             break
         elif i == 1:
             outlist.append(p.before)
         elif i == 2 or i == 3:
             if self.password:
                 password = self.password
             elif self.getpassword:
                 password = self.getpassword()
             else:
                 raise Error, _("SSH asked for password, "
                                "but no password is available")
             p.sendline(password)
             outlist = []
         elif i == 4:
             p.sendline("yes")
             outlist = []
     while p.isalive():
         try:
             time.sleep(1)
         except (pexpect.TIMEOUT, pexpect.EOF):
             # Continue until the child dies
             pass
     while outlist and outlist[0].startswith("Warning:"):
         outlist.pop(0)
     return p.exitstatus, "".join(outlist).strip()
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:35,代码来源:ssh.py


示例2: check_args_of_option

 def check_args_of_option(self, opt, nargs, err=None):
     given_opts = getattr(self, "_given_opts", [])
     if not opt in given_opts:
         return
     values = getattr(self, opt, [])
     if type(values) != type([]):
         return
     if nargs < 0:
         nargs = -nargs
         if len(values) >= nargs:
             return
         if not err:
             if nargs == 1:
                 err = _("Option '%s' requires at least one argument") % opt
             else:
                 err = _("Option '%s' requires at least %d arguments") % (opt, nargs)
         raise Error, err
     elif nargs == 0:
         if len( values ) == 0:
             return
         raise Error, err
     else:
         if len(values) == nargs:
             return
         if not err:
             if nargs == 1:
                 err = _("Option '%s' requires one argument") % opt
             else:
                 err = _("Option '%s' requires %d arguments") % (opt, nargs)
         raise Error, err
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:30,代码来源:option.py


示例3: __call__

    def __call__(self, data):
        for line in data.splitlines():
            what, pkgname, status = line.split(":", 2)
            what = what.strip()
            pkgname = pkgname.strip()
            status = status.strip()
            if what != "status":
                return
            if self.op is CONFIG and status == "unpacked":  # odd duplicate
                return
            if not pkgname in self.pkgs:
                return

            op = self.op
            pkg = self.pkgs[pkgname]
            subkey = "%s:%s" % (op, pkgname)
            if op is REMOVE:
                self.prog.setSubTopic(subkey, _("Removing %s") % pkg.name)
                if status == "installed" and subkey not in self.seen:
                    self.seen[subkey] = True
                    self.prog.setSub(subkey, 0, 1, 1)
                elif status == "config-files" and subkey in self.seen:
                    del self.seen[subkey]
                    self.prog.setSubDone(subkey)
                self.prog.show()
            elif op is PURGE:
                self.prog.setSubTopic(subkey, _("Purging %s") % pkg.name)
                if status == "installed" and subkey not in self.seen:
                    self.seen[subkey] = True
                    self.prog.setSub(subkey, 0, 1, 1)
                elif status == "not-installed" and subkey in self.seen:
                    del self.seen[subkey]
                    self.prog.setSubDone(subkey)
                self.prog.show()
            elif op is UNPACK:
                self.prog.setSubTopic(subkey, _("Unpacking %s") % pkg.name)
                if status == "half-installed" and subkey not in self.seen:
                    self.seen[subkey] = True
                    self.prog.setSub(subkey, 0, 1, 1)
                elif status == "unpacked" and subkey in self.seen:
                    del self.seen[subkey]
                    self.prog.setSubDone(subkey)
                self.prog.show()
            elif op is CONFIG:
                self.prog.setSubTopic(subkey, _("Configuring %s") % pkg.name)
                if status == "half-configured" and subkey not in self.seen:
                    self.seen[subkey] = True
                    self.prog.setSub(subkey, 0, 1, 1)
                elif status == "installed" and subkey in self.seen:
                    del self.seen[subkey]
                    self.prog.setSubDone(subkey)
                self.prog.show()
开发者ID:pombredanne,项目名称:packagemanagement,代码行数:52,代码来源:pm.py


示例4: postParse

def postParse(data):
    import re
    withre = re.compile("\s+with\s+", re.I)
    if withre.search(data["baseurl"]):
        if "hdlurl" in data:
            raise Error, _("Base URL has 'with', but Header List URL "
                           "was provided")
        tokens = withre.split(data["baseurl"])
        if len(tokens) != 2:
            raise Error, _("Base URL has invalid 'with' pattern")
        data["baseurl"] = tokens[0].strip()
        if tokens[1].strip():
            data["hdlurl"] = tokens[1].strip()
    return data
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:14,代码来源:urpmi_info.py


示例5: secondsToStr

def secondsToStr(time):
    if not time:
        return _("Unknown")
    elif time == 0:
        return "0s"
    elif time < 1:
        return "1s"
    else:
        minutes, seconds = divmod(time, 60)
        hours, minutes = divmod(minutes, 60)
        if hours > 99:
            return _("Stalled")
        elif hours > 0:
            return "%02ih%02im%02is" % (hours, minutes, seconds)
        elif minutes > 0:
            return "%02im%02is" % (minutes, seconds)
        else:
            return "%02is" % seconds
开发者ID:pierrejean-coudert,项目名称:winlibrepacman,代码行数:18,代码来源:strtools.py


示例6: sizeToStr

def sizeToStr(bytes):
    if bytes is None:
        return _("Unknown")
    if bytes < 1024:
        return "%dB" % bytes
    elif bytes < 1024000:
        return "%.1fkB" % (bytes/1024.)
    else:
        return "%.1fMB" % (bytes/1024000.)
开发者ID:pierrejean-coudert,项目名称:winlibrepacman,代码行数:9,代码来源:strtools.py


示例7: speedToStr

def speedToStr(speed):
    if speed < 1:
        return _("Stalled")
    elif speed < 1024:
        return "%dB/s" % speed
    elif speed < 1024000:
        return "%.1fkB/s" % (speed/1024.)
    else:
        return "%.1fMB/s" % (speed/1024000.)
开发者ID:pierrejean-coudert,项目名称:winlibrepacman,代码行数:9,代码来源:strtools.py


示例8: _process_short_opts

    def _process_short_opts(self, rargs, values):
        arg = rargs.pop(0)
        stop = False
        i = 1
        for ch in arg[1:]:
            opt = "-" + ch
            option = self._short_opt.get(opt)
            i += 1                      # we have consumed a character

            if not option:
                # That's the reason to change this function. We must
                # raise an error so that the argument is post-processed
                # when using skipunknown.
                raise optparse.BadOptionError, _("no such option: %s") % opt
            if option.takes_value():
                # Any characters left in arg?  Pretend they're the
                # next arg, and stop consuming characters of arg.
                if i < len(arg):
                    rargs.insert(0, arg[i:])
                    stop = True

                nargs = option.nargs
                if len(rargs) < nargs:
                    if nargs == 1:
                        self.error(_("%s option requires an argument") % opt)
                    else:
                        self.error(_("%s option requires %d arguments")
                                   % (opt, nargs))
                elif nargs == 1:
                    value = rargs.pop(0)
                else:
                    value = tuple(rargs[0:nargs])
                    del rargs[0:nargs]

            else:                       # option doesn't take a value
                value = None

            option.process(opt, value, values, self)

            if stop:
                break
开发者ID:KortanZ,项目名称:linux,代码行数:41,代码来源:option.py


示例9: __fetchFile

 def __fetchFile(self, file, fetcher, progress, uncompress=False):
     fetcher.reset()
     item = fetcher.enqueue(file,uncomp=uncompress)
     fetcher.run(progress=progress)
     failed = item.getFailedReason()
     if failed:
         progress.add(self.getFetchSteps()-1)
         progress.show()
         if fetcher.getCaching() is NEVER:
             lines = [_("Failed acquiring information for '%s':") % self,
                      "%s: %s" % (item.getURL(), failed)]
             raise Error, "\n".join(lines)
     return item
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:13,代码来源:yast2.py


示例10: strToBool

def strToBool(s, default=False):
    if type(s) in (bool, int):
        return bool(s)
    if not s:
        return default
    s = s.strip().lower()
    if s in ("y", "yes", "true", "1", _("y"), _("yes"), _("true")):
        return True
    if s in ("n", "no", "false", "0", _("n"), _("no"), _("false")):
        return False
    return default
开发者ID:pierrejean-coudert,项目名称:winlibrepacman,代码行数:11,代码来源:strtools.py


示例11: format_help

 def format_help(self, formatter=None):
     if formatter is None:
         formatter = self.formatter
     if self._override_help:
         result = self._override_help.strip()
         result += "\n"
     else:
         result = optparse.OptionParser.format_help(self, formatter)
         result = result.strip()
         result += "\n"
         if self._examples:
             result += formatter.format_heading(_("examples"))
             formatter.indent()
             for line in self._examples.strip().splitlines():
                 result += " "*formatter.current_indent
                 result += line+"\n"
             formatter.dedent()
     result += "\n"
     return result
开发者ID:KortanZ,项目名称:linux,代码行数:19,代码来源:option.py


示例12: or

#
# Written by Gustavo Niemeyer <[email protected]>
#
# This file is part of Smart Package Manager.
#
# Smart Package Manager is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# Smart Package Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
from smart import _

kind = "package"

name = _("DPKG Installed Packages")

description = _("""
Installed packages from dpkg status.
""")

fields = []
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:30,代码来源:deb_sys_info.py


示例13: or

#
# Written by Joel Martin <[email protected]>
#
# This file is part of Smart Package Manager.
#
# Smart Package Manager is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# Smart Package Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
from smart import _

kind = "package"

name = _("Solaris Installed Packages and Patches")

description = _("""
Installed packages and patches from the local Solaris databases.
""")

fields = []
开发者ID:NehaRawat,项目名称:spacewalk,代码行数:30,代码来源:solaris_sys_info.py


示例14: format_usage

 def format_usage(self, usage):
     return _("Usage: %s\n") % usage
开发者ID:KortanZ,项目名称:linux,代码行数:2,代码来源:option.py


示例15: format_heading

 def format_heading(self, heading):
     heading = _(heading)
     return "\n%*s%s:\n" % (self.current_indent, "", heading.capitalize())
     _("options")
开发者ID:KortanZ,项目名称:linux,代码行数:4,代码来源:option.py


示例16: _

# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
from smart.util import optparse
from smart import Error, _
import textwrap
import sys, os

# NOTICE: The standard optparse module haven't been touched, but since
#         this code subclasses it and trusts on a specific interface,
#         an internal copy is being used to avoid future breakage.

__all__ = ["OptionParser", "OptionValueError", "append_all"]

try:
    optparse.STD_HELP_OPTION.help = \
            _("show this help message and exit")
    optparse.STD_VERSION_OPTION.help = \
            _("show program's version number and exit")
except AttributeError:
    optparse._ = _

OptionValueError = optparse.OptionValueError

class HelpFormatter(optparse.HelpFormatter):

    def __init__(self):
        optparse.HelpFormatter.__init__(self, 2, 24, 79, 1)

    def format_usage(self, usage):
        return _("Usage: %s\n") % usage
开发者ID:KortanZ,项目名称:linux,代码行数:30,代码来源:option.py


示例17: _

# your option) any later version.
#
# Smart Package Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
from smart import _

kind = "package"

name = _("APT-DEB Repository")

description = _("""
Repositories created for APT-DEB.
""")

fields = [("baseurl", _("Base URL"), str, None,
           _("Base URL of repository, where dists/ is located.")),
          ("distribution", _("Distribution"), str, None,
           _("Distribution to use.")),
          ("components", _("Components"), str, "",
           _("Space separated list of components.")),
          ("fingerprint", _("Fingerprint"), str, "",
           _("GPG fingerprint of key signing the channel.")),
          ("keyring", _("Keyring"), str, "",
           _("If provided, channel must necessarily be signed by a key "
开发者ID:nikhilgv9,项目名称:winlibrepacman,代码行数:31,代码来源:apt_deb_info.py


示例18: or

# Smart Package Manager is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# Smart Package Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
from smart import _

kind = "package"

name = _("Slackware Repository")

description = _("""
Remote repository with slackware packages.
""")

fields = [("baseurl", _("Base URL"), str, None,
           _("Base URL where PACKAGES.TXT is located")),
          ("compressed", _("Compressed"), bool, False,
          _("Whether PACKAGES.TXT is gzip compressed")),
          ("fingerprint", _("Fingerprint"), str, "",
           _("GPG fingerprint of key signing the channel."))]
开发者ID:Kampi,项目名称:Zybo-Linux,代码行数:30,代码来源:slack_site_info.py


示例19: _

# your option) any later version.
#
# Smart Package Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
from smart import _

kind = "package"

name = _("URPMI Repository")

description = _(
    """
Repository created for Mandriva's URPMI package manager.
"""
)

fields = [
    (
        "baseurl",
        _("Base URL"),
        str,
        None,
        _(
            "Base URL where packages or the 'list' file are found under. "
开发者ID:pombredanne,项目名称:winlibrepacman,代码行数:31,代码来源:urpmi_info.py


示例20: or

# Written by Gustavo Niemeyer <[email protected]>
#
# This file is part of Smart Package Manager.
#
# Smart Package Manager is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
#
# Smart Package Manager is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
from smart import _

kind = "package"

name = _("PDK Component")

description = _("""
Local directory with DEB packages.
""")

fields = [("path", _("Directory Path"), str, None,
           _("Path of directory containing DEB packages."))]
开发者ID:64studio,项目名称:pdk,代码行数:30,代码来源:pdk_deb_info.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cache.Loader类代码示例发布时间:2022-05-27
下一篇:
Python util.periodicSequentialCall函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap