本文整理汇总了Python中rbtools.get_version_string函数的典型用法代码示例。如果您正苦于以下问题:Python get_version_string函数的具体用法?Python get_version_string怎么用?Python get_version_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_version_string函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
origcwd = os.path.abspath(os.getcwd())
if 'APPDATA' in os.environ:
homepath = os.environ['APPDATA']
elif 'HOME' in os.environ:
#homepath = os.environ["HOME"]
homepath = '/usr/local/bin/perforce'
else:
homepath = ''
# If we end up creating a cookie file, make sure it's only readable by the
# user.
os.umask(0077)
# Load the config and cookie files
cookie_file = os.path.join(homepath, ".post-review-cookies.txt")
user_config, globals()['configs'] = load_config_files(homepath)
args = parse_options(sys.argv[1:])
debug('RBTools %s' % get_version_string())
debug('Python %s' % sys.version)
debug('Running on %s' % (platform.platform()))
debug('Home = %s' % homepath)
debug('Current Directory = %s' % os.getcwd())
debug('Checking the repository type. Errors shown below are mostly harmless.')
repository_info, tool = scan_usable_client(options)
debug('Finished checking the repository type.')
tool.user_config = user_config
tool.configs = configs
# Verify that options specific to an SCM Client have not been mis-used.
tool.check_options()
if repository_info.supports_changesets:
changenum = tool.get_changenum(args)
else:
changenum = None
if options.revision_range:
diff, parent_diff = tool.diff_between_revisions(options.revision_range, args,
repository_info)
elif options.svn_changelist:
diff, parent_diff = tool.diff_changelist(options.svn_changelist)
elif options.diff_filename:
parent_diff = None
if options.diff_filename == '-':
diff = sys.stdin.read()
else:
try:
fp = open(os.path.join(origcwd, options.diff_filename), 'r')
diff = fp.read()
fp.close()
except IOError, e:
die("Unable to open diff filename: %s" % e)
示例2: main
def main():
"""Execute a command."""
def exit_on_int(sig, frame):
sys.exit(128 + sig)
signal.signal(signal.SIGINT, exit_on_int)
parser = OptionParser(prog=RB_MAIN,
usage='%prog [--version] <command> [options]'
' [<args>]',
option_list=GLOBAL_OPTIONS,
add_help_option=False,
version='RBTools %s' % get_version_string())
parser.disable_interspersed_args()
opt, args = parser.parse_args()
if not args:
help([], parser)
command_name = args[0]
if command_name == "help":
help(args[1:], parser)
elif opt.help or "--help" in args or '-h' in args:
help(args, parser)
# Attempt to retrieve the command class from the entry points. We
# first look in rbtools for the commands, and failing that, we look
# for third-party commands.
ep = pkg_resources.get_entry_info("rbtools", "rbtools_commands", args[0])
if not ep:
try:
ep = pkg_resources.iter_entry_points('rbtools_commands',
args[0]).next()
except StopIteration:
# There aren't any custom entry points defined.
pass
if ep:
try:
command = ep.load()()
except ImportError:
# TODO: It might be useful to actual have the strack
# trace here, due to an import somewhere down the import
# chain failing.
sys.stderr.write("Could not load command entry point %s\n" %
ep.name)
sys.exit(1)
except Exception, e:
sys.stderr.write("Unexpected error loading command %s: %s\n" %
(ep.name, e))
sys.exit(1)
command.run_from_argv([RB_MAIN] + args)
示例3: main
def main():
origcwd = os.path.abspath(os.getcwd())
if 'APPDATA' in os.environ:
homepath = os.environ['APPDATA']
elif 'HOME' in os.environ:
homepath = os.environ["HOME"]
else:
homepath = ''
# If we end up creating a cookie file, make sure it's only readable by the
# user.
os.umask(0077)
# Load the config and cookie files
cookie_file = os.path.join(homepath, ".post-review-cookies.txt")
user_config, globals()['configs'] = load_config_files(homepath)
args = parse_options(sys.argv[1:])
debug('RBTools %s' % get_version_string())
debug('Home = %s' % homepath)
repository_info, tool = scan_usable_client(options)
tool.user_config = user_config
tool.configs = configs
# Verify that options specific to an SCM Client have not been mis-used.
tool.check_options()
# Try to find a valid Review Board server to use.
if options.server:
server_url = options.server
else:
server_url = tool.scan_for_server(repository_info)
if not server_url:
print "Unable to find a Review Board server for this source code tree."
sys.exit(1)
server = ReviewBoardServer(server_url, repository_info, cookie_file)
# Handle the case where /api/ requires authorization (RBCommons).
if not server.check_api_version():
die("Unable to log in with the supplied username and password.")
# Let's begin.
server.login()
tempt_fate(server)
示例4: init_logging
def init_logging(self):
"""Initializes logging for the command.
This will set up different log handlers based on the formatting we want
for the given levels.
The INFO log handler will just show the text, like a print statement.
WARNING and higher will show the level name as a prefix, in the form of
"LEVEL: message".
If debugging is enabled, a debug log handler will be set up showing
debug messages in the form of ">>> message", making it easier to
distinguish between debugging and other messages.
"""
root = logging.getLogger()
if self.options.debug:
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('>>> %(message)s'))
handler.setLevel(logging.DEBUG)
handler.addFilter(LogLevelFilter(logging.DEBUG))
root.addHandler(handler)
root.setLevel(logging.DEBUG)
else:
root.setLevel(logging.INFO)
# Handler for info messages. We'll treat these like prints.
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(message)s'))
handler.setLevel(logging.INFO)
handler.addFilter(LogLevelFilter(logging.INFO))
root.addHandler(handler)
# Handler for warnings, errors, and criticals. They'll show the
# level prefix and the message.
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
handler.setLevel(logging.WARNING)
root.addHandler(handler)
logging.debug('RBTools %s', get_version_string())
logging.debug('Python %s', sys.version)
logging.debug('Running on %s', platform.platform())
logging.debug('Home = %s', get_home_path())
logging.debug('Current directory = %s', os.getcwd())
示例5: main
def main():
"""Execute a command."""
parser = OptionParser(prog=RB_MAIN,
usage='%prog [--version] <command> [options]'
' [<args>]',
option_list=GLOBAL_OPTIONS,
add_help_option=False,
version='RBTools %s' % get_version_string())
parser.disable_interspersed_args()
opt, args = parser.parse_args()
if not args:
help([], parser)
command_name = args[0]
if command_name == "help":
help(args[1:], parser)
elif opt.help or "--help" in args or '-h' in args:
help(args, parser)
# Attempt to retrieve the command class from the entry points.
ep = pkg_resources.get_entry_info("rbtools", "rbtools_commands", args[0])
if ep:
try:
command = ep.load()()
except ImportError:
# TODO: It might be useful to actual have the strack
# trace here, due to an import somewhere down the import
# chain failing.
sys.stderr.write("Could not load command entry point %s\n" %
ep.name)
sys.exit(1)
except Exception, e:
sys.stderr.write("Unexpected error loading command %s: %s\n" %
(ep.name, e))
sys.exit(1)
command.run_from_argv([RB_MAIN] + args)
示例6: parse_options
def parse_options(args):
parser = OptionParser(usage="%prog [-pond] [-r review_id] [changenum]",
version="RBTools " + get_version_string())
parser.add_option("-p", "--publish",
dest="publish", action="store_true",
default=get_config_value(configs, 'PUBLISH', False),
help="publish the review request immediately after "
"submitting")
parser.add_option("-r", "--review-request-id",
dest="rid", metavar="ID", default=None,
help="existing review request ID to update")
parser.add_option("-o", "--open",
dest="open_browser", action="store_true",
default=get_config_value(configs, 'OPEN_BROWSER', False),
help="open a web browser to the review request page")
parser.add_option("-n", "--output-diff",
dest="output_diff_only", action="store_true",
default=False,
help="outputs a diff to the console and exits. "
"Does not post")
parser.add_option("--server",
dest="server",
default=get_config_value(configs, 'REVIEWBOARD_URL'),
metavar="SERVER",
help="specify a different Review Board server to use")
parser.add_option("--disable-proxy",
action='store_true',
dest='disable_proxy',
default=not get_config_value(configs, 'ENABLE_PROXY',
True),
help="prevents requests from going through a proxy "
"server")
parser.add_option("--diff-only",
dest="diff_only", action="store_true", default=False,
help="uploads a new diff, but does not update "
"info from changelist")
parser.add_option("--reopen",
dest="reopen", action="store_true", default=False,
help="reopen discarded review request "
"after update")
parser.add_option("--target-groups",
dest="target_groups",
default=get_config_value(configs, 'TARGET_GROUPS'),
help="names of the groups who will perform "
"the review")
parser.add_option("--target-people",
dest="target_people",
default=get_config_value(configs, 'TARGET_PEOPLE'),
help="names of the people who will perform "
"the review")
parser.add_option("--summary",
dest="summary", default=None,
help="summary of the review ")
parser.add_option("--description",
dest="description", default=None,
help="description of the review ")
parser.add_option("--description-file",
dest="description_file", default=None,
help="text file containing a description of the review")
parser.add_option('-g', '--guess-fields',
dest="guess_fields", action="store_true",
default=get_config_value(configs, 'GUESS_FIELDS',
False),
help="equivalent to --guess-summary --guess-description")
parser.add_option("--guess-summary",
dest="guess_summary", action="store_true",
default=get_config_value(configs, 'GUESS_SUMMARY',
False),
help="guess summary from the latest commit (git/"
"hg/hgsubversion only)")
parser.add_option("--guess-description",
dest="guess_description", action="store_true",
default=get_config_value(configs, 'GUESS_DESCRIPTION',
False),
help="guess description based on commits on this branch "
"(git/hg/hgsubversion only)")
parser.add_option("--testing-done",
dest="testing_done", default=None,
help="details of testing done ")
parser.add_option("--testing-done-file",
dest="testing_file", default=None,
help="text file containing details of testing done ")
parser.add_option("--branch",
dest="branch",
default=get_config_value(configs, 'BRANCH'),
help="affected branch ")
parser.add_option("--bugs-closed",
dest="bugs_closed", default=None,
help="list of bugs closed ")
parser.add_option("--change-description", default=None,
help="description of what changed in this revision of "
"the review request when updating an existing request")
parser.add_option("--revision-range",
dest="revision_range", default=None,
help="generate the diff for review based on given "
"revision range")
parser.add_option("--submit-as",
dest="submit_as",
default=get_config_value(configs, 'SUBMIT_AS'),
#.........这里部分代码省略.........
示例7: main
def main():
origcwd = os.path.abspath(os.getcwd())
if 'APPDATA' in os.environ:
homepath = os.environ['APPDATA']
elif 'HOME' in os.environ:
homepath = os.environ["HOME"]
else:
homepath = ''
# If we end up creating a cookie file, make sure it's only readable by the
# user.
os.umask(0077)
# Load the config and cookie files
cookie_file = os.path.join(homepath, ".post-review-cookies.txt")
user_config, globals()['configs'] = load_config_files(homepath)
args = parse_options(sys.argv[1:])
debug('RBTools %s' % get_version_string())
debug('Home = %s' % homepath)
repository_info, tool = scan_usable_client(options)
tool.user_config = user_config
tool.configs = configs
# Verify that options specific to an SCM Client have not been mis-used.
tool.check_options()
# Try to find a valid Review Board server to use.
if options.server:
server_url = options.server
else:
server_url = tool.scan_for_server(repository_info)
if not server_url:
print "Unable to find a Review Board server for this source code tree."
sys.exit(1)
server = ReviewBoardServer(server_url, repository_info, cookie_file)
# Handle the case where /api/ requires authorization (RBCommons).
if not server.check_api_version():
die("Unable to log in with the supplied username and password.")
if repository_info.supports_changesets:
changenum = tool.get_changenum(args)
else:
changenum = None
if options.revision_range:
diff, parent_diff = tool.diff_between_revisions(options.revision_range, args,
repository_info)
elif options.svn_changelist:
diff, parent_diff = tool.diff_changelist(options.svn_changelist)
elif options.diff_filename:
parent_diff = None
if options.diff_filename == '-':
diff = sys.stdin.read()
else:
try:
fp = open(os.path.join(origcwd, options.diff_filename), 'r')
diff = fp.read()
fp.close()
except IOError, e:
die("Unable to open diff filename: %s" % e)
示例8:
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'RBTools Documentation'
copyright = u'2013, Beanbag, Inc.'
# The version info for the project you're documenting, acts as
# replacement for |version| and |release|, also used in various other
# places throughout the built documents.
#
# The short X.Y version.
version = '.'.join([str(i) for i in rbtools.VERSION[:-1][:2]])
# The full version, including alpha/beta/rc tags.
release = rbtools.get_version_string()
# The language for content autogenerated by Sphinx. Refer to
# documentation for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today
# to some non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
#unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
示例9: Option
import os
import pkg_resources
import signal
import subprocess
import sys
from rbtools import get_version_string
from rbtools.commands import find_entry_point_for_command, Option, RB_MAIN
from rbtools.utils.aliases import run_alias
from rbtools.utils.filesystem import load_config
GLOBAL_OPTIONS = [
Option('-v', '--version',
action='version',
version='RBTools %s' % get_version_string()),
Option('-h', '--help',
action='store_true',
dest='help',
default=False),
Option('command',
nargs=argparse.REMAINDER,
help='The RBTools command to execute, and any arguments. '
'(See below)'),
]
def build_help_text(command_class):
"""Generate help text from a command class."""
command = command_class()
parser = command.create_parser({})
示例10: init_logging
def init_logging(self):
"""Initializes logging for the command.
This will set up different log handlers based on the formatting we want
for the given levels.
The INFO log handler will just show the text, like a print statement.
WARNING and higher will show the level name as a prefix, in the form of
"LEVEL: message".
If debugging is enabled, a debug log handler will be set up showing
debug messages in the form of ">>> message", making it easier to
distinguish between debugging and other messages.
"""
if sys.stdout.isatty():
# We only use colorized logging when writing to TTYs, so we don't
# bother initializing it then.
colorama.init()
root = logging.getLogger()
if self.options.debug:
handler = logging.StreamHandler()
handler.setFormatter(self._create_formatter(
'DEBUG', '{color}>>>{reset} %(message)s'))
handler.setLevel(logging.DEBUG)
handler.addFilter(LogLevelFilter(logging.DEBUG))
root.addHandler(handler)
root.setLevel(logging.DEBUG)
else:
root.setLevel(logging.INFO)
# Handler for info messages. We'll treat these like prints.
handler = logging.StreamHandler()
handler.setFormatter(self._create_formatter(
'INFO', '{color}%(message)s{reset}'))
handler.setLevel(logging.INFO)
handler.addFilter(LogLevelFilter(logging.INFO))
root.addHandler(handler)
# Handlers for warnings, errors, and criticals. They'll show the
# level prefix and the message.
levels = (
('WARNING', logging.WARNING),
('ERROR', logging.ERROR),
('CRITICAL', logging.CRITICAL),
)
for level_name, level in levels:
handler = logging.StreamHandler()
handler.setFormatter(self._create_formatter(
level_name, '{color}%(levelname)s:{reset} %(message)s'))
handler.addFilter(LogLevelFilter(level))
handler.setLevel(level)
root.addHandler(handler)
logging.debug('RBTools %s', get_version_string())
logging.debug('Python %s', sys.version)
logging.debug('Running on %s', platform.platform())
logging.debug('Home = %s', get_home_path())
logging.debug('Current directory = %s', os.getcwd())
示例11: init_logging
def init_logging(self):
"""Initializes logging for the command.
This will set up different log handlers based on the formatting we want
for the given levels.
The INFO log handler will just show the text, like a print statement.
WARNING and higher will show the level name as a prefix, in the form of
"LEVEL: message".
If debugging is enabled, a debug log handler will be set up showing
debug messages in the form of ">>> message", making it easier to
distinguish between debugging and other messages.
"""
root = logging.getLogger()
if self.options.debug:
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('>>> %(message)s'))
handler.setLevel(logging.DEBUG)
handler.addFilter(LogLevelFilter(logging.DEBUG))
root.addHandler(handler)
root.setLevel(logging.DEBUG)
else:
root.setLevel(logging.INFO)
# Handler for info messages. We'll treat these like prints.
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(message)s'))
handler.setLevel(logging.INFO)
handler.addFilter(LogLevelFilter(logging.INFO))
root.addHandler(handler)
# Handler for warnings, errors, and criticals. They'll show the
# level prefix and the message.
handler = logging.StreamHandler()
if (self.options.color == 'always' or
(self.options.color == 'auto' and
sys.stderr.isatty())):
handler.setFormatter(ColoredFormatter(
'%(log_color)s%(levelname)-8s%(reset)s'
'%(message_log_color)s%(message)s',
datefmt=None,
reset=True,
log_colors={
'WARNING': self.options.warn_color,
'ERROR': self.options.error_color,
'CRITICAL': self.options.critical_color,
},
secondary_log_colors={
'message': {
'WARNING': self.options.warn_color,
'ERROR': self.options.error_color,
'CRITICAL': self.options.critical_color,
}
},
style='%'
))
else:
handler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
handler.setLevel(logging.WARNING)
root.addHandler(handler)
logging.debug('RBTools %s', get_version_string())
logging.debug('Python %s', sys.version)
logging.debug('Running on %s', platform.platform())
logging.debug('Home = %s', get_home_path())
logging.debug('Current directory = %s', os.getcwd())
示例12: parse_options
def parse_options(args):
parser = OptionParser(usage="%prog [-pond] [-r review_id] [changenum]",
version="RBTools " + get_version_string())
parser.add_option("-p", "--publish",
dest="publish", action="store_true",
default=get_config_value(configs, 'PUBLISH', False),
help="publish the review request immediately after "
"submitting")
parser.add_option("-r", "--review-request-id",
dest="rid", metavar="ID", default=None,
help="existing review request ID to update")
parser.add_option("-o", "--open",
dest="open_browser", action="store_true",
default=get_config_value(configs, 'OPEN_BROWSER', False),
help="open a web browser to the review request page")
parser.add_option("-n", "--output-diff",
dest="output_diff_only", action="store_true",
default=False,
help="outputs a diff to the console and exits. "
"Does not post")
parser.add_option("--server",
dest="server",
default=get_config_value(configs, 'REVIEWBOARD_URL'),
metavar="SERVER",
help="specify a different Review Board server to use")
parser.add_option("--disable-proxy",
action='store_true',
dest='disable_proxy',
default=not get_config_value(configs, 'ENABLE_PROXY',
True),
help="prevents requests from going through a proxy "
"server")
parser.add_option("--diff-only",
dest="diff_only", action="store_true", default=False,
help="uploads a new diff, but does not update "
"info from changelist")
parser.add_option("--reopen",
dest="reopen", action="store_true", default=False,
help="reopen discarded review request "
"after update")
parser.add_option("--target-groups",
dest="target_groups",
default=get_config_value(configs, 'TARGET_GROUPS'),
help="names of the groups who will perform "
"the review")
parser.add_option("--target-people",
dest="target_people",
default=get_config_value(configs, 'TARGET_PEOPLE'),
help="names of the people who will perform "
"the review")
parser.add_option("--summary",
dest="summary", default=None,
help="summary of the review ")
parser.add_option("--description",
dest="description", default=None,
help="description of the review ")
parser.add_option("--description-file",
dest="description_file", default=None,
help="text file containing a description of the review")
parser.add_option('-g', '--guess-fields',
dest="guess_fields", action="store_true",
default=get_config_value(configs, 'GUESS_FIELDS',
False),
help="equivalent to --guess-summary --guess-description")
parser.add_option("--guess-summary",
dest="guess_summary", action="store_true",
default=get_config_value(configs, 'GUESS_SUMMARY',
False),
help="guess summary from the latest commit (git/"
"hg/hgsubversion only)")
parser.add_option("--guess-description",
dest="guess_description", action="store_true",
default=get_config_value(configs, 'GUESS_DESCRIPTION',
False),
help="guess description based on commits on this branch "
"(git/hg/hgsubversion only)")
parser.add_option("--testing-done",
dest="testing_done", default=None,
help="details of testing done ")
parser.add_option("--testing-done-file",
dest="testing_file", default=None,
help="text file containing details of testing done ")
parser.add_option("--branch",
dest="branch",
default=get_config_value(configs, 'BRANCH'),
help="affected branch ")
parser.add_option("--bugs-closed",
dest="bugs_closed", default=None,
help="list of bugs closed ")
parser.add_option("--change-description", default=None,
help="description of what changed in this revision of "
"the review request when updating an existing request")
parser.add_option("--revision-range",
dest="revision_range", default=None,
help="generate the diff for review based on given "
"revision range")
parser.add_option("--submit-as",
dest="submit_as",
default=get_config_value(configs, 'SUBMIT_AS'),
#.........这里部分代码省略.........