Re: [Freeipa-devel] [PATCH] Use Exception class instead of StandardError

2015-07-27 Thread Martin Basti

On 29/06/15 08:41, Niranjan wrote:

Martin Basti wrote:

On 10/06/15 00:59, Niranjan wrote:

Niranjan wrote:
Greetings,

Please find the modified patch for ipapython/adminutil.py.

I have run few tests manually like running ipa-server-install
as non-root user or provide --quiet and --verbose  to see
if it raises ScriptError properly.

Also i checked by running ipa-server-install and using CTRL-C
to break and see if the KeyboardInterrupt is properly caught.

Please let me know your views on this.

Regards
Niranjan


ACK for IPA 4.3, I don't feel brave enough to push it into IPA 4.2.

Also, would be nice to have migrated all occurrences of StandardError to
Exception, before push.

I actually intend to do that, but i thought i will start small and do this
from one file before i proceed further, I can send patch which migrates all
occurance of standardError to Exception.

Pushed to master: 7d2823040593a4207cfce834a5c6840464fab64b

Martin^2




Niranjan wrote:

Greetings,

I would like to present patch for replacing StandardError exception
with Exception class in ipapython/adminutil.py. Also replacing
BaseException class with Exception class.

Though the use of StandardError is many places. I would like to start
with ipapython/adminutil.py

This is my first patch. Please let me know if my approach on this is
correct.

Could anyone have a look at this please.

Regards
Niranjan
 From 018312f76952ea86c8c6e2396657e0531d2d61ba Mon Sep 17 00:00:00 2001
From: Niranjan Mallapadi 
Date: Mon, 1 Jun 2015 09:41:05 +0530
Subject: [PATCH] Use Exception class instead of BaseException

1. Replace BaseException with Exception class.
2. Remove StandardError and use Exception class. StandError is deprecated 
(Python3)
3 .From python3.0 use of , is not recommended, instead
use "as" keyword (PEP 3110)

Signed-off-by: Niranjan Mallapadi 
---
  ipapython/admintool.py | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ipapython/admintool.py b/ipapython/admintool.py
index 
d55bd18499ac427db8adc0c04096bc2aabdc2bbd..891232b9f387182ac5dbfb279a6f666805261ba1
 100644
--- a/ipapython/admintool.py
+++ b/ipapython/admintool.py
@@ -32,7 +32,7 @@ from ipapython import config
  from ipapython import ipa_log_manager
-class ScriptError(StandardError):
+class ScriptError(Exception):
  """An exception that records an error message and a return value
  """
  def __init__(self, msg='', rval=1):
@@ -169,13 +169,20 @@ class AdminTool(object):
  self.ask_for_options()
  self.setup_logging()
  return_value = self.run()
-except BaseException, exception:
+except Exception as exception:
  traceback = sys.exc_info()[2]
  error_message, return_value = self.handle_error(exception)
  if return_value:
  self.log_failure(error_message, return_value, exception,
  traceback)
  return return_value
+except SystemExit as exception:
+traceback = sys.exc_info()[2]
+error_message, return_value = self.handle_error(exception)
+if return_value:
+self.log_failure(error_message, return_value, exception,
+traceback)
+return return_value
  self.log_success()
  return return_value
--
1.9.3

Removed an attachment of 322 bytes with the following headers:

Content-Type: application/pgp-signature
--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code



--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code




--
Martin Basti






--
Martin Basti

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [PATCH] Use Exception class instead of StandardError

2015-06-28 Thread Niranjan
Martin Basti wrote:
> On 10/06/15 00:59, Niranjan wrote:
> >Niranjan wrote:
> >Greetings,
> >
> >Please find the modified patch for ipapython/adminutil.py.
> >
> >I have run few tests manually like running ipa-server-install
> >as non-root user or provide --quiet and --verbose  to see
> >if it raises ScriptError properly.
> >
> >Also i checked by running ipa-server-install and using CTRL-C
> >to break and see if the KeyboardInterrupt is properly caught.
> >
> >Please let me know your views on this.
> >
> >Regards
> >Niranjan
> >
> ACK for IPA 4.3, I don't feel brave enough to push it into IPA 4.2.
> 
> Also, would be nice to have migrated all occurrences of StandardError to
> Exception, before push.
I actually intend to do that, but i thought i will start small and do this
from one file before i proceed further, I can send patch which migrates all
occurance of standardError to Exception.
> 
> Martin^2
> 
> >
> >
> >>Niranjan wrote:
> >>>Greetings,
> >>>
> >>>I would like to present patch for replacing StandardError exception
> >>>with Exception class in ipapython/adminutil.py. Also replacing
> >>>BaseException class with Exception class.
> >>>
> >>>Though the use of StandardError is many places. I would like to start
> >>>with ipapython/adminutil.py
> >>>
> >>>This is my first patch. Please let me know if my approach on this is
> >>>correct.
> >>Could anyone have a look at this please.
> >>>Regards
> >>>Niranjan
> >>> From 018312f76952ea86c8c6e2396657e0531d2d61ba Mon Sep 17 00:00:00 2001
> >>>From: Niranjan Mallapadi 
> >>>Date: Mon, 1 Jun 2015 09:41:05 +0530
> >>>Subject: [PATCH] Use Exception class instead of BaseException
> >>>
> >>>1. Replace BaseException with Exception class.
> >>>2. Remove StandardError and use Exception class. StandError is deprecated 
> >>>(Python3)
> >>>3 .From python3.0 use of , is not recommended, instead
> >>>use "as" keyword (PEP 3110)
> >>>
> >>>Signed-off-by: Niranjan Mallapadi 
> >>>---
> >>>  ipapython/admintool.py | 11 +--
> >>>  1 file changed, 9 insertions(+), 2 deletions(-)
> >>>
> >>>diff --git a/ipapython/admintool.py b/ipapython/admintool.py
> >>>index 
> >>>d55bd18499ac427db8adc0c04096bc2aabdc2bbd..891232b9f387182ac5dbfb279a6f666805261ba1
> >>> 100644
> >>>--- a/ipapython/admintool.py
> >>>+++ b/ipapython/admintool.py
> >>>@@ -32,7 +32,7 @@ from ipapython import config
> >>>  from ipapython import ipa_log_manager
> >>>-class ScriptError(StandardError):
> >>>+class ScriptError(Exception):
> >>>  """An exception that records an error message and a return value
> >>>  """
> >>>  def __init__(self, msg='', rval=1):
> >>>@@ -169,13 +169,20 @@ class AdminTool(object):
> >>>  self.ask_for_options()
> >>>  self.setup_logging()
> >>>  return_value = self.run()
> >>>-except BaseException, exception:
> >>>+except Exception as exception:
> >>>  traceback = sys.exc_info()[2]
> >>>  error_message, return_value = self.handle_error(exception)
> >>>  if return_value:
> >>>  self.log_failure(error_message, return_value, exception,
> >>>  traceback)
> >>>  return return_value
> >>>+except SystemExit as exception:
> >>>+traceback = sys.exc_info()[2]
> >>>+error_message, return_value = self.handle_error(exception)
> >>>+if return_value:
> >>>+self.log_failure(error_message, return_value, exception,
> >>>+traceback)
> >>>+return return_value
> >>>  self.log_success()
> >>>  return return_value
> >>>-- 
> >>>1.9.3
> >>>
> >>
> >>>Removed an attachment of 322 bytes with the following headers:
> >>>
> >>>Content-Type: application/pgp-signature
> >>>-- 
> >>>Manage your subscription for the Freeipa-devel mailing list:
> >>>https://www.redhat.com/mailman/listinfo/freeipa-devel
> >>>Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
> >
> >
> >>-- 
> >>Manage your subscription for the Freeipa-devel mailing list:
> >>https://www.redhat.com/mailman/listinfo/freeipa-devel
> >>Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
> >
> >
> 
> 
> -- 
> Martin Basti
> 


pgp_mbaoGDgNY.pgp
Description: PGP signature
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [PATCH] Use Exception class instead of StandardError

2015-06-26 Thread Martin Basti

On 10/06/15 00:59, Niranjan wrote:

Niranjan wrote:
Greetings,

Please find the modified patch for ipapython/adminutil.py.

I have run few tests manually like running ipa-server-install
as non-root user or provide --quiet and --verbose  to see
if it raises ScriptError properly.

Also i checked by running ipa-server-install and using CTRL-C
to break and see if the KeyboardInterrupt is properly caught.

Please let me know your views on this.

Regards
Niranjan


ACK for IPA 4.3, I don't feel brave enough to push it into IPA 4.2.

Also, would be nice to have migrated all occurrences of StandardError to 
Exception, before push.


Martin^2





Niranjan wrote:

Greetings,

I would like to present patch for replacing StandardError exception
with Exception class in ipapython/adminutil.py. Also replacing
BaseException class with Exception class.

Though the use of StandardError is many places. I would like to start
with ipapython/adminutil.py

This is my first patch. Please let me know if my approach on this is
correct.

Could anyone have a look at this please.

Regards
Niranjan
 From 018312f76952ea86c8c6e2396657e0531d2d61ba Mon Sep 17 00:00:00 2001
