本文整理汇总了Python中rbtools.utils.checks.check_gnu_diff函数的典型用法代码示例。如果您正苦于以下问题:Python check_gnu_diff函数的具体用法?Python check_gnu_diff怎么用?Python check_gnu_diff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_gnu_diff函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_repository_info
def get_repository_info(self):
if not check_install('svn help'):
return None
# Get the SVN repository path (either via a working copy or
# a supplied URI)
svn_info_params = ["svn", "info"]
if self.options.repository_url:
svn_info_params.append(self.options.repository_url)
data = execute(svn_info_params,
ignore_errors=True)
m = re.search(r'^Repository Root: (.+)$', data, re.M)
if not m:
return None
path = m.group(1)
m = re.search(r'^URL: (.+)$', data, re.M)
if not m:
return None
base_path = m.group(1)[len(path):] or "/"
m = re.search(r'^Repository UUID: (.+)$', data, re.M)
if not m:
return None
# Now that we know it's SVN, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
return SVNRepositoryInfo(path, base_path, m.group(1))
示例2: get_repository_info
def get_repository_info(self):
"""Determine and return the repository info.
Returns:
rbtools.clients.RepositoryInfo:
The repository info object. If the current working directory does
not correspond to a TFS checkout, this returns ``None``.
"""
if self.tf is None:
logging.debug('Unable to execute "tf help": skipping TFS')
return None
workfold = self._run_tf(['workfold', os.getcwd()])
m = re.search('^Collection: (.*)$', workfold, re.MULTILINE)
if not m:
logging.debug('Could not find the collection from "tf workfold"')
return None
# Now that we know it's TFS, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
path = unquote(m.group(1))
return RepositoryInfo(path)
示例3: get_repository_info
def get_repository_info(self):
if self.tf is None:
logging.debug('Unable to execute "tf help": skipping TFS')
return None
workfold = self._run_tf(['workfold', os.getcwd()])
m = re.search('^Collection: (.*)$', workfold, re.MULTILINE)
if not m:
logging.debug('Could not find the collection from "tf workfold"')
return None
# Now that we know it's TFS, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
path = urllib2.unquote(m.group(1))
mappings = dict([
(group[0], group[2])
for group in
re.findall(r' (\$(.+))\: (.+)$', workfold, re.MULTILINE)
])
return TFSRepositoryInfo(path, mappings=mappings)
示例4: get_repository_info
def get_repository_info(self):
if not self.p4.is_supported():
return None
p4_info = self.p4.info()
# For the repository path, we first prefer p4 brokers, then the
# upstream p4 server. If neither of those are found, just return None.
repository_path = p4_info.get('Broker address', None)
if repository_path is None:
repository_path = p4_info.get('Server address', None)
if repository_path is None:
return None
try:
parts = repository_path.split(':')
hostname = None
if len(parts) == 3 and parts[0] == 'ssl':
hostname = parts[1]
port = parts[2]
elif len(parts) == 2:
hostname, port = parts
if not hostname:
die('Path %s is not a valid Perforce P4PORT' % repository_path)
info = socket.gethostbyaddr(hostname)
# If aliases exist for hostname, create a list of alias:port
# strings for repository_path.
if info[1]:
servers = [info[0]] + info[1]
repository_path = ["%s:%s" % (server, port)
for server in servers]
else:
repository_path = "%s:%s" % (info[0], port)
except (socket.gaierror, socket.herror):
pass
server_version = p4_info.get('Server version', None)
if not server_version:
return None
m = re.search(r'[^ ]*/([0-9]+)\.([0-9]+)/[0-9]+ .*$',
server_version, re.M)
if m:
self.p4d_version = int(m.group(1)), int(m.group(2))
else:
# Gracefully bail if we don't get a match
return None
# Now that we know it's Perforce, make sure we have GNU diff
# installed, and error out if we don't.
check_gnu_diff()
return RepositoryInfo(path=repository_path, supports_changesets=True)
示例5: get_repository_info
def get_repository_info(self):
if self._svn_repository_info_cache:
return self._svn_repository_info_cache
if not check_install(['svn', 'help']):
logging.debug('Unable to execute "svn help": skipping SVN')
return None
# Get the SVN repository path (either via a working copy or
# a supplied URI)
svn_info_params = ["info"]
if getattr(self.options, 'repository_url', None):
svn_info_params.append(self.options.repository_url)
data = self._run_svn(svn_info_params, ignore_errors=True,
results_unicode=False,
log_output_on_error=False)
m = re.search(b'^Repository Root: (.+)$', data, re.M)
if not m:
return None
path = m.group(1)
m = re.search(b'^URL: (.+)$', data, re.M)
if not m:
return None
base_path = m.group(1)[len(path):] or b'/'
m = re.search(b'^Repository UUID: (.+)$', data, re.M)
if not m:
return None
uuid = m.group(1)
# Now that we know it's SVN, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
# Grab version of SVN client and store as a tuple in the form:
# (major_version, minor_version, micro_version)
ver_string = self._run_svn(['--version', '-q'], ignore_errors=True)
m = self.VERSION_NUMBER_RE.match(ver_string)
if not m:
logging.warn('Unable to parse SVN client version triple from '
'"%s". Assuming version 0.0.0.'
% ver_string.strip())
self.subversion_client_version = (0, 0, 0)
else:
self.subversion_client_version = tuple(map(int, m.groups()))
self._svn_repository_info_cache = SVNRepositoryInfo(path,
base_path,
uuid)
return self._svn_repository_info_cache
示例6: get_repository_info
def get_repository_info(self):
"""Returns information on the Clear Case repository.
This will first check if the cleartool command is
installed and in the path, and post-review was run
from inside of the view.
"""
if not check_install('cleartool help'):
return None
viewname = execute(["cleartool", "pwv", "-short"]).strip()
if viewname.startswith('** NONE'):
return None
# Now that we know it's ClearCase, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
property_lines = execute(["cleartool", "lsview", "-full", "-properties",
"-cview"], split_lines=True)
for line in property_lines:
properties = line.split(' ')
if properties[0] == 'Properties:':
# Determine the view type and check if it's supported.
#
# Specifically check if webview was listed in properties
# because webview types also list the 'snapshot'
# entry in properties.
if 'webview' in properties:
die("Webviews are not supported. You can use post-review"
" only in dynamic or snapshot view.")
if 'dynamic' in properties:
self.viewtype = 'dynamic'
else:
self.viewtype = 'snapshot'
break
# Find current VOB's tag
vobstag = execute(["cleartool", "describe", "-short", "vob:."],
ignore_errors=True).strip()
if "Error: " in vobstag:
die("To generate diff run post-review inside vob.")
# From current working directory cut path to VOB.
# VOB's tag contain backslash character before VOB's name.
# I hope that first character of VOB's tag like '\new_proj'
# won't be treat as new line character but two separate:
# backslash and letter 'n'
cwd = os.getcwd()
base_path = cwd[:cwd.find(vobstag) + len(vobstag)]
return ClearCaseRepositoryInfo(path=base_path,
base_path=base_path,
vobstag=vobstag,
supports_parent_diffs=False)
示例7: get_repository_info
def get_repository_info(self):
if not check_install(['svn', 'help']):
logging.debug('Unable to execute "svn help": skipping SVN')
return None
# Get the SVN repository path (either via a working copy or
# a supplied URI)
svn_info_params = ["info"]
if getattr(self.options, 'repository_url', None):
svn_info_params.append(self.options.repository_url)
# Add --non-interactive so that this command will not hang
# when used on a https repository path
svn_info_params.append("--non-interactive")
data = self._run_svn(svn_info_params, ignore_errors=True,
results_unicode=False)
m = re.search(b'^Repository Root: (.+)$', data, re.M)
if not m:
return None
path = m.group(1)
m = re.search(b'^URL: (.+)$', data, re.M)
if not m:
return None
base_path = m.group(1)[len(path):] or "/"
m = re.search(b'^Repository UUID: (.+)$', data, re.M)
if not m:
return None
# Now that we know it's SVN, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
# Grab version of SVN client and store as a tuple in the form:
# (major_version, minor_version, micro_version)
ver_string = self._run_svn(['--version', '-q'], ignore_errors=True)
self.subversion_client_version = tuple(map(int, ver_string.split('.')))
return SVNRepositoryInfo(path, base_path, m.group(1))
示例8: get_repository_info
def get_repository_info(self):
if not check_install('/usr/local/svn/bin/svn help'):
return None
# Get the SVN repository path (either via a working copy or
# a supplied URI)
svn_info_params = ["/usr/local/svn/bin/svn", "info"]
if getattr(self.options, 'repository_url', None):
svn_info_params.append(self.options.repository_url)
# Add --non-interactive so that this command will not hang
# when used on a https repository path
svn_info_params.append("--non-interactive")
svn_info_params.append("--username")
svn_info_params.append("felix")
svn_info_params.append("--password")
svn_info_params.append("felix")
data = execute(svn_info_params,
ignore_errors=True)
m = re.search(r'^Repository Root: (.+)$', data, re.M)
if not m:
return None
path = m.group(1)
m = re.search(r'^URL: (.+)$', data, re.M)
if not m:
return None
base_path = m.group(1)[len(path):] or "/"
m = re.search(r'^Repository UUID: (.+)$', data, re.M)
if not m:
return None
# Now that we know it's SVN, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
return SVNRepositoryInfo(path, base_path, m.group(1))
示例9: get_repository_info
def get_repository_info(self):
if not check_install(["svn", "help"]):
logging.debug('Unable to execute "svn help": skipping SVN')
return None
# Get the SVN repository path (either via a working copy or
# a supplied URI)
svn_info_params = ["svn", "info"]
if getattr(self.options, "repository_url", None):
svn_info_params.append(self.options.repository_url)
# Add --non-interactive so that this command will not hang
# when used on a https repository path
svn_info_params.append("--non-interactive")
data = execute(svn_info_params, ignore_errors=True)
m = re.search(r"^Repository Root: (.+)$", data, re.M)
if not m:
return None
path = m.group(1)
m = re.search(r"^URL: (.+)$", data, re.M)
if not m:
return None
base_path = m.group(1)[len(path) :] or "/"
m = re.search(r"^Repository UUID: (.+)$", data, re.M)
if not m:
return None
# Now that we know it's SVN, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
return SVNRepositoryInfo(path, base_path, m.group(1))
示例10: get_repository_info
def get_repository_info(self):
if not check_install('p4 help'):
return None
data = execute(["p4", "info"], ignore_errors=True)
m = re.search(r'^Server address: (.+)$', data, re.M)
if not m:
return None
repository_path = m.group(1).strip()
try:
hostname, port = repository_path.split(":")
info = socket.gethostbyaddr(hostname)
# If aliases exist for hostname, create a list of alias:port
# strings for repository_path.
if info[1]:
servers = [info[0]] + info[1]
repository_path = ["%s:%s" % (server, port)
for server in servers]
else:
repository_path = "%s:%s" % (info[0], port)
except (socket.gaierror, socket.herror):
pass
m = re.search(r'^Server version: [^ ]*/([0-9]+)\.([0-9]+)/[0-9]+ .*$',
data, re.M)
self.p4d_version = int(m.group(1)), int(m.group(2))
# Now that we know it's Perforce, make sure we have GNU diff
# installed, and error out if we don't.
check_gnu_diff()
return RepositoryInfo(path=repository_path, supports_changesets=True)
示例11: get_repository_info
def get_repository_info(self):
if not self.p4.is_supported():
logging.debug('Unable to execute "p4 help": skipping Perforce')
return None
p4_info = self.p4.info()
# For the repository path, we first prefer p4 brokers, then the
# upstream p4 server. If neither of those are found, just return None.
repository_path = (p4_info.get('Broker address') or
p4_info.get('Server address'))
if repository_path is None:
return None
client_root = p4_info.get('Client root')
if client_root is None:
return None
norm_cwd = os.path.normcase(os.path.realpath(os.getcwd()) +
os.path.sep)
norm_client_root = os.path.normcase(os.path.realpath(client_root) +
os.path.sep)
# Don't accept the repository if the current directory is outside the
# root of the Perforce client.
if not norm_cwd.startswith(norm_client_root):
return None
try:
parts = repository_path.split(':')
hostname = None
if len(parts) == 3 and parts[0] == 'ssl':
hostname = parts[1]
port = parts[2]
elif len(parts) == 2:
hostname, port = parts
if not hostname:
die('Path %s is not a valid Perforce P4PORT' % repository_path)
info = socket.gethostbyaddr(hostname)
# Build the list of repository paths we want to tr to look up.
servers = [hostname]
if info[0] != hostname:
servers.append(info[0])
# If aliases exist for hostname, create a list of alias:port
# strings for repository_path.
if info[1]:
servers += info[1]
repository_path = ["%s:%s" % (server, port)
for server in servers]
# If there's only one repository path found, then we don't
# need to do a more expensive lookup of all registered
# paths. We can look up just this path directly.
if len(repository_path) == 1:
repository_path = repository_path[0]
except (socket.gaierror, socket.herror):
pass
server_version = p4_info.get('Server version', None)
if not server_version:
return None
m = re.search(r'[^ ]*/([0-9]+)\.([0-9]+)/[0-9]+ .*$',
server_version, re.M)
if m:
self.p4d_version = int(m.group(1)), int(m.group(2))
else:
# Gracefully bail if we don't get a match
return None
# Now that we know it's Perforce, make sure we have GNU diff
# installed, and error out if we don't.
check_gnu_diff()
return RepositoryInfo(path=repository_path, supports_changesets=True)
示例12: get_repository_info
def get_repository_info(self):
"""Return information on the ClearCase repository.
This will first check if the cleartool command is installed and in the
path, and that the current working directory is inside of the view.
Returns:
ClearCaseRepositoryInfo:
The repository info structure.
"""
if not check_install(['cleartool', 'help']):
logging.debug('Unable to execute "cleartool help": skipping '
'ClearCase')
return None
viewname = execute(['cleartool', 'pwv', '-short']).strip()
if viewname.startswith('** NONE'):
return None
# Now that we know it's ClearCase, make sure we have GNU diff
# installed, and error out if we don't.
check_gnu_diff()
property_lines = execute(
['cleartool', 'lsview', '-full', '-properties', '-cview'],
split_lines=True)
for line in property_lines:
properties = line.split(' ')
if properties[0] == 'Properties:':
# Determine the view type and check if it's supported.
#
# Specifically check if webview was listed in properties
# because webview types also list the 'snapshot'
# entry in properties.
if 'webview' in properties:
raise SCMError('Webviews are not supported. You can use '
'rbt commands only in dynamic or snapshot '
'views.')
if 'dynamic' in properties:
self.viewtype = 'dynamic'
else:
self.viewtype = 'snapshot'
break
# Find current VOB's tag
vobstag = execute(['cleartool', 'describe', '-short', 'vob:.'],
ignore_errors=True).strip()
if 'Error: ' in vobstag:
raise SCMError('Failed to generate diff run rbt inside vob.')
root_path = execute(['cleartool', 'pwv', '-root'],
ignore_errors=True).strip()
if 'Error: ' in root_path:
raise SCMError('Failed to generate diff run rbt inside view.')
# From current working directory cut path to VOB. On Windows
# and under cygwin, the VOB tag contains the VOB's path including
# name, e.g. `\new_proj` for a VOB `new_proj` mounted at the root
# of a drive. On Unix, the VOB tag is similar, but with a different
# path separator, e.g. `/vobs/new_proj` for our new_proj VOB mounted
# at `/vobs`.
cwd = os.getcwd()
base_path = cwd[:len(root_path) + len(vobstag)]
return ClearCaseRepositoryInfo(path=base_path,
base_path=base_path,
vobstag=vobstag)
示例13: get_repository_info
#.........这里部分代码省略.........
except AttributeError:
os_plat=''
if sys.platform.startswith('win') or os_plat == 'nt':
self._command_args = ['cmd', '/C']
else:
# probably Unix like...
self._command_args = ['sh', '-c']
logging.debug("piccolo bin %r" % self.p_bin)
if perform_piccolo_check:
logging.debug("about to check for piccolo")
if not check_install('%s help' % self.p_bin): # or "p here"? ideally 'p version -c' and then report issues with version (-c option was added to version 2.2.0 of piccolo; p2main.c -> 66 Change 2041 -> 66 (change) on 14-oct-2008 by whiro01)
# "p version -c" does not require current directory to be in MAPPATH (does not even need MAPPATH set)
# p help needs mappath (and connection to server)
logging.debug("piccolo check check_install() failed")
return None
# so we have a piccolo command in the path
if not self.p_actualver:
# check version of piccolo client .........
pic_command_str = '%s version -c' % self.p_bin
pver_text = execute(self._command_args + [pic_command_str], ignore_errors=True, extra_ignore_errors=(1,))
logging.info('pver_text %r', pver_text)
if pver_text.startswith('Invalid option:'):
logging.debug("piccolo version check returned Invalid option")
# too old, does not support -c
print ''
print 'Piccolo version too old, (version -c support missing). Need (at least) version %s' % self.p_minver_str
return None
# extract version
pver_text = pver_text.strip()
pver_text = pver_text.rsplit(' ', 1)[1]
pver = pver_text.rsplit('.')
logging.debug("pver %r" % pver)
#pver = map(int, pver) # fails if ther are non-integers :-( E.g. 'Piccolo client version 2.2.0b14'
comparable_pver = []
for tmp_ver in pver:
try:
tmp_ver = int(tmp_ver)
except ValueError:
# probably not an integer, or may be a mix :-(
new_tmp_ver = ['0']
for tmp_ver_piece in tmp_ver:
if tmp_ver_piece in string.digits:
new_tmp_ver.append(tmp_ver_piece)
else:
break
tmp_ver = int(''.join(new_tmp_ver))
comparable_pver.append(tmp_ver)
self.p_actualver = comparable_pver
logging.debug("self.p_actualver %r" % self.p_actualver)
logging.debug("self.p_minver %r" % self.p_minver)
if self.p_actualver < self.p_minver:
print ''
print 'Piccolo version too old. Found version %s need version %s' % (pver_text, self.p_minver_str)
return None
pic_command_str = '%s here' % self.p_bin
self._p_here_txt = execute(self._command_args + [pic_command_str], ignore_errors=True, extra_ignore_errors=(1,))
self._p_here_txt = self._p_here_txt.strip()
# FIXME look at check_gnu_diff() - don't actually need gnu diff under most unix systems BUT do under Windows (mostly likely place for a bad diff exe)
if sys.platform.startswith('win') or os_plat == 'nt':
check_gnu_diff()
else:
self._p_here_txt = 'EDITME_P2_CLIENT_INFO' ## TODO do at least minimum hostname and pwd?
logging.debug('self._p_here_txt %r', self._p_here_txt)
if self.options.submit_as is None:
self.options.submit_as = os.environ.get('USER')
if self.options.submit_as and self.options.submit_as.lower() == 'ingres':
self.options.submit_as = None
#if self.options.username is None:
# self.options.username = os.environ.get('USER')
# Ingres Corp only has 1 repository (although there are gateways)
"""
The Piccolo server (or path) can be obtained with NEWer clients in a very easy fashion:
version 2.2.0 has a neat option:
p map -x
version 2.1.24 does NOT support -x (which restricts to things you have mapped, i.e. can limit the connects) but does support map:
p map
NOTE check version requires Rogers changes.
Can then grep for connect, etc.
"""
default_piccolo_server = 'usilsuxx:1666' # and/or pick up from "p map" filtering for connect(s) (shell approach would be; p map |grep '^connect' | awk '{print $4}') if perform_piccolo_check is True
repository_path = self.options.p2_server or default_piccolo_server # Should try and pick this up from client map, really need a new piccolo command list (first) piccolo server
if self.options.server is None:
self.options.server = 'http://reviewboard.ingres.prv' # should consider overridding _get_server_from_config()
return RepositoryInfo(path=repository_path, supports_changesets=False)