* [Qemu-devel] [PATCH v1 0/4]: QAPI: Small fixes for qapi-types.py
@ 2011-10-17 15:29 Luiz Capitulino
2011-10-17 15:29 ` [Qemu-devel] [PATCH 1/4] qapi-types.py: Add a main() like function Luiz Capitulino
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Luiz Capitulino @ 2011-10-17 15:29 UTC (permalink / raw)
To: mdroth; +Cc: aliguori, qemu-devel
Details in the patches.
scripts/qapi-types.py | 233 +++++++++++++++++++++++++------------------------
1 files changed, 118 insertions(+), 115 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 1/4] qapi-types.py: Add a main() like function
2011-10-17 15:29 [Qemu-devel] [PATCH v1 0/4]: QAPI: Small fixes for qapi-types.py Luiz Capitulino
@ 2011-10-17 15:29 ` Luiz Capitulino
2011-10-17 21:19 ` Michael Roth
2011-10-17 15:29 ` [Qemu-devel] [PATCH 2/4] qapi-types.py: Don't build paths by hand Luiz Capitulino
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Luiz Capitulino @ 2011-10-17 15:29 UTC (permalink / raw)
To: mdroth; +Cc: aliguori, qemu-devel
Makes it easier to read the code.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
scripts/qapi-types.py | 230 ++++++++++++++++++++++++------------------------
1 files changed, 115 insertions(+), 115 deletions(-)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index f64d84c..986ff1e 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -161,118 +161,118 @@ void qapi_free_%(type)s(%(c_type)s obj)
c_type=c_type(name),type=name)
return ret
-
-try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], "p:o:", ["prefix=", "output-dir="])
-except getopt.GetoptError, err:
- print str(err)
- sys.exit(1)
-
-output_dir = ""
-prefix = ""
-c_file = 'qapi-types.c'
-h_file = 'qapi-types.h'
-
-for o, a in opts:
- if o in ("-p", "--prefix"):
- prefix = a
- elif o in ("-o", "--output-dir"):
- output_dir = a + "/"
-
-c_file = output_dir + prefix + c_file
-h_file = output_dir + prefix + h_file
-
-try:
- os.makedirs(output_dir)
-except os.error, e:
- if e.errno != errno.EEXIST:
- raise
-
-fdef = open(c_file, 'w')
-fdecl = open(h_file, 'w')
-
-fdef.write(mcgen('''
-/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
-
-/*
- * deallocation functions for schema-defined QAPI types
- *
- * Copyright IBM, Corp. 2011
- *
- * Authors:
- * Anthony Liguori <aliguori@us.ibm.com>
- * Michael Roth <mdroth@linux.vnet.ibm.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-
-#include "qapi/qapi-dealloc-visitor.h"
-#include "%(prefix)sqapi-types.h"
-#include "%(prefix)sqapi-visit.h"
-
-''', prefix=prefix))
-
-fdecl.write(mcgen('''
-/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
-
-/*
- * schema-defined QAPI types
- *
- * Copyright IBM, Corp. 2011
- *
- * Authors:
- * Anthony Liguori <aliguori@us.ibm.com>
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING.LIB file in the top-level directory.
- *
- */
-
-#ifndef %(guard)s
-#define %(guard)s
-
-#include "qapi/qapi-types-core.h"
-''',
- guard=guardname(h_file)))
-
-exprs = parse_schema(sys.stdin)
-
-for expr in exprs:
- ret = "\n"
- if expr.has_key('type'):
- ret += generate_fwd_struct(expr['type'], expr['data'])
- elif expr.has_key('enum'):
- ret += generate_enum(expr['enum'], expr['data'])
- fdef.write(generate_enum_lookup(expr['enum'], expr['data']))
- elif expr.has_key('union'):
- ret += generate_fwd_struct(expr['union'], expr['data']) + "\n"
- ret += generate_enum('%sKind' % expr['union'], expr['data'].keys())
- else:
- continue
- fdecl.write(ret)
-
-for expr in exprs:
- ret = "\n"
- if expr.has_key('type'):
- ret += generate_struct(expr['type'], "", expr['data']) + "\n"
- ret += generate_type_cleanup_decl(expr['type'] + "List")
- fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n")
- ret += generate_type_cleanup_decl(expr['type'])
- fdef.write(generate_type_cleanup(expr['type']) + "\n")
- elif expr.has_key('union'):
- ret += generate_union(expr['union'], expr['data'])
- else:
- continue
- fdecl.write(ret)
-
-fdecl.write('''
-#endif
-''')
-
-fdecl.flush()
-fdecl.close()
-
-fdef.flush()
-fdef.close()
+if __name__ == '__main__':
+ try:
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "p:o:", ["prefix=", "output-dir="])
+ except getopt.GetoptError, err:
+ print str(err)
+ sys.exit(1)
+
+ output_dir = ""
+ prefix = ""
+ c_file = 'qapi-types.c'
+ h_file = 'qapi-types.h'
+
+ for o, a in opts:
+ if o in ("-p", "--prefix"):
+ prefix = a
+ elif o in ("-o", "--output-dir"):
+ output_dir = a + "/"
+
+ c_file = output_dir + prefix + c_file
+ h_file = output_dir + prefix + h_file
+
+ try:
+ os.makedirs(output_dir)
+ except os.error, e:
+ if e.errno != errno.EEXIST:
+ raise
+
+ fdef = open(c_file, 'w')
+ fdecl = open(h_file, 'w')
+
+ fdef.write(mcgen('''
+ /* AUTOMATICALLY GENERATED, DO NOT MODIFY */
+
+ /*
+ * deallocation functions for schema-defined QAPI types
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ * Anthony Liguori <aliguori@us.ibm.com>
+ * Michael Roth <mdroth@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+ #include "qapi/qapi-dealloc-visitor.h"
+ #include "%(prefix)sqapi-types.h"
+ #include "%(prefix)sqapi-visit.h"
+
+ ''', prefix=prefix))
+
+ fdecl.write(mcgen('''
+ /* AUTOMATICALLY GENERATED, DO NOT MODIFY */
+
+ /*
+ * schema-defined QAPI types
+ *
+ * Copyright IBM, Corp. 2011
+ *
+ * Authors:
+ * Anthony Liguori <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+ #ifndef %(guard)s
+ #define %(guard)s
+
+ #include "qapi/qapi-types-core.h"
+ ''',
+ guard=guardname(h_file)))
+
+ exprs = parse_schema(sys.stdin)
+
+ for expr in exprs:
+ ret = "\n"
+ if expr.has_key('type'):
+ ret += generate_fwd_struct(expr['type'], expr['data'])
+ elif expr.has_key('enum'):
+ ret += generate_enum(expr['enum'], expr['data'])
+ fdef.write(generate_enum_lookup(expr['enum'], expr['data']))
+ elif expr.has_key('union'):
+ ret += generate_fwd_struct(expr['union'], expr['data']) + "\n"
+ ret += generate_enum('%sKind' % expr['union'], expr['data'].keys())
+ else:
+ continue
+ fdecl.write(ret)
+
+ for expr in exprs:
+ ret = "\n"
+ if expr.has_key('type'):
+ ret += generate_struct(expr['type'], "", expr['data']) + "\n"
+ ret += generate_type_cleanup_decl(expr['type'] + "List")
+ fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n")
+ ret += generate_type_cleanup_decl(expr['type'])
+ fdef.write(generate_type_cleanup(expr['type']) + "\n")
+ elif expr.has_key('union'):
+ ret += generate_union(expr['union'], expr['data'])
+ else:
+ continue
+ fdecl.write(ret)
+
+ fdecl.write('''
+ #endif
+ ''')
+
+ fdecl.flush()
+ fdecl.close()
+
+ fdef.flush()
+ fdef.close()
--
1.7.7.rc3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/4] qapi-types.py: Don't build paths by hand
2011-10-17 15:29 [Qemu-devel] [PATCH v1 0/4]: QAPI: Small fixes for qapi-types.py Luiz Capitulino
2011-10-17 15:29 ` [Qemu-devel] [PATCH 1/4] qapi-types.py: Add a main() like function Luiz Capitulino
@ 2011-10-17 15:29 ` Luiz Capitulino
2011-10-17 21:20 ` Michael Roth
2011-10-17 15:29 ` [Qemu-devel] [PATCH 3/4] qapi-types.py: Fail gracefully if out dir is not specified Luiz Capitulino
2011-10-17 15:29 ` [Qemu-devel] [PATCH 4/4] qapi-types.py: Drop unused variable Luiz Capitulino
3 siblings, 1 reply; 10+ messages in thread
From: Luiz Capitulino @ 2011-10-17 15:29 UTC (permalink / raw)
To: mdroth; +Cc: aliguori, qemu-devel
Use os.path.join() instead.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
scripts/qapi-types.py | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 986ff1e..8df4b72 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -177,10 +177,10 @@ if __name__ == '__main__':
if o in ("-p", "--prefix"):
prefix = a
elif o in ("-o", "--output-dir"):
- output_dir = a + "/"
+ output_dir = a
- c_file = output_dir + prefix + c_file
- h_file = output_dir + prefix + h_file
+ c_file = os.path.join(output_dir, prefix + c_file)
+ h_file = os.path.join(output_dir, prefix + h_file)
try:
os.makedirs(output_dir)
--
1.7.7.rc3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 3/4] qapi-types.py: Fail gracefully if out dir is not specified
2011-10-17 15:29 [Qemu-devel] [PATCH v1 0/4]: QAPI: Small fixes for qapi-types.py Luiz Capitulino
2011-10-17 15:29 ` [Qemu-devel] [PATCH 1/4] qapi-types.py: Add a main() like function Luiz Capitulino
2011-10-17 15:29 ` [Qemu-devel] [PATCH 2/4] qapi-types.py: Don't build paths by hand Luiz Capitulino
@ 2011-10-17 15:29 ` Luiz Capitulino
2011-10-17 21:27 ` Michael Roth
2011-10-17 15:29 ` [Qemu-devel] [PATCH 4/4] qapi-types.py: Drop unused variable Luiz Capitulino
3 siblings, 1 reply; 10+ messages in thread
From: Luiz Capitulino @ 2011-10-17 15:29 UTC (permalink / raw)
To: mdroth; +Cc: aliguori, qemu-devel
Otherwise we get:
Traceback (most recent call last):
File "./scripts/qapi-types.py", line 183, in <module>
os.makedirs(output_dir)
File "/usr/lib64/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 2] No such file or directory: ''
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
scripts/qapi-types.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 8df4b72..4a2ddc4 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -178,7 +178,11 @@ if __name__ == '__main__':
prefix = a
elif o in ("-o", "--output-dir"):
output_dir = a
-
+
+ if not output_dir:
+ sys.stdout.write("ouput directory was not specified\n")
+ sys.exit(1)
+
c_file = os.path.join(output_dir, prefix + c_file)
h_file = os.path.join(output_dir, prefix + h_file)
--
1.7.7.rc3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 4/4] qapi-types.py: Drop unused variable
2011-10-17 15:29 [Qemu-devel] [PATCH v1 0/4]: QAPI: Small fixes for qapi-types.py Luiz Capitulino
` (2 preceding siblings ...)
2011-10-17 15:29 ` [Qemu-devel] [PATCH 3/4] qapi-types.py: Fail gracefully if out dir is not specified Luiz Capitulino
@ 2011-10-17 15:29 ` Luiz Capitulino
2011-10-17 21:29 ` Michael Roth
3 siblings, 1 reply; 10+ messages in thread
From: Luiz Capitulino @ 2011-10-17 15:29 UTC (permalink / raw)
To: mdroth; +Cc: aliguori, qemu-devel
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
scripts/qapi-types.py | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 4a2ddc4..28d7f01 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -65,7 +65,6 @@ def generate_enum_lookup(name, values):
const char *%(name)s_lookup[] = {
''',
name=name)
- i = 0
for value in values:
ret += mcgen('''
"%(value)s",
--
1.7.7.rc3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/4] qapi-types.py: Add a main() like function
2011-10-17 15:29 ` [Qemu-devel] [PATCH 1/4] qapi-types.py: Add a main() like function Luiz Capitulino
@ 2011-10-17 21:19 ` Michael Roth
0 siblings, 0 replies; 10+ messages in thread
From: Michael Roth @ 2011-10-17 21:19 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: aliguori, qemu-devel
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
On Mon, 17 Oct 2011 13:29:34 -0200, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> Makes it easier to read the code.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> scripts/qapi-types.py | 230 ++++++++++++++++++++++++------------------------
> 1 files changed, 115 insertions(+), 115 deletions(-)
>
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index f64d84c..986ff1e 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -161,118 +161,118 @@ void qapi_free_%(type)s(%(c_type)s obj)
> c_type=c_type(name),type=name)
> return ret
>
> -
> -try:
> - opts, args = getopt.gnu_getopt(sys.argv[1:], "p:o:", ["prefix=", "output-dir="])
> -except getopt.GetoptError, err:
> - print str(err)
> - sys.exit(1)
> -
> -output_dir = ""
> -prefix = ""
> -c_file = 'qapi-types.c'
> -h_file = 'qapi-types.h'
> -
> -for o, a in opts:
> - if o in ("-p", "--prefix"):
> - prefix = a
> - elif o in ("-o", "--output-dir"):
> - output_dir = a + "/"
> -
> -c_file = output_dir + prefix + c_file
> -h_file = output_dir + prefix + h_file
> -
> -try:
> - os.makedirs(output_dir)
> -except os.error, e:
> - if e.errno != errno.EEXIST:
> - raise
> -
> -fdef = open(c_file, 'w')
> -fdecl = open(h_file, 'w')
> -
> -fdef.write(mcgen('''
> -/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
> -
> -/*
> - * deallocation functions for schema-defined QAPI types
> - *
> - * Copyright IBM, Corp. 2011
> - *
> - * Authors:
> - * Anthony Liguori <aliguori@us.ibm.com>
> - * Michael Roth <mdroth@linux.vnet.ibm.com>
> - *
> - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
> - * See the COPYING.LIB file in the top-level directory.
> - *
> - */
> -
> -#include "qapi/qapi-dealloc-visitor.h"
> -#include "%(prefix)sqapi-types.h"
> -#include "%(prefix)sqapi-visit.h"
> -
> -''', prefix=prefix))
> -
> -fdecl.write(mcgen('''
> -/* AUTOMATICALLY GENERATED, DO NOT MODIFY */
> -
> -/*
> - * schema-defined QAPI types
> - *
> - * Copyright IBM, Corp. 2011
> - *
> - * Authors:
> - * Anthony Liguori <aliguori@us.ibm.com>
> - *
> - * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
> - * See the COPYING.LIB file in the top-level directory.
> - *
> - */
> -
> -#ifndef %(guard)s
> -#define %(guard)s
> -
> -#include "qapi/qapi-types-core.h"
> -''',
> - guard=guardname(h_file)))
> -
> -exprs = parse_schema(sys.stdin)
> -
> -for expr in exprs:
> - ret = "\n"
> - if expr.has_key('type'):
> - ret += generate_fwd_struct(expr['type'], expr['data'])
> - elif expr.has_key('enum'):
> - ret += generate_enum(expr['enum'], expr['data'])
> - fdef.write(generate_enum_lookup(expr['enum'], expr['data']))
> - elif expr.has_key('union'):
> - ret += generate_fwd_struct(expr['union'], expr['data']) + "\n"
> - ret += generate_enum('%sKind' % expr['union'], expr['data'].keys())
> - else:
> - continue
> - fdecl.write(ret)
> -
> -for expr in exprs:
> - ret = "\n"
> - if expr.has_key('type'):
> - ret += generate_struct(expr['type'], "", expr['data']) + "\n"
> - ret += generate_type_cleanup_decl(expr['type'] + "List")
> - fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n")
> - ret += generate_type_cleanup_decl(expr['type'])
> - fdef.write(generate_type_cleanup(expr['type']) + "\n")
> - elif expr.has_key('union'):
> - ret += generate_union(expr['union'], expr['data'])
> - else:
> - continue
> - fdecl.write(ret)
> -
> -fdecl.write('''
> -#endif
> -''')
> -
> -fdecl.flush()
> -fdecl.close()
> -
> -fdef.flush()
> -fdef.close()
> +if __name__ == '__main__':
> + try:
> + opts, args = getopt.gnu_getopt(sys.argv[1:], "p:o:", ["prefix=", "output-dir="])
> + except getopt.GetoptError, err:
> + print str(err)
> + sys.exit(1)
> +
> + output_dir = ""
> + prefix = ""
> + c_file = 'qapi-types.c'
> + h_file = 'qapi-types.h'
> +
> + for o, a in opts:
> + if o in ("-p", "--prefix"):
> + prefix = a
> + elif o in ("-o", "--output-dir"):
> + output_dir = a + "/"
> +
> + c_file = output_dir + prefix + c_file
> + h_file = output_dir + prefix + h_file
> +
> + try:
> + os.makedirs(output_dir)
> + except os.error, e:
> + if e.errno != errno.EEXIST:
> + raise
> +
> + fdef = open(c_file, 'w')
> + fdecl = open(h_file, 'w')
> +
> + fdef.write(mcgen('''
> + /* AUTOMATICALLY GENERATED, DO NOT MODIFY */
> +
> + /*
> + * deallocation functions for schema-defined QAPI types
> + *
> + * Copyright IBM, Corp. 2011
> + *
> + * Authors:
> + * Anthony Liguori <aliguori@us.ibm.com>
> + * Michael Roth <mdroth@linux.vnet.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
> + * See the COPYING.LIB file in the top-level directory.
> + *
> + */
> +
> + #include "qapi/qapi-dealloc-visitor.h"
> + #include "%(prefix)sqapi-types.h"
> + #include "%(prefix)sqapi-visit.h"
> +
> + ''', prefix=prefix))
> +
> + fdecl.write(mcgen('''
> + /* AUTOMATICALLY GENERATED, DO NOT MODIFY */
> +
> + /*
> + * schema-defined QAPI types
> + *
> + * Copyright IBM, Corp. 2011
> + *
> + * Authors:
> + * Anthony Liguori <aliguori@us.ibm.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
> + * See the COPYING.LIB file in the top-level directory.
> + *
> + */
> +
> + #ifndef %(guard)s
> + #define %(guard)s
> +
> + #include "qapi/qapi-types-core.h"
> + ''',
> + guard=guardname(h_file)))
> +
> + exprs = parse_schema(sys.stdin)
> +
> + for expr in exprs:
> + ret = "\n"
> + if expr.has_key('type'):
> + ret += generate_fwd_struct(expr['type'], expr['data'])
> + elif expr.has_key('enum'):
> + ret += generate_enum(expr['enum'], expr['data'])
> + fdef.write(generate_enum_lookup(expr['enum'], expr['data']))
> + elif expr.has_key('union'):
> + ret += generate_fwd_struct(expr['union'], expr['data']) + "\n"
> + ret += generate_enum('%sKind' % expr['union'], expr['data'].keys())
> + else:
> + continue
> + fdecl.write(ret)
> +
> + for expr in exprs:
> + ret = "\n"
> + if expr.has_key('type'):
> + ret += generate_struct(expr['type'], "", expr['data']) + "\n"
> + ret += generate_type_cleanup_decl(expr['type'] + "List")
> + fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n")
> + ret += generate_type_cleanup_decl(expr['type'])
> + fdef.write(generate_type_cleanup(expr['type']) + "\n")
> + elif expr.has_key('union'):
> + ret += generate_union(expr['union'], expr['data'])
> + else:
> + continue
> + fdecl.write(ret)
> +
> + fdecl.write('''
> + #endif
> + ''')
> +
> + fdecl.flush()
> + fdecl.close()
> +
> + fdef.flush()
> + fdef.close()
> --
> 1.7.7.rc3
>
--
Sincerely,
Mike Roth
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/4] qapi-types.py: Don't build paths by hand
2011-10-17 15:29 ` [Qemu-devel] [PATCH 2/4] qapi-types.py: Don't build paths by hand Luiz Capitulino
@ 2011-10-17 21:20 ` Michael Roth
0 siblings, 0 replies; 10+ messages in thread
From: Michael Roth @ 2011-10-17 21:20 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: aliguori, qemu-devel
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
On Mon, 17 Oct 2011 13:29:35 -0200, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> Use os.path.join() instead.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> scripts/qapi-types.py | 6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index 986ff1e..8df4b72 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -177,10 +177,10 @@ if __name__ == '__main__':
> if o in ("-p", "--prefix"):
> prefix = a
> elif o in ("-o", "--output-dir"):
> - output_dir = a + "/"
> + output_dir = a
>
> - c_file = output_dir + prefix + c_file
> - h_file = output_dir + prefix + h_file
> + c_file = os.path.join(output_dir, prefix + c_file)
> + h_file = os.path.join(output_dir, prefix + h_file)
>
> try:
> os.makedirs(output_dir)
> --
> 1.7.7.rc3
>
--
Sincerely,
Mike Roth
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 3/4] qapi-types.py: Fail gracefully if out dir is not specified
2011-10-17 15:29 ` [Qemu-devel] [PATCH 3/4] qapi-types.py: Fail gracefully if out dir is not specified Luiz Capitulino
@ 2011-10-17 21:27 ` Michael Roth
2011-10-18 12:31 ` Luiz Capitulino
0 siblings, 1 reply; 10+ messages in thread
From: Michael Roth @ 2011-10-17 21:27 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: aliguori, qemu-devel
On Mon, 17 Oct 2011 13:29:36 -0200, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> Otherwise we get:
>
> Traceback (most recent call last):
> File "./scripts/qapi-types.py", line 183, in <module>
> os.makedirs(output_dir)
> File "/usr/lib64/python2.7/os.py", line 157, in makedirs
> mkdir(name, mode)
> OSError: [Errno 2] No such file or directory: ''
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> scripts/qapi-types.py | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index 8df4b72..4a2ddc4 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -178,7 +178,11 @@ if __name__ == '__main__':
> prefix = a
> elif o in ("-o", "--output-dir"):
> output_dir = a
> -
> +
> + if not output_dir:
> + sys.stdout.write("ouput directory was not specified\n")
> + sys.exit(1)
> +
We should probably just set output_dir to os.getcwd() here.
> c_file = os.path.join(output_dir, prefix + c_file)
> h_file = os.path.join(output_dir, prefix + h_file)
>
> --
> 1.7.7.rc3
>
--
Sincerely,
Mike Roth
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 4/4] qapi-types.py: Drop unused variable
2011-10-17 15:29 ` [Qemu-devel] [PATCH 4/4] qapi-types.py: Drop unused variable Luiz Capitulino
@ 2011-10-17 21:29 ` Michael Roth
0 siblings, 0 replies; 10+ messages in thread
From: Michael Roth @ 2011-10-17 21:29 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: aliguori, qemu-devel
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
On Mon, 17 Oct 2011 13:29:37 -0200, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
> scripts/qapi-types.py | 1 -
> 1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index 4a2ddc4..28d7f01 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -65,7 +65,6 @@ def generate_enum_lookup(name, values):
> const char *%(name)s_lookup[] = {
> ''',
> name=name)
> - i = 0
> for value in values:
> ret += mcgen('''
> "%(value)s",
> --
> 1.7.7.rc3
>
--
Sincerely,
Mike Roth
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 3/4] qapi-types.py: Fail gracefully if out dir is not specified
2011-10-17 21:27 ` Michael Roth
@ 2011-10-18 12:31 ` Luiz Capitulino
0 siblings, 0 replies; 10+ messages in thread
From: Luiz Capitulino @ 2011-10-18 12:31 UTC (permalink / raw)
To: Michael Roth; +Cc: aliguori, qemu-devel
On Mon, 17 Oct 2011 16:27:34 -0500
Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> On Mon, 17 Oct 2011 13:29:36 -0200, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> > Otherwise we get:
> >
> > Traceback (most recent call last):
> > File "./scripts/qapi-types.py", line 183, in <module>
> > os.makedirs(output_dir)
> > File "/usr/lib64/python2.7/os.py", line 157, in makedirs
> > mkdir(name, mode)
> > OSError: [Errno 2] No such file or directory: ''
> >
> > Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> > ---
> > scripts/qapi-types.py | 6 +++++-
> > 1 files changed, 5 insertions(+), 1 deletions(-)
> >
> > diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> > index 8df4b72..4a2ddc4 100644
> > --- a/scripts/qapi-types.py
> > +++ b/scripts/qapi-types.py
> > @@ -178,7 +178,11 @@ if __name__ == '__main__':
> > prefix = a
> > elif o in ("-o", "--output-dir"):
> > output_dir = a
> > -
> > +
> > + if not output_dir:
> > + sys.stdout.write("ouput directory was not specified\n")
> > + sys.exit(1)
> > +
>
> We should probably just set output_dir to os.getcwd() here.
Fair enough.
>
> > c_file = os.path.join(output_dir, prefix + c_file)
> > h_file = os.path.join(output_dir, prefix + h_file)
> >
> > --
> > 1.7.7.rc3
> >
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-10-18 12:31 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-17 15:29 [Qemu-devel] [PATCH v1 0/4]: QAPI: Small fixes for qapi-types.py Luiz Capitulino
2011-10-17 15:29 ` [Qemu-devel] [PATCH 1/4] qapi-types.py: Add a main() like function Luiz Capitulino
2011-10-17 21:19 ` Michael Roth
2011-10-17 15:29 ` [Qemu-devel] [PATCH 2/4] qapi-types.py: Don't build paths by hand Luiz Capitulino
2011-10-17 21:20 ` Michael Roth
2011-10-17 15:29 ` [Qemu-devel] [PATCH 3/4] qapi-types.py: Fail gracefully if out dir is not specified Luiz Capitulino
2011-10-17 21:27 ` Michael Roth
2011-10-18 12:31 ` Luiz Capitulino
2011-10-17 15:29 ` [Qemu-devel] [PATCH 4/4] qapi-types.py: Drop unused variable Luiz Capitulino
2011-10-17 21:29 ` Michael Roth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).