diff mbox

[3/4] qapi-types.py: Fail gracefully if out dir is not specified

Message ID 1318865377-3328-4-git-send-email-lcapitulino@redhat.com
State New
Headers show

Commit Message

Luiz Capitulino Oct. 17, 2011, 3:29 p.m. UTC
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(-)

Comments

Michael Roth Oct. 17, 2011, 9:27 p.m. UTC | #1
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
>
Luiz Capitulino Oct. 18, 2011, 12:31 p.m. UTC | #2
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
> > 
>
diff mbox

Patch

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)