16.07.2020 17:36, Andrey Shinkevich wrote:
On 16.07.2020 13:20, Vladimir Sementsov-Ogievskiy wrote:
14.07.2020 00:36, Andrey Shinkevich wrote:
Add the command key to the qcow2.py arguments list to dump QCOW2
metadata in JSON format. Here is the suggested way to do that. The
implementation of the dump in JSON format is in the patch that follows.
Signed-off-by: Andrey Shinkevich <andrey.shinkev...@virtuozzo.com>
---
tests/qemu-iotests/qcow2.py | 19 +++++++++++++++----
tests/qemu-iotests/qcow2_format.py | 16 ++++++++--------
2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/tests/qemu-iotests/qcow2.py b/tests/qemu-iotests/qcow2.py
index 0910e6a..7402279 100755
...
@@ -134,6 +137,11 @@ cmds = [
def main(filename, cmd, args):
+ global dump_json
+ dump_json = '-j' in sys.argv
+ if dump_json:
+ sys.argv.remove('-j')
+ args.remove('-j')
I'd prefer to access sys.argv in one place (in "if __name__ ...").
In case we move the block
global dump_json
dump_json = '-j' in sys.argv
if dump_json:
sys.argv.remove('-j')
from main() to the body of "if __name__ == '__main__'"
we get the following error -
"SyntaxError: name 'dump_json' is assigned to before global declaration"
you don't need "global" declaration outside of a function
--
Best regards,
Vladimir