本文整理汇总了Python中mr.developer.tests.utils.Process.popen方法的典型用法代码示例。如果您正苦于以下问题:Python Process.popen方法的具体用法?Python Process.popen怎么用?Python Process.popen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mr.developer.tests.utils.Process
的用法示例。
在下文中一共展示了Process.popen方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gitConfigUser
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def gitConfigUser(self, repo):
repository = os.path.join(self.tempdir, repo)
process = Process(cwd=repository)
rc, lines = process.popen('git config user.email "[email protected]"')
assert rc == 0
rc, lines = process.popen('git config user.name "Florian Schulze"')
assert rc == 0
return repository
示例2: addSubmoduleToRepo
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def addSubmoduleToRepo(self, repository, submodule_path, submodule_name):
process = Process(cwd=repository)
rc, lines = process.popen("git submodule add file:///%s %s" % (submodule_path, submodule_name))
assert rc == 0
rc, lines = process.popen("git add .gitmodules")
assert rc == 0
rc, lines = process.popen("git add %s" % submodule_name)
assert rc == 0
rc, lines = process.popen("git commit -m 'Add submodule %s'" % submodule_name)
示例3: createRepo
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def createRepo(self, repo):
repository = os.path.join(self.tempdir, repo)
os.mkdir(repository)
process = Process(cwd=repository)
rc, lines = process.popen("git init")
assert rc == 0
rc, lines = process.popen('git config user.email "[email protected]"')
assert rc == 0
rc, lines = process.popen('git config user.name "Florian Schulze"')
assert rc == 0
return repository
示例4: addFileToRepo
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def addFileToRepo(self, repository, fname):
process = Process(cwd=repository)
repo_file = os.path.join(repository, fname)
self.mkfile(repo_file, fname)
rc, lines = process.popen(
"git add %s" % repo_file,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit %s -m %s" % (repo_file, fname),
echo=False)
assert rc == 0
示例5: testUpdateWithoutRevisionPin
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def testUpdateWithoutRevisionPin(self):
from mr.developer.develop import CmdCheckout
from mr.developer.develop import CmdUpdate
repository = os.path.join(self.tempdir, 'repository')
os.mkdir(repository)
process = Process(cwd=repository)
rc, lines = process.popen(
"hg init %s" % repository)
assert rc == 0
foo = os.path.join(repository, 'foo')
self.mkfile(foo, 'foo')
rc, lines = process.popen(
"hg add %s" % foo,
echo=False)
assert rc == 0
rc, lines = process.popen(
"hg commit %s -m foo -u test" % foo,
echo=False)
assert rc == 0
bar = os.path.join(repository, 'bar')
self.mkfile(bar, 'bar')
rc, lines = process.popen(
"hg add %s" % bar,
echo=False)
assert rc == 0
rc, lines = process.popen(
"hg commit %s -m bar -u test" % bar,
echo=False)
assert rc == 0
src = os.path.join(self.tempdir, 'src')
os.mkdir(src)
develop = MockDevelop()
develop.sources = {
'egg': Source(
kind='hg',
name='egg',
url='%s' % repository,
path=os.path.join(src, 'egg'))}
_log = patch('mr.developer.mercurial.logger')
log = _log.__enter__()
try:
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'bar', 'foo'))
CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'bar', 'foo'))
assert log.method_calls == [
('info', ("Cloned 'egg' with mercurial.",), {}),
('info', ("Updated 'egg' with mercurial.",), {}),
('info', ("Switched 'egg' to default.",), {})]
finally:
_log.__exit__()
示例6: createRepo
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def createRepo(self, repo):
repository = os.path.join(self.tempdir, repo)
os.mkdir(repository)
process = Process(cwd=repository)
rc, lines = process.popen("git init")
assert rc == 0
return repository
示例7: testUpdateWithoutRevisionPin
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def testUpdateWithoutRevisionPin(self):
from mr.developer.commands import CmdCheckout
from mr.developer.commands import CmdUpdate
repository = self.createRepo('repository')
process = Process(cwd=repository)
foo = os.path.join(repository, 'foo')
self.mkfile(foo, 'foo')
rc, lines = process.popen(
"git add %s" % foo,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit %s -m foo" % foo,
echo=False)
assert rc == 0
bar = os.path.join(repository, 'bar')
self.mkfile(bar, 'bar')
rc, lines = process.popen(
"git add %s" % bar,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit %s -m bar" % bar,
echo=False)
assert rc == 0
src = os.path.join(self.tempdir, 'src')
develop = MockDevelop()
develop.sources = {
'egg': Source(
kind='git',
name='egg',
url='file:///%s' % repository,
path=os.path.join(src, 'egg'))}
_log = patch('mr.developer.git.logger')
log = _log.__enter__()
try:
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.git', 'bar', 'foo'))
CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.git', 'bar', 'foo'))
assert log.method_calls == [
('info', ("Cloned 'egg' with git.",), {}),
('info', ("Updated 'egg' with git.",), {})]
finally:
_log.__exit__()
示例8: testUpdateWithoutRevisionPin
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def testUpdateWithoutRevisionPin(self):
from mr.developer.develop import CmdCheckout
from mr.developer.develop import CmdUpdate
process = Process()
repository = os.path.join(self.tempdir, 'repository')
rc, lines = process.popen(
"svnadmin create %s" % repository)
assert rc == 0
checkout = os.path.join(self.tempdir, 'checkout')
rc, lines = process.popen(
"svn checkout file://%s %s" % (repository, checkout),
echo=False)
assert rc == 0
foo = os.path.join(checkout, 'foo')
self.mkfile(foo, 'foo')
rc, lines = process.popen(
"svn add %s" % foo,
echo=False)
assert rc == 0
rc, lines = process.popen(
"svn commit %s -m foo" % foo,
echo=False)
assert rc == 0
bar = os.path.join(checkout, 'bar')
self.mkfile(bar, 'bar')
rc, lines = process.popen(
"svn add %s" % bar,
echo=False)
assert rc == 0
rc, lines = process.popen(
"svn commit %s -m bar" % bar,
echo=False)
assert rc == 0
src = os.path.join(self.tempdir, 'src')
develop = MockDevelop()
develop.sources = {
'egg': Source(
kind='svn',
name='egg',
url='file://%s' % repository,
path=os.path.join(src, 'egg'))}
_log = patch('mr.developer.svn.logger')
log = _log.__enter__()
try:
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.svn', 'bar', 'foo'))
CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.svn', 'bar', 'foo'))
assert log.method_calls == [
('info', ("Checked out 'egg' with subversion.",), {}),
('info', ("Updated 'egg' with subversion.",), {})]
finally:
_log.__exit__()
示例9: testUpdateWithRevisionPin
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def testUpdateWithRevisionPin(self):
from mr.developer.develop import CmdCheckout
from mr.developer.develop import CmdUpdate
process = Process()
repository = os.path.join(self.tempdir, 'repository')
rc, lines = process.popen(
"svnadmin create %s" % repository)
assert rc == 0
checkout = os.path.join(self.tempdir, 'checkout')
rc, lines = process.popen(
"svn checkout file://%s %s" % (repository, checkout),
echo=False)
assert rc == 0
foo = os.path.join(checkout, 'foo')
self.mkfile(foo, 'foo')
rc, lines = process.popen(
"svn add %s" % foo,
echo=False)
assert rc == 0
rc, lines = process.popen(
"svn commit %s -m foo" % foo,
echo=False)
assert rc == 0
bar = os.path.join(checkout, 'bar')
self.mkfile(bar, 'bar')
rc, lines = process.popen(
"svn add %s" % bar,
echo=False)
assert rc == 0
rc, lines = process.popen(
"svn commit %s -m bar" % bar,
echo=False)
assert rc == 0
src = os.path.join(self.tempdir, 'src')
develop = MockDevelop()
develop.sources = {
'egg': Source(
kind='svn',
name='egg',
url='file://%[email protected]' % repository,
path=os.path.join(src, 'egg'))}
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.svn', 'foo'))
CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.svn', 'foo'))
示例10: testUpdateWithRevisionPin
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def testUpdateWithRevisionPin(self):
from mr.developer.develop import CmdCheckout
from mr.developer.develop import CmdUpdate
repository = os.path.join(self.tempdir, 'repository')
os.mkdir(repository)
process = Process(cwd=repository)
rc, lines = process.popen(
"hg init %s" % repository)
assert rc == 0
foo = os.path.join(repository, 'foo')
self.mkfile(foo, 'foo')
rc, lines = process.popen(
"hg add %s" % foo,
echo=False)
assert rc == 0
# create branch for testing
rc, lines = process.popen(
"hg branch test",
echo=False)
assert rc == 0
rc, lines = process.popen(
"hg commit %s -m foo -u test" % foo,
echo=False)
assert rc == 0
# get comitted rev
rc, lines = process.popen(
"hg log %s" % foo,
echo=False)
assert rc == 0
rev = lines[0].split()[1].split(':')[1]
# return to default branch
rc, lines = process.popen(
"hg branch default",
echo=False)
assert rc == 0
bar = os.path.join(repository, 'bar')
self.mkfile(bar, 'bar')
rc, lines = process.popen(
"hg add %s" % bar,
echo=False)
assert rc == 0
rc, lines = process.popen(
"hg commit %s -m bar -u test" % bar,
echo=False)
assert rc == 0
src = os.path.join(self.tempdir, 'src')
os.mkdir(src)
develop = MockDevelop()
# check rev
develop.sources = {
'egg': Source(
kind='hg',
name='egg',
rev=rev,
url='%s' % repository,
path=os.path.join(src, 'egg'))}
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo'))
CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo'))
# check branch
develop.sources = {
'egg': Source(
kind='hg',
name='egg',
branch='test',
url='%s' % repository,
path=os.path.join(src, 'egg'))}
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo'))
CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.hg', 'foo'))
# we can't use both rev and branch
pytest.raises(SystemExit, """
develop.sources = {
'egg': Source(
kind='hg',
name='egg',
branch='test',
rev=rev,
url='%s' % repository,
path=os.path.join(src, 'egg-failed'))}
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
""")
示例11: testUpdateWithRevisionPin
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def testUpdateWithRevisionPin(self):
from mr.developer.develop import CmdCheckout
from mr.developer.develop import CmdUpdate
from mr.developer.develop import CmdStatus
repository = self.createRepo('repository')
process = Process(cwd=repository)
foo = os.path.join(repository, 'foo')
self.mkfile(foo, 'foo')
rc, lines = process.popen(
"git add %s" % foo,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit -m 'Initial'",
echo=False)
assert rc == 0
# create branch for testing
rc, lines = process.popen(
"git checkout -b test",
echo=False)
assert rc == 0
foo2 = os.path.join(repository, 'foo2')
self.mkfile(foo2, 'foo2')
rc, lines = process.popen(
"git add %s" % foo2,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit -m foo",
echo=False)
assert rc == 0
# get comitted rev
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
rev = lines[0].split()[1]
# return to default branch
rc, lines = process.popen(
"git checkout master",
echo=False)
assert rc == 0
bar = os.path.join(repository, 'bar')
self.mkfile(bar, 'bar')
rc, lines = process.popen(
"git add %s" % bar,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit -m bar",
echo=False)
assert rc == 0
src = os.path.join(self.tempdir, 'src')
os.mkdir(src)
develop = MockDevelop()
develop.sources_dir = src
# check rev
develop.sources = {
'egg': Source(
kind='git',
name='egg',
rev=rev,
url='%s' % repository,
path=os.path.join(src, 'egg'))}
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.git', 'foo', 'foo2'))
CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.git', 'foo', 'foo2'))
shutil.rmtree(os.path.join(src, 'egg'))
# check branch
develop.sources = {
'egg': Source(
kind='git',
name='egg',
branch='test',
url='%s' % repository,
path=os.path.join(src, 'egg'))}
CmdCheckout(develop)(develop.parser.parse_args(['co', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.git', 'foo', 'foo2'))
CmdUpdate(develop)(develop.parser.parse_args(['up', 'egg']))
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.git', 'foo', 'foo2'))
CmdStatus(develop)(develop.parser.parse_args(['status']))
# we can't use both rev and branch
pytest.raises(SystemExit, """
develop.sources = {
'egg': Source(
kind='git',
name='egg',
#.........这里部分代码省略.........
示例12: testDepthOption
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def testDepthOption(self):
from mr.developer.develop import develop
# create repository and make two commits on it
repository = self.createRepo('repository')
process = Process(cwd=repository)
foo = os.path.join(repository, 'foo')
self.mkfile(foo, 'foo')
rc, lines = process.popen(
"git add %s" % foo,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit %s -m foo" % foo,
echo=False)
assert rc == 0
bar = os.path.join(repository, 'bar')
self.mkfile(bar, 'bar')
rc, lines = process.popen(
"git add %s" % bar,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit %s -m bar" % bar,
echo=False)
assert rc == 0
src = os.path.join(self.tempdir, 'src')
self.createFile(
'buildout.cfg', [
'[buildout]',
'mr.developer-threads = 1',
'[sources]',
'egg = git file:///%s' % repository])
self.createFile('.mr.developer.cfg', [])
os.chdir(self.tempdir)
develop('co', 'egg')
# check that there are two commits in history
process = Process(cwd=os.path.join(src, 'egg'))
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
commits = [msg for msg in lines
if msg.decode('utf-8').startswith('commit')]
assert len(commits) == 2
shutil.rmtree(os.path.join(src, 'egg'))
self.createFile(
'buildout.cfg', [
'[buildout]',
'mr.developer-threads = 1',
'[sources]',
'egg = git file:///%s depth=1' % repository])
develop('co', 'egg')
# check that there is only one commit in history
process = Process(cwd=os.path.join(src, 'egg'))
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
commits = [msg for msg in lines
if msg.decode('utf-8').startswith('commit')]
assert len(commits) == 1
shutil.rmtree(os.path.join(src, 'egg'))
self.createFile(
'buildout.cfg', [
'[buildout]',
'mr.developer-threads = 1',
'git-clone-depth = 1',
'[sources]',
'egg = git file:///%s' % repository])
develop('co', 'egg')
# check that there is only one commit in history
process = Process(cwd=os.path.join(src, 'egg'))
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
commits = [msg for msg in lines
if msg.decode('utf-8').startswith('commit')]
assert len(commits) == 1
示例13: createDefaultContent
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def createDefaultContent(self, repository):
# Create default content and branches in a repository.
# Return a revision number.
process = Process(cwd=repository)
foo = os.path.join(repository, 'foo')
self.mkfile(foo, 'foo')
rc, lines = process.popen(
"git add %s" % foo,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit -m 'Initial'",
echo=False)
assert rc == 0
# create branch for testing
rc, lines = process.popen(
"git checkout -b test",
echo=False)
assert rc == 0
foo2 = os.path.join(repository, 'foo2')
self.mkfile(foo2, 'foo2')
rc, lines = process.popen(
"git add %s" % foo2,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit -m foo2",
echo=False)
assert rc == 0
# get comitted rev
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
rev = lines[0].split()[1]
# return to default branch
rc, lines = process.popen(
"git checkout master",
echo=False)
assert rc == 0
bar = os.path.join(repository, 'bar')
self.mkfile(bar, 'bar')
rc, lines = process.popen(
"git add %s" % bar,
echo=False)
assert rc == 0
rc, lines = process.popen(
"git commit -m bar",
echo=False)
assert rc == 0
# Return revision of one of the commits, the one that adds the
# foo2 file.
return rev
示例14: testDepthOption
# 需要导入模块: from mr.developer.tests.utils import Process [as 别名]
# 或者: from mr.developer.tests.utils.Process import popen [as 别名]
def testDepthOption(self):
from mr.developer.develop import develop
# create repository and make two commits on it
repository = self.createRepo('repository')
self.createDefaultContent(repository)
process = Process(cwd=repository)
src = os.path.join(self.tempdir, 'src')
self.createFile(
'buildout.cfg', [
'[buildout]',
'mr.developer-threads = 1',
'[sources]',
'egg = git file:///%s' % repository])
self.createFile('.mr.developer.cfg', [])
os.chdir(self.tempdir)
develop('co', 'egg')
# check that there are two commits in history
process = Process(cwd=os.path.join(src, 'egg'))
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
commits = [msg for msg in lines
if msg.decode('utf-8').startswith('commit')]
assert len(commits) == 2
shutil.rmtree(os.path.join(src, 'egg'))
self.createFile(
'buildout.cfg', [
'[buildout]',
'mr.developer-threads = 1',
'[sources]',
'egg = git file:///%s depth=1' % repository])
develop('co', 'egg')
# check that there is only one commit in history
process = Process(cwd=os.path.join(src, 'egg'))
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
commits = [msg for msg in lines
if msg.decode('utf-8').startswith('commit')]
assert len(commits) == 1
shutil.rmtree(os.path.join(src, 'egg'))
self.createFile(
'buildout.cfg', [
'[buildout]',
'mr.developer-threads = 1',
'git-clone-depth = 1',
'[sources]',
'egg = git file:///%s' % repository])
develop('co', 'egg')
# check that there is only one commit in history
process = Process(cwd=os.path.join(src, 'egg'))
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
commits = [msg for msg in lines
if msg.decode('utf-8').startswith('commit')]
assert len(commits) == 1
# You should be able to combine depth and cloning a branch.
# Otherwise with a depth of 1 you could clone the master
# branch and then not be able to switch to the wanted branch,
# because this branch would not be there: the revision that it
# points to is not in the downloaded history.
shutil.rmtree(os.path.join(src, 'egg'))
self.createFile(
'buildout.cfg', [
'[buildout]',
'mr.developer-threads = 1',
'git-clone-depth = 1',
'[sources]',
'egg = git file:///%s branch=test' % repository])
develop('co', 'egg')
# check that there is only one commit in history
process = Process(cwd=os.path.join(src, 'egg'))
rc, lines = process.popen(
"git log",
echo=False)
assert rc == 0
commits = [msg for msg in lines
if msg.decode('utf-8').startswith('commit')]
assert len(commits) == 1
# Check that the expected files from the branch are there
assert set(os.listdir(os.path.join(src, 'egg'))) == set(('.git', 'foo', 'foo2'))