Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
65ae9780
Commit
65ae9780
authored
Jul 23, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11079 from amegianeg/fix_broad_except_in_inventory
Avoid too broad except in Inventory
parents
35a5e011
37ae5aab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
lib/ansible/inventory/__init__.py
+7
-8
No files found.
lib/ansible/inventory/__init__.py
View file @
65ae9780
...
...
@@ -113,19 +113,18 @@ class Inventory(object):
# class we can show a more apropos error
shebang_present
=
False
try
:
inv_file
=
open
(
host_list
)
first_line
=
inv_file
.
readlines
()[
0
]
inv_file
.
close
()
if
first_line
.
startswith
(
'#!'
):
shebang_present
=
True
except
:
with
open
(
host_list
,
"r"
)
as
inv_file
:
first_line
=
inv_file
.
readline
()
if
first_line
.
startswith
(
"#!"
):
shebang_present
=
True
except
IOError
:
pass
if
is_executable
(
host_list
):
try
:
self
.
parser
=
InventoryScript
(
loader
=
self
.
_loader
,
filename
=
host_list
)
self
.
groups
=
self
.
parser
.
groups
.
values
()
except
:
except
errors
.
AnsibleError
:
if
not
shebang_present
:
raise
errors
.
AnsibleError
(
"The file
%
s is marked as executable, but failed to execute correctly. "
%
host_list
+
\
"If this is not supposed to be an executable script, correct this with `chmod -x
%
s`."
%
host_list
)
...
...
@@ -135,7 +134,7 @@ class Inventory(object):
try
:
self
.
parser
=
InventoryParser
(
filename
=
host_list
)
self
.
groups
=
self
.
parser
.
groups
.
values
()
except
:
except
errors
.
AnsibleError
:
if
shebang_present
:
raise
errors
.
AnsibleError
(
"The file
%
s looks like it should be an executable inventory script, but is not marked executable. "
%
host_list
+
\
"Perhaps you want to correct this with `chmod +x
%
s`?"
%
host_list
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment