mirror of
https://github.com/ceph/ceph
synced 2025-03-31 07:53:23 +00:00
Merge PR #30585 into master
* refs/pull/30585/head: docs/cephfs-shell: update doc about pyscript cephfs-shell: make compatible with cmd2 versions after 0.9.13 Reviewed-by: Patrick Donnelly <pdonnell@redhat.com> Reviewed-by: Varsha Rao <varao@redhat.com>
This commit is contained in:
commit
ed9c5f7f7e
@ -238,18 +238,21 @@ Usage:
|
|||||||
* name - name of the alias being looked up, added, or replaced
|
* name - name of the alias being looked up, added, or replaced
|
||||||
* value - what the alias will be resolved to (if adding or replacing) this can contain spaces and does not need to be quoted
|
* value - what the alias will be resolved to (if adding or replacing) this can contain spaces and does not need to be quoted
|
||||||
|
|
||||||
pyscript
|
run_pyscript
|
||||||
--------
|
------------
|
||||||
|
|
||||||
Runs a python script file inside the console
|
Runs a python script file inside the console
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
pyscript <script_path> [script_arguments]
|
run_pyscript <script_path> [script_arguments]
|
||||||
|
|
||||||
* Console commands can be executed inside this script with cmd ("your command")
|
* Console commands can be executed inside this script with cmd ("your command")
|
||||||
However, you cannot run nested "py" or "pyscript" commands from within this script
|
However, you cannot run nested "py" or "pyscript" commands from within this
|
||||||
Paths or arguments that contain spaces must be enclosed in quotes
|
script. Paths or arguments that contain spaces must be enclosed in quotes
|
||||||
|
|
||||||
|
.. note:: This command is available as ``pyscript`` for cmd2 versions 0.9.13
|
||||||
|
or less.
|
||||||
|
|
||||||
py
|
py
|
||||||
--
|
--
|
||||||
@ -328,18 +331,21 @@ Usage:
|
|||||||
|
|
||||||
* file_path - path to a file to open in editor
|
* file_path - path to a file to open in editor
|
||||||
|
|
||||||
load
|
run_script
|
||||||
----
|
----------
|
||||||
|
|
||||||
Runs commands in script file that is encoded as either ASCII or UTF-8 text.
|
Runs commands in script file that is encoded as either ASCII or UTF-8 text.
|
||||||
|
Each command in the script should be separated by a newline.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
load <file_path>
|
run_script <file_path>
|
||||||
|
|
||||||
|
|
||||||
* file_path - a file path pointing to a script
|
* file_path - a file path pointing to a script
|
||||||
|
|
||||||
* Script should contain one command per line, just like command would betyped in console.
|
.. note:: This command is available as ``load`` for cmd2 versions 0.9.13
|
||||||
|
or less.
|
||||||
|
|
||||||
shell
|
shell
|
||||||
-----
|
-----
|
||||||
|
@ -5,7 +5,6 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
from cmd2 import Cmd
|
|
||||||
import cephfs as libcephfs
|
import cephfs as libcephfs
|
||||||
import shutil
|
import shutil
|
||||||
import traceback
|
import traceback
|
||||||
@ -16,6 +15,10 @@ import re
|
|||||||
import shlex
|
import shlex
|
||||||
import stat
|
import stat
|
||||||
|
|
||||||
|
from cmd2 import Cmd
|
||||||
|
from cmd2 import __version__ as cmd2_version
|
||||||
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
if sys.version_info.major < 3:
|
if sys.version_info.major < 3:
|
||||||
raise RuntimeError("cephfs-shell is only compatible with python3")
|
raise RuntimeError("cephfs-shell is only compatible with python3")
|
||||||
|
|
||||||
@ -1332,7 +1335,10 @@ if __name__ == '__main__':
|
|||||||
if args.config:
|
if args.config:
|
||||||
config_file = args.config
|
config_file = args.config
|
||||||
if args.batch:
|
if args.batch:
|
||||||
|
if LooseVersion(cmd2_version) <= LooseVersion("0.9.13"):
|
||||||
args.commands = ['load ' + args.batch, ',quit']
|
args.commands = ['load ' + args.batch, ',quit']
|
||||||
|
else:
|
||||||
|
args.commands = ['run_script ' + args.batch, ',quit']
|
||||||
if args.test:
|
if args.test:
|
||||||
args.commands.extend(['-t,'] + [arg + ',' for arg in args.test])
|
args.commands.extend(['-t,'] + [arg + ',' for arg in args.test])
|
||||||
sys.argv.clear()
|
sys.argv.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user