Quantcast

python code error???

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

python code error???

robhealey1
Greetings:

Could anyone please help me figure put a better way of doing this?
Once it has a True, I need it to stop searching...

I know it needs some kind of conditional in it, but where and how???

_DU = False
try:
    from packaging import logger
    from packaging.util import find_packages, convert_path, newer
    _DU = True
except ImportError:
    pass

try:
    from distutils2 import logger
    from distutils2.util import find_packages, convert_path, newer
    _DU = True
except ImportError:
    pass

try:
    from distutils import log as logger
    from distutils.util import find_packages, convert_path, newer
    _DU = True
except ImportError:
    pass

# no Distutils, Distutils2, packaging is NOT installed!
if _DU == False:
    sys.exit('Distutils, Distutils2, Packaging is REQUIRED!')

--
Sincerely yours,
Rob G. Healey

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: python code error???

Stephen George
Hi Rob,

If I understand correctly, once you get a import to work, you dont want
to import the other libraries?

how about

try:
     from packaging import logger
     from packaging.util import find_packages, convert_path, newer
except ImportError:
     try:
         from distutils2 import logger
      from distutils2.util import find_packages, convert_path, newer
     except ImportError:
         try:
             from distutils import log as logger
             from distutils.util import find_packages, convert_path, newer
         except ImportError:
             # no Distutils, Distutils2, packaging is NOT installed!
             sys.exit('Distutils, Distutils2, Packaging is REQUIRED!')


Does that do what you need?

Steve

On 22/04/12 15:52, Rob Healey wrote:

> Greetings:
>
> Could anyone please help me figure put a better way of doing this?
> Once it has a True, I need it to stop searching...
>
> I know it needs some kind of conditional in it, but where and how???
>
> _DU = False
> try:
>      from packaging import logger
>      from packaging.util import find_packages, convert_path, newer
>      _DU = True
> except ImportError:
>      pass
>
> try:
>      from distutils2 import logger
>      from distutils2.util import find_packages, convert_path, newer
>      _DU = True
> except ImportError:
>      pass
>
> try:
>      from distutils import log as logger
>      from distutils.util import find_packages, convert_path, newer
>      _DU = True
> except ImportError:
>      pass
>
> # no Distutils, Distutils2, packaging is NOT installed!
> if _DU == False:
>      sys.exit('Distutils, Distutils2, Packaging is REQUIRED!')
>


------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Loading...