From: Niranjan Mallapadi 
Date: Mon, 1 Jun 2015 09:41:05 +0530
Subject: [PATCH] Use Exception class instead of BaseException

1. Replace BaseException with Exception class.
2. Remove StandardError and use Exception class. StandError is deprecated 
(Python3)
3 .From python3.0 use of , is not recommended, instead
use "as" keyword (PEP 3110)

Signed-off-by: Niranjan Mallapadi 
---
  ipapython/admintool.py | 11 +--
  1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ipapython/admintool.py b/ipapython/admintool.py
index 
d55bd18499ac427db8adc0c04096bc2aabdc2bbd..891232b9f387182ac5dbfb279a6f666805261ba1
 100644
--- a/ipapython/admintool.py
+++ b/ipapython/admintool.py
@@ -32,7 +32,7 @@ from ipapython import config
  from ipapython import ipa_log_manager
  
  
-class ScriptError(StandardError):

+class ScriptError(Exception):
  """An exception that records an error message and a return value
  """
  def __init__(self, msg='', rval=1):
@@ -169,13 +169,20 @@ class AdminTool(object):
  self.ask_for_options()
  self.setup_logging()
  return_value = self.run()
-except BaseException, exception:
+except Exception as exception:
  traceback = sys.exc_info()[2]
  error_message, return_value = self.handle_error(exception)
  if return_value:
  self.log_failure(error_message, return_value, exception,
  traceback)
  return return_value
+except SystemExit as exception:
+traceback = sys.exc_info()[2]
+error_message, return_value = self.handle_error(exception)
+if return_value:
+self.log_failure(error_message, return_value, exception,
+traceback)
+return return_value
  self.log_success()
  return return_value
  
--

1.9.3




Removed an attachment of 322 bytes with the following headers:

Content-Type: application/pgp-signature
--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code




--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code






--
Martin Basti

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Re: [Freeipa-devel] [PATCH] Use Exception class instead of StandardError

2015-06-15 Thread Niranjan
Niranjan wrote:
> Niranjan wrote:
> Greetings,
> 
> Please find the modified patch for ipapython/adminutil.py. 
> 
> I have run few tests manually like running ipa-server-install
> as non-root user or provide --quiet and --verbose  to see 
> if it raises ScriptError properly. 
> 
> Also i checked by running ipa-server-install and using CTRL-C
> to break and see if the KeyboardInterrupt is properly caught. 
> 
> Please let me know your views on this.
Could anyone have a look at the modified patch please.

> 
> Regards
> Niranjan
> 
> 
> From aa74dad193a42b8d7ea1715391c461bcbad888b4 Mon Sep 17 00:00:00 2001
> From: Niranjan Mallapadi 
> Date: Wed, 10 Jun 2015 04:19:46 +0530
> Subject: [PATCH] Use Exception class instead of StandardError
> 
> In except clause, use of "," is not recommended (PEP 3110)
> 
> Signed-off-by: Niranjan Mallapadi 
> ---
>  ipapython/admintool.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ipapython/admintool.py b/ipapython/admintool.py
> index 
> d55bd18499ac427db8adc0c04096bc2aabdc2bbd..5aa1c19bb70f9d9049130d1e2a253abb4b86677b
>  100644
> --- a/ipapython/admintool.py
> +++ b/ipapython/admintool.py
> @@ -32,7 +32,7 @@ from ipapython import config
>  from ipapython import ipa_log_manager
>  
>  
> -class ScriptError(StandardError):
> +class ScriptError(Exception):
>  """An exception that records an error message and a return value
>  """
>  def __init__(self, msg='', rval=1):
> @@ -169,7 +169,7 @@ class AdminTool(object):
>  self.ask_for_options()
>  self.setup_logging()
>  return_value = self.run()
> -except BaseException, exception:
> +except BaseException as exception:
>  traceback = sys.exc_info()[2]
>  error_message, return_value = self.handle_error(exception)
>  if return_value:
> -- 
> 1.9.3
> 




> -- 
> Manage your subscription for the Freeipa-devel mailing list:
> https://www.redhat.com/mailman/listinfo/freeipa-devel
> Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code



pgpXSTMzzCymv.pgp
Description: PGP signature
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

[Freeipa-devel] [PATCH] Use Exception class instead of StandardError

2015-06-09 Thread Niranjan
Niranjan wrote:
Greetings,

Please find the modified patch for ipapython/adminutil.py. 

I have run few tests manually like running ipa-server-install
as non-root user or provide --quiet and --verbose  to see 
if it raises ScriptError properly. 

