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


Python Transport.parse_args方法代码示例

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


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

示例1: Source

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
class Source(object):
    help_menu = 'build a source package on the local system'
    _help = """
Build a source package on the local system.
"""
    name = 'source'

    def __init__(self, argv):
        self.argv = argv

    def main(self):
        self.parser = Transport(self.argv)
        self.parser.catch_help = self.help()
        self.parser.parse_args()
        self._run()

    def help(self):
        return self._help

    def _run(self):
        """ Build a source package on the local system. """
        util.setup_pristine_tar_branch()
        cmd = ['gbp', 'buildpackage', '--git-tag', '--git-retag', '-S',
               '-us', '-uc']
        log.info(' '.join(cmd))
        subprocess.check_call(cmd)
开发者ID:ktdreyer,项目名称:rhcephpkg,代码行数:28,代码来源:source.py

示例2: main

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
    def main(self, argv):
        # Console Logger
        sh = logging.StreamHandler()
        sh.setFormatter(log.color_format())
        sh.setLevel(logging.DEBUG)

        root_logger = logging.getLogger()
        root_logger.setLevel(logging.DEBUG)
        root_logger.addHandler(sh)

        self.api_credentials()

        # TODO: Need to implement `--filename` and make it available
        options = [['--log', '--logging']]
        parser = Transport(argv, mapper=self.mapper,
                           options=options, check_help=False,
                           check_version=False)
        parser.parse_args()
        chacractl.config['verbosity'] = parser.get('--log', 'info')
        parser.catch_help = self.help()
        parser.catch_version = chacractl.__version__
        parser.mapper = self.mapper
        if len(argv) <= 1:
            return parser.print_help()
        parser.dispatch()
        parser.catches_help()
        parser.catches_version()
开发者ID:ceph,项目名称:chacractl,代码行数:29,代码来源:main.py

示例3: parse_args

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
 def parse_args(self):
     parser = Transport(self.argv, options=['--socket-location'])
     parser.catch_help = self._help
     parser.parse_args()
     location = parser.get('--socket-location') or '/tmp/pytest.sock'
     delgado.config['allowed'] = ['py.test']
     engine = Engine(socket_location=location)
     engine.run_forever()
开发者ID:alfredodeza,项目名称:delgado,代码行数:10,代码来源:pytest.py

示例4: parse_args

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
 def parse_args(self):
     options = ['--allowed']
     parser = Transport(self.argv, options=options)
     parser.catch_help = self._help
     parser.parse_args()
     delgado.config['allowed'] = parser.get('--allowed') or []
     engine = Engine(connection=self.connection)
     engine.run_forever()
开发者ID:johnmontero,项目名称:delgado,代码行数:10,代码来源:server.py

示例5: Hello

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
class Hello(object):
    help_menu = 'test authentication to Jenkins'
    _help = """
Test authentication to Jenkins and return your user's fullName attribute.
"""
    name = 'hello'

    def __init__(self, argv):
        self.argv = argv
        self.options = []

    def main(self):
        self.parser = Transport(self.argv, options=self.options)
        self.parser.catch_help = self.help()
        self.parser.parse_args()
        self._run()

    def help(self):
        return self._help

    def _run(self):
        """ Authenticate to Jenkins and print our username to STDOUT.
            Useful for checking that our authentication credentials are
            correct. """
        jenkins = util.jenkins_connection()
        # python-jenkins does not have syntactic support for "whoami" (the
        # "/me/api/json" endpoint), so we have to hit it and parse it
        # ourselves.
        # https://review.openstack.org/307896

        whoami_url = posixpath.join(jenkins.url, 'me/api/json')
        try:
            response = jenkins.jenkins_open(Request(whoami_url))
            data = json.loads(response)
        except JenkinsException as err:
            raise SystemExit(err)

        name = data['fullName']  # Our Jenkins instance gets this from LDAP
        try:
            jenkins_version = jenkins.get_version()
        except AttributeError:
            # python-jenkins older than 0.4.1 does not have get_version().
            version_url = jenkins.server
            try:
                response = urlopen(Request(version_url))
                if six.PY2:
                    jenkins_version = response.info().getheader('X-Jenkins')
                else:
                    jenkins_version = response.getheader('X-Jenkins')
            except (HTTPError, BadStatusLine) as err:
                raise SystemExit(err)
        print('Hello %s from Jenkins %s' % (name, jenkins_version))
开发者ID:ktdreyer,项目名称:rhcephpkg,代码行数:54,代码来源:hello.py

示例6: parse_args

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
 def parse_args(self, argv=None):
     """ pass argv during testing """
     if argv is None:
         argv = self.argv
     options = [['--output', '-o']]
     parser = Transport(argv, options=options)
     parser.catch_help = self.help()
     parser.parse_args()
     self.source = util.infer_path(parser.unknown_commands)
     self.output = parser.get('--output', self.source + '-dvd.iso')
     self.check_dependency()
     self.make_iso()
     self.make_sha256sum()
开发者ID:alfredodeza,项目名称:merfi,代码行数:15,代码来源:iso.py

示例7: parse_args

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
    def parse_args(self):
        transport = Transport(self.argv, check_help=False)
        transport.catch_help = self.__doc__
        if len(self.argv) <= 1:
            transport.print_help()
        transport.parse_args()

        for action in self.actions:
            if transport.has(action):
                return self.actions.get(action)()

        # If nothing matches, print the help
        transport.print_help()
开发者ID:johnmontero,项目名称:dozo,代码行数:15,代码来源:extend.py

示例8: main

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
 def main(self, argv):
     parser = Transport(argv, mapper=self.mapper,
                        options=[], check_help=False,
                        check_version=False)
     parser.parse_args()
     parser.catch_help = self.help(parser.subhelp())
     parser.catch_version = ceph_installer.__version__
     parser.mapper = self.mapper
     if len(argv) <= 1:
         return parser.print_help()
     parser.dispatch()
     parser.catches_help()
     parser.catches_version()
开发者ID:b-ranto,项目名称:ceph-installer,代码行数:15,代码来源:main.py

示例9: main

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
 def main(self, argv):
     options = []
     parser = Transport(argv, mapper=self.mapper,
                        options=options, check_help=False,
                        check_version=False)
     parser.parse_args()
     parser.catch_help = self.help()
     parser.catch_version = rhcephpkg.__version__
     parser.mapper = self.mapper
     if len(argv) <= 1:
         return parser.print_help()
     parser.dispatch()
     parser.catches_help()
     parser.catches_version()
开发者ID:ktdreyer,项目名称:rhcephpkg,代码行数:16,代码来源:main.py

示例10: Repo

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
class Repo(object):
    _help = dedent(
        """
    Operate on repositories on a remote chacra instance. Both `recreate` and
    `update` calls are not immediate. They rely on the async service managing
    repos which usually have a delay applied to them.

    Options:

    recreate        Mark a repository to be removed and created from scratch
                    again.
    update          Repository will get updated by running the repo tools on
                    it again.
    """
    )
    help_menu = "recreate, delete, or update repositories"
    options = ["recreate", "update"]

    def __init__(self, argv):
        self.argv = argv

    @property
    def base_url(self):
        return os.path.join(chacractl.config["url"], "repos")

    @catches(requests.exceptions.HTTPError, handler=requests_errors)
    def post(self, url):
        exists = requests.head(url, auth=chacractl.config["credentials"], verify=chacractl.config["ssl_verify"])
        exists.raise_for_status()
        logger.info("POST: %s", url)
        response = requests.post(url, auth=chacractl.config["credentials"], verify=chacractl.config["ssl_verify"])
        response.raise_for_status()
        json = response.json()
        for k, v in json.items():
            logger.info("%s: %s", k, v)

    def main(self):
        self.parser = Transport(self.argv, options=self.options)
        self.parser.catch_help = self._help
        self.parser.parse_args()
        recreate = self.parser.get("recreate")
        update = self.parser.get("update")
        if recreate:
            url_part = os.path.join(recreate, "recreate")
            url = os.path.join(self.base_url, url_part)
            self.post(url)
        elif update:
            url_part = os.path.join(update, "update")
            url = os.path.join(self.base_url, url_part)
            self.post(url)
开发者ID:ceph,项目名称:chacractl,代码行数:52,代码来源:repos.py

示例11: Exists

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
class Exists(object):
    _help = dedent("""
    Check if a given URL part exists already. Mainly does a HEAD request to the
    given endpoint. If the URL does not exist it will return a non-zero exit
    status (404).

    For example:

        chacractl exists binaries/ceph-deploy/master/debian/wheezy

    Positional Arguments:

    [URL]        The endpoint, starting with the full url part (sans fqdn)
    """)
    help_menu = "check if a given URL part exists already"
    options = []

    def __init__(self, argv):
        self.argv = argv
        self.base_url = chacractl.config['url']

    def sanitize_url(self, url_part):
        # get rid of the leading slash to prevent issues when joining
        url = url_part.lstrip('/')

        # and add a trailing slash so that the request is done at the correct
        # canonical url
        if not url.endswith('/'):
            url = "%s/" % url
        return url

    @catches(requests.exceptions.HTTPError, handler=requests_errors)
    def head(self, url):
        logger.info('HEAD: %s', url)
        exists = requests.head(
            url,
            auth=chacractl.config['credentials'],
            verify=chacractl.config['ssl_verify'])
        exists.raise_for_status()

    def main(self):
        self.parser = Transport(self.argv, options=self.options)
        self.parser.catch_help = self._help
        self.parser.parse_args()
        if self.parser.unknown_commands:
            url_part = self.sanitize_url(self.parser.unknown_commands[-1])
            url = os.path.join(self.base_url, url_part)
            return self.head(url)
        else:
            logger.error('no url was passed in')
开发者ID:ahills,项目名称:chacractl,代码行数:52,代码来源:exists.py

示例12: BaseBackend

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
class BaseBackend(base.BaseCommand):

    options = []
    parser = None

    def parse_args(self):
        self.parser = Transport(self.argv, options=self.options)
        self.parser.catch_help = self.help()
        self.parser.parse_args()
        self.path = util.infer_path(self.parser.unknown_commands)
        self.check_dependency()
        self.sign()

    def sign(self):
        raise NotImplemented()
开发者ID:alfredodeza,项目名称:merfi,代码行数:17,代码来源:base.py

示例13: Build

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
class Build(object):
    help_menu = "build a package in Jenkins"
    _help = """
Build a package in Jenkins.
"""
    name = "build"

    def __init__(self, argv):
        self.argv = argv
        self.options = []

    def main(self):
        self.parser = Transport(self.argv, options=self.options)
        self.parser.catch_help = self.help()
        self.parser.parse_args()
        self._run()

    def help(self):
        return self._help

    def _run(self):
        """ Build a package in Jenkins. """
        pkg_name = util.package_name()
        branch_name = util.current_branch()
        jenkins = util.jenkins_connection()

        if branch_name.startswith("patch-queue/"):
            log.error("%s a patch-queue branch" % branch_name)
            msg = 'You can switch to the debian branch with "gbp pq switch"'
            raise SystemExit(msg)

        log.info(
            "building %s branch %s at %s", pkg_name, branch_name, posixpath.join(jenkins.url, "job", "build-package")
        )
        job_params = {"PKG_NAME": pkg_name, "BRANCH": branch_name}

        if self._has_broken_build_job():
            jenkins.build_job = types.MethodType(_build_job_fixed, jenkins)

        jenkins.build_job("build-package", parameters=job_params, token=jenkins.password)

    def _has_broken_build_job(self):
        # Ubuntu Trusty ships python-jenkins 0.2.1-0ubuntu1, and this version
        # has a broken build_job() method. See
        # https://bugs.launchpad.net/bugs/1177831 .
        # This bug was fixed in python-jenkins v0.3.2 upstream.
        v = get_distribution("python_jenkins").version
        return parse_version(v) < parse_version("0.3.2")
开发者ID:red-hat-storage,项目名称:rhcephpkg,代码行数:50,代码来源:build.py

示例14: main

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
 def main(self, argv):
     options = [['--log', '--logging']]
     parser = Transport(argv, mapper=self.mapper,
                        options=options, check_help=False,
                        check_version=False)
     parser.parse_args()
     merfi.config['verbosity'] = parser.get('--log', 'info')
     merfi.config['check'] = parser.has('--check')
     parser.catch_help = self.help()
     parser.catch_version = merfi.__version__
     parser.mapper = self.mapper
     if len(argv) <= 1:
         return parser.print_help()
     parser.dispatch()
     parser.catches_help()
     parser.catches_version()
开发者ID:alfredodeza,项目名称:merfi,代码行数:18,代码来源:main.py

示例15: Clone

# 需要导入模块: from tambo import Transport [as 别名]
# 或者: from tambo.Transport import parse_args [as 别名]
class Clone(object):
    help_menu = 'clone a package from dist-git'
    _help = """
Clone a package from dist-git. Your SSH key must be set up in Gerrit.

Positional Arguments:

[package]  The name of the package to clone.
"""
    name = 'clone'

    def __init__(self, argv):
        self.argv = argv
        self.options = []

    def main(self):
        self.parser = Transport(self.argv, options=self.options)
        self.parser.catch_help = self.help()
        self.parser.parse_args()
        try:
            pkg = self.parser.unknown_commands[0]
        except IndexError:
            return self.parser.print_help()
        self._run(pkg)

    def help(self):
        return self._help

    def _run(self, pkg):
        """ Clone a package from dist-git. """
        if os.path.exists(pkg):
            raise SystemExit('%s already exists in current working directory.',
                             pkg)
        configp = util.config()
        try:
            user = configp.get('rhcephpkg', 'user')
            gitbaseurl = configp.get('rhcephpkg', 'gitbaseurl')
        except configparser.Error as err:
            raise SystemExit('Problem parsing .rhcephpkg.conf: %s',
                             err.message)
        # TODO: SafeConfigParser might make the "user" interpolation here
        # unnecessary? Need to test, particularly what it does to %(module).
        pkg_url = gitbaseurl % {'user': user, 'module': pkg}
        cmd = ['git', 'clone', pkg_url]
        subprocess.check_call(cmd)
开发者ID:red-hat-storage,项目名称:rhcephpkg,代码行数:47,代码来源:clone.py


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