Quantcast

Gramps exit code

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Gramps exit code

hutou
I am writing a bash script to backup my data and want to secure it, but I have a problem with the gramps exit code !
If I feed gramps with an inexisting database to backup, then an error message is printed, but the return code says everything it's Ok !
See below :

$ gramps -O MissingBase -e backup.gramps
540: WARNING: bottombar.gpr.py: line 90: MISE EN GARDE : le module pyexiv2 n'est pas chargé. Les métadonnées image ne sont pas disponibles.
Erreur : l'arbre d'entrée « MissingBase » n'existe pas.
Si il s'agit du format GEDCOM, Gramps-xml ou grdb, utilisez plutôt l'option -i pour l'importer dans un arbre familial.
$ echo $?
0
$
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gramps exit code

Benny Malengier



2012/11/8 hutou <[hidden email]>
I am writing a bash script to backup my data and want to secure it, but I
have a problem with the gramps exit code !
If I feed gramps with an *inexisting* database to backup, then an error
message is printed, but the return code says everything it's Ok !

Hmm, some of this was changed because Gramps was throwing an exception with return code 1, instead of just exiting.

I think the offending code for you is in cli/arghandler.py
If you search for sys.exit, you see there    sys.exit(0) and not what you would want, sys.exit(1)

Change the 0 to 1, save, and try again.
However, it might be better to raise an exception instead, and then in cli/grampscli.py write a try block around line 326...

Also, in the file gramps.py, at the end, you see: if errors ...
It might be optimal to also there do  a sys.exit(1) instead of just finishing the script.

If you make a patch, to upload it to a bug ticket on the bug tracker

Note that next version of Gramps will be quite different, you will need to retest bash scripts.

Benny

See below :





--
View this message in context: http://gramps.1791082.n4.nabble.com/Gramps-exit-code-tp4657313.html
Sent from the GRAMPS - User mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gramps exit code

hutou
Well... thanks for your answer and suggestions. I am sorry, but I think it would be a (very !) hard task for me to write a patch, as I do not even have a basic knowledge of the gramps source code and my Python skills are barely measurable :-(
You say the next version of gramps will be quite different : do you mean this problem will be solved ?
If so, have you any idea of the future release date ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gramps exit code

Benny Malengier

2012/11/9 hutou <[hidden email]>
Well... thanks for your answer and suggestions. I am sorry, but I think it
would be a (very !) hard task for me to write a patch, as I do not even have
a basic knowledge of the gramps source code and my Python skills are barely
measurable :-(

But you write a bash script, and gramps is written in python, which is also a scripting language and considerably more easy!
It is just a matter of changing those 0's in 1's and letting us know if that fixes it for you.

You say the next version of gramps will be quite different : do you mean
this problem will be solved ?

No, it will only be fixed if someone tests some changes. If you write bash scripts, you should be able to do the 0 to 1 change, and let us know if it fixes things.
 
If so, have you any idea of the future release date ?

We will release an alpha and beta version still this year, but a stable version will only be for spring 2013.



--
View this message in context: http://gramps.1791082.n4.nabble.com/Gramps-exit-code-tp4657313p4657322.html
Sent from the GRAMPS - User mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gramps exit code

hutou
Ok, I understand what you mean and it seems easy, indeed !
I'll give it a try.
Loading...