Also i checked by running ipa-server-install and using CTRL-C
to break and see if the KeyboardInterrupt is properly caught. 

Please let me know your views on this.

Regards
Niranjan




> Niranjan wrote:
> > Greetings,
> > 
> > I would like to present patch for replacing StandardError exception
> > with Exception class in ipapython/adminutil.py. Also replacing
> > BaseException class with Exception class. 
> > 
> > Though the use of StandardError is many places. I would like to start
> > with ipapython/adminutil.py
> > 
> > This is my first patch. Please let me know if my approach on this is 
> > correct.
> Could anyone have a look at this please. 
> > 
> > Regards
> > Niranjan
> 
> > From 018312f76952ea86c8c6e2396657e0531d2d61ba Mon Sep 17 00:00:00 2001
> > From: Niranjan Mallapadi 
> > Date: Mon, 1 Jun 2015 09:41:05 +0530
> > Subject: [PATCH] Use Exception class instead of BaseException
> > 
> > 1. Replace BaseException with Exception class.
> > 2. Remove StandardError and use Exception class. StandError is deprecated 
> > (Python3)
> > 3 .From python3.0 use of , is not recommended, instead
> > use "as" keyword (PEP 3110)
> > 
> > Signed-off-by: Niranjan Mallapadi 
> > ---
> >  ipapython/admintool.py | 11 +--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/ipapython/admintool.py b/ipapython/admintool.py
> > index 
> > d55bd18499ac427db8adc0c04096bc2aabdc2bbd..891232b9f387182ac5dbfb279a6f666805261ba1
> >  100644
> > --- a/ipapython/admintool.py
> > +++ b/ipapython/admintool.py
> > @@ -32,7 +32,7 @@ from ipapython import config
> >  from ipapython import ipa_log_manager
> >  
> >  
> > -class ScriptError(StandardError):
> > +class ScriptError(Exception):
> >  """An exception that records an error message and a return value
> >  """
> >  def __init__(self, msg='', rval=1):
> > @@ -169,13 +169,20 @@ class AdminTool(object):
> >  self.ask_for_options()
> >  self.setup_logging()
> >  return_value = self.run()
> > -except BaseException, exception:
> > +except Exception as exception:
> >  traceback = sys.exc_info()[2]
> >  error_message, return_value = self.handle_error(exception)
> >  if return_value:
> >  self.log_failure(error_message, return_value, exception,
> >  traceback)
> >  return return_value
> > +except SystemExit as exception:
> > +traceback = sys.exc_info()[2]
> > +error_message, return_value = self.handle_error(exception)
> > +if return_value:
> > +self.log_failure(error_message, return_value, exception,
> > +traceback)
> > +return return_value
> >  self.log_success()
> >  return return_value
> >  
> > -- 
> > 1.9.3
> > 
> 
> 
> > Removed an attachment of 322 bytes with the following headers:
> > 
> > Content-Type: application/pgp-signature
> 
> > -- 
> > Manage your subscription for the Freeipa-devel mailing list:
> > https://www.redhat.com/mailman/listinfo/freeipa-devel
> > Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
> 



> -- 
> Manage your subscription for the Freeipa-devel mailing list:
> https://www.redhat.com/mailman/listinfo/freeipa-devel
> Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

From aa74dad193a42b8d7ea1715391c461bcbad888b4 Mon Sep 17 00:00:00 2001
From: Niranjan Mallapadi 
Date: Wed, 10 Jun 2015 04:19:46 +0530
Subject: [PATCH] Use Exception class instead of StandardError

In except clause, use of "," is not recommended (PEP 3110)

Signed-off-by: Niranjan Mallapadi 
---
 ipapython/admintool.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ipapython/admintool.py b/ipapython/admintool.py
index 
d55bd18499ac427db8adc0c04096bc2aabdc2bbd..5aa1c19bb70f9d9049130d1e2a253abb4b86677b
 100644
--- a/ipapython/admintool.py
+++ b/ipapython/admintool.py
@@ -32,7 +32,7 @@ from ipapython import config
 from ipapython import ipa_log_manager
 
 
-class ScriptError(StandardError):
+class ScriptError(Exception):
 """An exception that records an error message and a return value
 """
 def __init__(self, msg='', rval=1):
@@ -169,7 +169,7 @@ class AdminTool(object):
 self.ask_for_options()
 self.setup_logging()
 return_value = self.run()
-except BaseException, exception:
+except BaseException as exception:
 traceback = sys.exc_info()[2]
 error_message, return_value = self.handle_error(exception)
 if return_value:
-- 
1.9.3



pgpBEOA6w7AWI.pgp
Description: PGP signature
-- 
Manage your subscription