本文整理汇总了Python中scalarizr.linux.build_cmd_args函数的典型用法代码示例。如果您正苦于以下问题:Python build_cmd_args函数的具体用法?Python build_cmd_args怎么用?Python build_cmd_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了build_cmd_args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mysqldump
def mysqldump(*databases, **long_kwds):
output = long_kwds.pop("output", None)
cmd = linux.build_cmd_args(executable="/usr/bin/mysqldump", long=long_kwds, params=databases)
kwds = {}
if output:
kwds["stdout"] = open(output, "w+")
return linux.system(cmd, **kwds)
示例2: args
def args(self, *params, **long_kwds):
self.cmd = linux.build_cmd_args(
executable=self.executable,
long=long_kwds,
params=params)
LOG.debug('cmd: %s', self.cmd)
return self
示例3: dd
def dd(**kwds):
short = []
for k, v in kwds.items():
short.append('%s=%s' % (k, v))
return linux.system(linux.build_cmd_args(
executable='/bin/dd',
short=short))
示例4: innobackupex
def innobackupex(*params, **long_kwds):
if not os.path.exists('/usr/bin/innobackupex'):
pkgmgr.installed('percona-xtrabackup')
return linux.system(linux.build_cmd_args(
executable='/usr/bin/innobackupex',
long=long_kwds,
params=params))
示例5: _gen_src
def _gen_src(self):
if self.file_per_database:
for db_name in self._databases:
self._current_db = db_name
cmd = linux.build_cmd_args(
executable='/usr/bin/mysqldump',
params=__mysql__['mysqldump_options'].split() + [db_name])
mysql_dump = subprocess.Popen(cmd, bufsize=-1,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
yield mysql_dump.stdout
else:
cmd = linux.build_cmd_args(
executable='/usr/bin/mysqldump',
params=__mysql__['mysqldump_options'].split() + ['--all-databases'])
mysql_dump = subprocess.Popen(cmd, bufsize=-1,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
yield mysql_dump.stdout
示例6: mkfs
def mkfs(self, device, *short_args):
short_args = list(short_args)
short_args.extend(('-t', self.type))
args = linux.build_cmd_args(
executable='/sbin/mkfs',
short=short_args,
params=[device])
system(args, error_text=self.error_messages['mkfs'] % device)
示例7: modprobe
def modprobe(module_name, **long_kwds):
if not os_info['mods_enabled']:
return (None, None, 0)
return linux.system(linux.build_cmd_args(
executable='/sbin/modprobe',
long=long_kwds,
params=[module_name]),
error_text='Kernel module %s is not available' % module_name)
示例8: mysqldump
def mysqldump(*databases, **long_kwds):
output = long_kwds.pop('output', None)
cmd = linux.build_cmd_args(
executable='/usr/bin/mysqldump',
long=long_kwds,
params=databases)
kwds = {}
if output:
kwds['stdout'] = open(output, 'w+')
return linux.system(cmd, **kwds)
示例9: rsync
def rsync(src, dst, **long_kwds):
if not os.path.exists('/usr/bin/rsync'):
pkgmgr.installed('rsync')
system(['sync'])
output = system(build_cmd_args(executable='/usr/bin/rsync',
long=long_kwds,
params=[src, dst],
duplicate_keys=True))
system(['sync'])
return output
示例10: vgchange
def vgchange(*volume_group_names, **long_kwds):
try:
return linux.system(linux.build_cmd_args(
executable='/sbin/vgchange',
long=long_kwds,
params=volume_group_names))
except linux.LinuxError, e:
if e.returncode == 5:
raise NotFound()
raise
示例11: my_print_defaults
def my_print_defaults(*option_groups):
out = linux.system(linux.build_cmd_args(executable="/usr/bin/my_print_defaults", params=option_groups))[0]
ret = {}
for line in out.splitlines():
cols = line.split("=")
ret[cols[0][2:]] = cols[1] if len(cols) > 1 else True
for key in __mysql__["defaults"]:
if key not in ret:
ret[key] = __mysql__["defaults"][key]
return ret
示例12: iptables
def iptables(**long_kwds):
ordered_long = OrderedDict()
for key in ("protocol", "match"):
if key in long_kwds:
ordered_long[key] = long_kwds.pop(key)
ordered_long.update(long_kwds)
return linux.system(linux.build_cmd_args(executable=IPTABLES_BIN,
long=ordered_long))
示例13: pvchange
def pvchange(*physical_volume_paths, **long_kwds):
try:
return linux.system(linux.build_cmd_args(
executable='/sbin/pvchange',
long=long_kwds,
params=physical_volume_paths))
except linux.LinuxError, e:
if e.returncode == 5:
raise NotFound()
raise
示例14: lvcreate
def lvcreate(*params, **long_kwds):
try:
return linux.system(linux.build_cmd_args(
executable='/sbin/lvcreate',
long=long_kwds,
params=params))
finally:
if linux.os['name'] == 'GCEL':
# Logical volumes not available for mount immediately
# Problem posted to Google at 29 Apr 2013.
time.sleep(1)
示例15: iptables_save
def iptables_save(filename=None, *short_args, **long_kwds):
# file name is a path string or file-like object
# if filename is None return output
kwds = {}
if isinstance(filename, basestring):
filename = open(filename, 'w+')
if hasattr(filename, 'write'):
kwds['stdout'] = filename
out = linux.system(linux.build_cmd_args(executable=IPTABLES_SAVE,
short=short_args, long=long_kwds), **kwds)[0]
return out