Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
c3c1383a
Commit
c3c1383a
authored
10 years ago
by
Paulus Schoutsen
Browse files
Options
Downloads
Patches
Plain Diff
More error checking added on start
parent
9f241013
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/__main__.py
+35
-5
35 additions, 5 deletions
homeassistant/__main__.py
homeassistant/loader.py
+2
-1
2 additions, 1 deletion
homeassistant/loader.py
with
37 additions
and
6 deletions
homeassistant/__main__.py
+
35
−
5
View file @
c3c1383a
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
sys
import
sys
import
os
import
os
import
argparse
import
argparse
import
importlib
try
:
try
:
from
homeassistant
import
bootstrap
from
homeassistant
import
bootstrap
...
@@ -45,14 +46,43 @@ def main():
...
@@ -45,14 +46,43 @@ def main():
unittest
.
main
(
module
=
'
homeassistant.test
'
)
unittest
.
main
(
module
=
'
homeassistant.test
'
)
else
:
else
:
config_path
=
os
.
path
.
join
(
args
.
config
,
'
home-assistant.conf
'
)
# Validate that all core dependencies are installed
import_fail
=
False
for
module
in
[
'
requests
'
]:
try
:
importlib
.
import_module
(
module
)
except
ImportError
:
import_fail
=
True
print
(
'
Fatal Error: Unable to find dependency {}
'
.
format
(
module
))
if
import_fail
:
print
((
"
Install dependencies by running:
"
"
pip3 install -r requirements.txt
"
))
exit
()
# Test if configuration directory exists
config_dir
=
os
.
path
.
join
(
os
.
getcwd
(),
args
.
config
)
if
not
os
.
path
.
isdir
(
config_dir
):
print
((
'
Fatal Error: Unable to find specified configuration
'
'
directory {}
'
).
format
(
config_dir
))
sys
.
exit
()
config_path
=
os
.
path
.
join
(
config_dir
,
'
home-assistant.conf
'
)
# Ensure a config file exists to make first time usage easier
# Ensure a config file exists to make first time usage easier
if
not
os
.
path
.
isfile
(
config_path
):
if
not
os
.
path
.
isfile
(
config_path
):
with
open
(
config_path
,
'
w
'
)
as
conf
:
try
:
conf
.
write
(
"
[http]
\n
"
)
with
open
(
config_path
,
'
w
'
)
as
conf
:
conf
.
write
(
"
api_password=password
\n\n
"
)
conf
.
write
(
"
[http]
\n
"
)
conf
.
write
(
"
[demo]
\n
"
)
conf
.
write
(
"
api_password=password
\n\n
"
)
conf
.
write
(
"
[demo]
\n
"
)
except
IOError
:
print
((
'
Fatal Error: No configuration file found and unable
'
'
to write a default one to {}
'
).
format
(
config_path
))
sys
.
exit
()
hass
=
bootstrap
.
from_config_file
(
config_path
)
hass
=
bootstrap
.
from_config_file
(
config_path
)
hass
.
start
()
hass
.
start
()
...
...
This diff is collapsed.
Click to expand it.
homeassistant/loader.py
+
2
−
1
View file @
c3c1383a
...
@@ -91,7 +91,8 @@ def _get_component(module):
...
@@ -91,7 +91,8 @@ def _get_component(module):
comp
=
importlib
.
import_module
(
module
)
comp
=
importlib
.
import_module
(
module
)
except
ImportError
:
except
ImportError
:
_LOGGER
.
exception
(
"
Error loading {}
"
.
format
(
module
))
_LOGGER
.
exception
((
"
Error loading {}. Make sure all
"
"
dependencies are installed
"
).
format
(
module
))
return
None
return
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment