本文整理汇总了Python中tambo.Transport类的典型用法代码示例。如果您正苦于以下问题:Python Transport类的具体用法?Python Transport怎么用?Python Transport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transport类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: Source
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,代码行数:26,代码来源:source.py
示例2: parse_args
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,代码行数:8,代码来源:server.py
示例3: parse_args
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,代码行数:8,代码来源:pytest.py
示例4: Hello
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,代码行数:52,代码来源:hello.py
示例5: parse_args
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,代码行数:13,代码来源:iso.py
示例6: Exists
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,代码行数:50,代码来源:exists.py
示例7: Repo
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,代码行数:50,代码来源:repos.py
示例8: BaseBackend
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,代码行数:15,代码来源:base.py
示例9: Build
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,代码行数:48,代码来源:build.py
示例10: main
def main(self):
self.parser = Transport(self.argv, options=self.options)
self.parser.catch_help = self._help
self.parser.parse_args()
self.force = self.parser.has('--force')
# handle posting binaries:
if self.parser.has('create'):
url_part = self.sanitize_url(self.parser.get('create'))
if not sys.stdin.isatty():
# read from stdin
logger.info('reading input from stdin')
for line in sys.stdin.readlines():
filename = self.sanitize_filename(line)
if not filename:
continue
url = os.path.join(self.base_url, url_part)
self.post(url, filename)
else:
filepath = self.sanitize_filename(self.argv[-1])
if not filepath:
logger.warning(
'provided path does not exist: %s', self.argv[-1]
)
return
url = os.path.join(self.base_url, url_part)
self.post(url, filepath)
elif self.parser.has('delete'):
url_part = self.sanitize_url(self.parser.get('delete'))
url = os.path.join(self.base_url, url_part)
self.delete(url)
开发者ID:ahills,项目名称:chacractl,代码行数:32,代码来源:binaries.py
示例11: parse_args
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()
开发者ID:alfredodeza,项目名称:merfi,代码行数:7,代码来源:base.py
示例12: parse_args
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,代码行数:13,代码来源:extend.py
示例13: Clone
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,代码行数:45,代码来源:clone.py
示例14: main
def main(self):
self.parser = Transport(self.argv, options=self.options)
self.parser.catch_help = self.help()
self.parser.parse_args()
try:
build_number = int(self.parser.unknown_commands[0])
except (IndexError, ValueError):
return self.parser.print_help()
self.watch(build_number)
开发者ID:ktdreyer,项目名称:rhcephpkg,代码行数:9,代码来源:watch_build.py
示例15: main
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)
开发者ID:red-hat-storage,项目名称:rhcephpkg,代码行数:9,代码来源:clone.py
示例16: main
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,代码行数:10,代码来源:exists.py
示例17: main
def main(self):
self.parser = Transport(self.argv, options=self.options)
self.parser.catch_help = self.help()
self.parser.parse_args()
force = False
if self.parser.has(['--force', '--hard-reset']):
force = True
if self.parser.unknown_commands:
log.error('unknown option %s',
' '.join(self.parser.unknown_commands))
return self.parser.print_help()
self._run(force)
开发者ID:ktdreyer,项目名称:rhcephpkg,代码行数:12,代码来源:merge_patches.py
示例18: main
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,代码行数:14,代码来源:repos.py
示例19: main
def main(self):
self.parser = Transport(self.argv, options=self.options)
self.parser.catch_help = self.help()
self.parser.parse_args()
# FIXME: stop hardcoding trusty. Use the git branch name instead,
# translating "-ubuntu" into this local computer's own distro.
distro = 'trusty'
# Allow user to override the distro.
if self.parser.has('--dist'):
if self.parser.get('--dist') is None:
raise SystemExit('Specify a distro to --dist')
distro = self.parser.get('--dist')
self._run(distro)
开发者ID:red-hat-storage,项目名称:rhcephpkg,代码行数:15,代码来源:localbuild.py
示例20: parse_args
def parse_args(self, argv):
"""
Main method for parsing arguments, it uses whatever `argv` is although
it should always be a list. Once it goes through the ``Transport`` class
it tries to generate the help from the mapped classes and the current
docstring for this module.
If nothing matches it will return the help.
"""
self.get_extend_commands()
transport = Transport(argv, self.mapper)
transport.catch_help = "%s \n%s" % (__doc__, transport.subhelp())
transport.catch_version = "dozo version {0}".format(__version__)
if len(self.argv) <= 1:
transport.print_help()
transport.dispatch()
开发者ID:johnmontero,项目名称:dozo,代码行数:18,代码来源:__init__.py
注:本文中的tambo.Transport类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论