mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 17:27:45 +01:00
Fix wizard mkdir (#824)
* Fix CLI wizard mkdir_p with empty path Fixes https://github.com/esphome/issues/issues/796 * Cleanup * Lint
This commit is contained in:
parent
7adaeacd0b
commit
e2c8b21195
3 changed files with 5 additions and 6 deletions
|
@ -80,6 +80,9 @@ def run_system_command(*args):
|
||||||
|
|
||||||
|
|
||||||
def mkdir_p(path):
|
def mkdir_p(path):
|
||||||
|
if not path:
|
||||||
|
# Empty path - means create current dir
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
|
|
|
@ -7,7 +7,7 @@ import os
|
||||||
|
|
||||||
from esphome import const
|
from esphome import const
|
||||||
from esphome.core import CORE
|
from esphome.core import CORE
|
||||||
from esphome.helpers import mkdir_p, write_file_if_changed
|
from esphome.helpers import write_file_if_changed
|
||||||
|
|
||||||
# pylint: disable=unused-import, wrong-import-order
|
# pylint: disable=unused-import, wrong-import-order
|
||||||
from esphome.core import CoreType # noqa
|
from esphome.core import CoreType # noqa
|
||||||
|
@ -88,7 +88,6 @@ class StorageJSON(object):
|
||||||
return json.dumps(self.as_dict(), indent=2) + u'\n'
|
return json.dumps(self.as_dict(), indent=2) + u'\n'
|
||||||
|
|
||||||
def save(self, path):
|
def save(self, path):
|
||||||
mkdir_p(os.path.dirname(path))
|
|
||||||
write_file_if_changed(path, self.to_json())
|
write_file_if_changed(path, self.to_json())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -286,8 +286,6 @@ or use the custom_components folder.
|
||||||
|
|
||||||
|
|
||||||
def copy_src_tree():
|
def copy_src_tree():
|
||||||
import shutil
|
|
||||||
|
|
||||||
source_files = {}
|
source_files = {}
|
||||||
for _, component, _ in iter_components(CORE.config):
|
for _, component, _ in iter_components(CORE.config):
|
||||||
source_files.update(component.source_files)
|
source_files.update(component.source_files)
|
||||||
|
@ -326,8 +324,7 @@ def copy_src_tree():
|
||||||
# Now copy new files
|
# Now copy new files
|
||||||
for target, src_path in source_files_copy.items():
|
for target, src_path in source_files_copy.items():
|
||||||
dst_path = CORE.relative_src_path(*target.split('/'))
|
dst_path = CORE.relative_src_path(*target.split('/'))
|
||||||
mkdir_p(os.path.dirname(dst_path))
|
copy_file_if_changed(src_path, dst_path)
|
||||||
shutil.copy(src_path, dst_path)
|
|
||||||
|
|
||||||
# Finally copy defines
|
# Finally copy defines
|
||||||
write_file_if_changed(CORE.relative_src_path('esphome', 'core', 'defines.h'),
|
write_file_if_changed(CORE.relative_src_path('esphome', 'core', 'defines.h'),
|
||||||
|
|
Loading…
Reference in a new issue