exttools thinks exttools.pyo is a directory

Bug #1569799 reported by Paul Healy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
TOSCA Parser
Fix Released
High
Sharat Sharma
Gentoo Linux
New
Undecided
Unassigned

Bug Description

Exception thrown:
$ tosca-parser --template-file=example.yaml
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/tosca-parser", line 6, in <module>
    from toscaparser.shell import main
  File "/usr/lib64/python2.7/site-packages/toscaparser/shell.py", line 17, in <module>
    from toscaparser.tosca_template import ToscaTemplate
  File "/usr/lib64/python2.7/site-packages/toscaparser/tosca_template.py", line 24, in <module>
    import toscaparser.imports
  File "/usr/lib64/python2.7/site-packages/toscaparser/imports.py", line 20, in <module>
    from toscaparser.elements.tosca_type_validation import TypeValidation
  File "/usr/lib64/python2.7/site-packages/toscaparser/elements/tosca_type_validation.py", line 19, in <module>
    class TypeValidation(object):
  File "/usr/lib64/python2.7/site-packages/toscaparser/elements/tosca_type_validation.py", line 32, in TypeValidation
    exttools = ExtTools()
  File "/usr/lib64/python2.7/site-packages/toscaparser/extensions/exttools.py", line 28, in __init__
    self.EXTENSION_INFO = self._load_extensions()
  File "/usr/lib64/python2.7/site-packages/toscaparser/extensions/exttools.py", line 46, in _load_extensions
    ext_files = [f for f in os.listdir(extpath) if f.endswith('.py')
OSError: [Errno 20] Not a directory: '/usr/lib64/python2.7/site-packages/toscaparser/extensions/exttools.pyo'

Suggested fix:

diff --git a/toscaparser/extensions/exttools.py b/toscaparser/extensions/exttools.py
index 963b958..cebef14 100644
--- a/toscaparser/extensions/exttools.py
+++ b/toscaparser/extensions/exttools.py
@@ -36,7 +36,7 @@ class ExtTools(object):

         extdirs = [e for e in os.listdir(abs_path) if
                    not e.startswith('tests') and
- not e.endswith('.pyc') and not e.endswith('.py')]
+ not e.endswith('.pyc') and not e.endswith('.py') and not e.endswith('.pyo')]

         for e in extdirs:
             log.info(e)

pyo files are optimised compiled byte files.

Changed in tosca-parser:
assignee: nobody → Sharat Sharma (sharat-sharma)
Revision history for this message
Sahdev Zala (spzala) wrote :

@Paul, thanks much for reporting it and providing a fix.

@Sharat, are you still planning to work on it? Seems like a quick fix.

Changed in tosca-parser:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Sharat Sharma (sharat-sharma) wrote :

Yes. I am committing it now

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tosca-parser (master)

Reviewed: https://review.openstack.org/334284
Committed: https://git.openstack.org/cgit/openstack/tosca-parser/commit/?id=d01a7273f4115c2b02d8003d307ee4673ede11c9
Submitter: Jenkins
Branch: master

commit d01a7273f4115c2b02d8003d307ee4673ede11c9
Author: Sahdev Zala <email address hidden>
Date: Sun Jun 26 20:57:28 2016 -0700

    Allow optimized compiled file in extensions

    Optimized complied byte files ends with .pyo and should be allowed.

    Change-Id: Id0b1f25c18ef29f5fa8f600b6cd6d3191c093b75
    Closes-Bug: #1569799

Changed in tosca-parser:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.