Re: [Spacewalk-devel] Python 2/3 compatibility

2016-05-03 Thread Gennadii Altukhov
Hello guys,

the most part of code is adapted to be compatible with Python 2/3 already. So, 
before contribute new Python code, please read this docs/articles:

1) https://wiki.python.org/moin/PortingToPy3k/BilingualQuickRef
2) http://python3porting.com/differences.html?highlight=raise#raise

Pay attention on a fact, that our python code is compatible with Python 2.4 
too, and we would like to save backward compatibility (if you see 'strange' 
construction in code, this is
because of Python 2.4).


- Original Message -
From: "Gennadii Altukhov" <galtu...@redhat.com>
To: spacewalk-devel@redhat.com
Sent: Tuesday, May 3, 2016 10:31:11 AM
Subject: Re: [Spacewalk-devel] Python 2/3 compatibility

Hi,
We have already added changes w/o 'six'. We use only data types and reraise 
from 'six', so we extract this into our own micro-six.


- Original Message -
From: "Duncan Mac-Vicar P." <dmacvi...@suse.de>
To: spacewalk-devel@redhat.com
Sent: Monday, May 2, 2016 10:37:11 PM
Subject: Re: [Spacewalk-devel] Python 2/3 compatibility

On 04/07/2016 06:41 PM, Gennadii Altukhov wrote:
> PS Yes, I know about 'six' module, but I'm not sure we will use it.

Can you explain why?

-- 
Duncan Mac-Vicar P. - http://www.suse.com/

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu,
Graham Norton, HRB 21284 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany




___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] Python 2/3 compatibility

2016-05-03 Thread Gennadii Altukhov
Hi,
We have already added changes w/o 'six'. We use only data types and reraise 
from 'six', so we extract this into our own micro-six.


- Original Message -
From: "Duncan Mac-Vicar P." <dmacvi...@suse.de>
To: spacewalk-devel@redhat.com
Sent: Monday, May 2, 2016 10:37:11 PM
Subject: Re: [Spacewalk-devel] Python 2/3 compatibility

On 04/07/2016 06:41 PM, Gennadii Altukhov wrote:
> PS Yes, I know about 'six' module, but I'm not sure we will use it.

Can you explain why?

-- 
Duncan Mac-Vicar P. - http://www.suse.com/

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu,
Graham Norton, HRB 21284 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany




___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] Python 2/3 compatibility

2016-05-02 Thread Duncan Mac-Vicar P.
On 04/07/2016 06:41 PM, Gennadii Altukhov wrote:
> PS Yes, I know about 'six' module, but I'm not sure we will use it.

Can you explain why?

-- 
Duncan Mac-Vicar P. - http://www.suse.com/

SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu,
Graham Norton, HRB 21284 (AG Nürnberg)
Maxfeldstraße 5, 90409 Nürnberg, Germany




___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] Python 2/3 compatibility

2016-04-08 Thread Pavel Studeník
Hi Gennadii,
I am not sure that you know that Spacewalk is possible to install on
RHEL6 and higher. It doesn't support RHEL5 with python 2.4 [1]. The
compatibility server side should be "only" python2.6+. Client side is
other situation - it should work on RHEL5 as well [2]. The code could
look more readable on server side (you can use 'except ... as ...', etc).

[1] https://fedorahosted.org/spacewalk/wiki/HowToInstall
[2] https://fedorahosted.org/spacewalk/wiki/RegisteringClients

Regards.

On 7.4.2016 18:41, Gennadii Altukhov wrote:
> Hello guys,
>
> Maybe some of you already know, we are trying to adapt our Spacewalk python's 
> code to version 3.x and in the same time save backward compatibility with 
> version 2.x. (we have to support Python from version 2.4). Pavel Studenik is 
> adapting client-side code (rhncfg at this moment) and I server-side. The main 
> question for me is to extract all version-dependent code into mini-library or 
> check a version of python in if-clauses and try-except blocks within the 
> code. Actually I've tried to extract code in a library, but actually, it 
> contained only few functions and set of data-types and I removed it. 
>
> How does it look likes now, for example:
>
> import sys
>
> try:
> PY3 = sys.version_info.major >= 3
> except AttributeError:
> PY3 = False
>
>
> .
> .
> .
>
> if PY3:
> raise InvalidAction(str(pnf)).with_traceback(sys.exc_info()[2])
> else:
> raise InvalidAction(str(pnf)), None, sys.exc_info()[2]
>
>
> At the same moment I can adapt some data-types in the same try-block:
>
> try:
> PY3 = sys.version_info.major >= 3
> import xmlrpc.client as xmlrpclib
> except AttributeError:
> PY3 = False
> import xmlrpclib
>
> Honestly, I'm not happy with many of this 'if PY3:', and I would like to see 
> clean and simple code. What advantages and disadvantages do you see for both 
> of this cases? And If you have any questions you can ask me.
>
> PS Yes, I know about 'six' module, but I'm not sure we will use it.
>
> ___
> Spacewalk-devel mailing list
> Spacewalk-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-devel

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel