本文整理汇总了Python中circus.process.Process.format_args方法的典型用法代码示例。如果您正苦于以下问题:Python Process.format_args方法的具体用法?Python Process.format_args怎么用?Python Process.format_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circus.process.Process
的用法示例。
在下文中一共展示了Process.format_args方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_parameters
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import format_args [as 别名]
def test_process_parameters(self):
# all the options passed to the process should be available by the
# command / process
p1 = Process('1', 'make-me-a-coffee',
'$(circus.wid) --type $(circus.env.type)',
shell=False, spawn=False, env={'type': 'macchiato'})
self.assertEquals(['make-me-a-coffee', '1', '--type', 'macchiato'],
p1.format_args())
p2 = Process('1', 'yeah $(CIRCUS.WID)', spawn=False)
self.assertEquals(['yeah', '1'], p2.format_args())
示例2: test_issue310
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import format_args [as 别名]
def test_issue310(self):
'''
https://github.com/mozilla-services/circus/pull/310
Allow $(circus.sockets.name) to be used in args.
'''
conf = get_config(_CONF['issue310'])
watcher = Watcher.load_from_config(conf['watchers'][0])
socket = CircusSocket.load_from_config(conf['sockets'][0])
try:
watcher.initialize(None, {'web': socket}, None)
process = Process(watcher._nextwid, watcher.cmd,
args=watcher.args,
working_dir=watcher.working_dir,
shell=watcher.shell, uid=watcher.uid,
gid=watcher.gid, env=watcher.env,
rlimits=watcher.rlimits, spawn=False,
executable=watcher.executable,
use_fds=watcher.use_sockets,
watcher=watcher)
sockets_fds = watcher._get_sockets_fds()
formatted_args = process.format_args(sockets_fds=sockets_fds)
fd = sockets_fds['web']
self.assertEqual(formatted_args,
['foo', '--fd', str(fd)])
finally:
socket.close()
示例3: test_issue310
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import format_args [as 别名]
def test_issue310(self):
"""
https://github.com/mozilla-services/circus/pull/310
Allow $(circus.sockets.name) to be used in args.
"""
conf = get_config(_CONF["issue310"])
watcher = Watcher.load_from_config(conf["watchers"][0])
socket = CircusSocket.load_from_config(conf["sockets"][0])
watcher.initialize(None, {"web": socket}, None)
process = Process(
watcher._process_counter,
watcher.cmd,
args=watcher.args,
working_dir=watcher.working_dir,
shell=watcher.shell,
uid=watcher.uid,
gid=watcher.gid,
env=watcher.env,
rlimits=watcher.rlimits,
spawn=False,
executable=watcher.executable,
use_fds=watcher.use_sockets,
watcher=watcher,
)
fd = watcher._get_sockets_fds()["web"]
formatted_args = process.format_args()
self.assertEquals(formatted_args, ["foo", "--fd", str(fd)])
示例4: test_process_parameters
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import format_args [as 别名]
def test_process_parameters(self):
# all the options passed to the process should be available by the
# command / process
p1 = Process('1', 'make-me-a-coffee',
'$(circus.wid) --type $(circus.env.type)',
shell=False, spawn=False, env={'type': 'macchiato'},
use_fds=USE_FDS)
self.assertEqual(['make-me-a-coffee', '1', '--type', 'macchiato'],
p1.format_args())
p2 = Process('1', 'yeah $(CIRCUS.WID)', spawn=False, use_fds=USE_FDS)
self.assertEqual(['yeah', '1'], p2.format_args())
os.environ['coffee_type'] = 'american'
p3 = Process('1', 'yeah $(circus.env.type)', shell=False, spawn=False,
env={'type': 'macchiato'}, use_fds=USE_FDS)
self.assertEqual(['yeah', 'macchiato'], p3.format_args())
os.environ.pop('coffee_type')
示例5: load
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import format_args [as 别名]
def load(watcher_conf):
watcher = Watcher.load_from_config(watcher_conf.copy())
process = Process(watcher._nextwid, watcher.cmd,
args=watcher.args,
working_dir=watcher.working_dir,
shell=watcher.shell, uid=watcher.uid,
gid=watcher.gid, env=watcher.env,
rlimits=watcher.rlimits, spawn=False,
executable=watcher.executable,
use_fds=watcher.use_sockets,
watcher=watcher)
return process.format_args()
示例6: test_process_parameters
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import format_args [as 别名]
def test_process_parameters(self):
# all the options passed to the process should be available by the
# command / process
p1 = Process(
"1",
"make-me-a-coffee",
"$(circus.wid) --type $(circus.env.type)",
shell=False,
spawn=False,
env={"type": "macchiato"},
)
self.assertEqual(["make-me-a-coffee", "1", "--type", "macchiato"], p1.format_args())
p2 = Process("1", "yeah $(CIRCUS.WID)", spawn=False)
self.assertEqual(["yeah", "1"], p2.format_args())
os.environ["coffee_type"] = "american"
p3 = Process("1", "yeah $(circus.env.type)", shell=False, spawn=False, env={"type": "macchiato"})
self.assertEqual(["yeah", "macchiato"], p3.format_args())
os.environ.pop("coffee_type")
示例7: load
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import format_args [as 别名]
def load(watcher_conf):
watcher = Watcher.load_from_config(watcher_conf.copy())
# Make sure we don't close the sockets as we will be
# launching the Watcher with IS_WINDOWS=True
watcher.use_sockets = True
process = Process(watcher._nextwid, watcher.cmd,
args=watcher.args,
working_dir=watcher.working_dir,
shell=watcher.shell, uid=watcher.uid,
gid=watcher.gid, env=watcher.env,
rlimits=watcher.rlimits, spawn=False,
executable=watcher.executable,
use_fds=watcher.use_sockets,
watcher=watcher)
return process.format_args()
示例8: test_issue310
# 需要导入模块: from circus.process import Process [as 别名]
# 或者: from circus.process.Process import format_args [as 别名]
def test_issue310(self):
"""
https://github.com/mozilla-services/circus/pull/310
Allow $(circus.sockets.name) to be used in args.
"""
conf = get_config(_CONF["issue310"])
watcher = Watcher.load_from_config(conf["watchers"][0])
socket = CircusSocket.load_from_config(conf["sockets"][0])
try:
watcher.initialize(None, {"web": socket}, None)
if IS_WINDOWS:
# We can't close the sockets on Windows as we
# are redirecting stdout
watcher.use_sockets = True
process = Process(
watcher._nextwid,
watcher.cmd,
args=watcher.args,
working_dir=watcher.working_dir,
shell=watcher.shell,
uid=watcher.uid,
gid=watcher.gid,
env=watcher.env,
rlimits=watcher.rlimits,
spawn=False,
executable=watcher.executable,
use_fds=watcher.use_sockets,
watcher=watcher,
)
sockets_fds = watcher._get_sockets_fds()
formatted_args = process.format_args(sockets_fds=sockets_fds)
fd = sockets_fds["web"]
self.assertEqual(formatted_args, ["foo", "--fd", str(fd)])
finally:
socket.close()