Skip to content

Commit 5268595

Browse files
committed
tweak update_components script to exit on all failures
and cleaner formatting
1 parent 63a97df commit 5268595

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

dash/development/update_components.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,17 @@ def booststrap_components(components_source):
4242
status = proc.poll()
4343

4444
if err:
45-
print(err.decode(), file=sys.stderr)
45+
print(("🛑 " if status else "") + err.decode(), file=sys.stderr)
4646

47-
if status == 0:
47+
if status or not out:
4848
print(
49-
"🟢 Finished installing npm dependencies for the following component packages: {} (status={}) 🟢".format(
50-
source_glob, status
51-
),
49+
"🚨 Failed installing npm dependencies for component packages: {source_glob} (status={status}) 🚨",
5250
file=sys.stderr,
5351
)
54-
if not out:
52+
sys.exit(1)
53+
else:
5554
print(
56-
"Failed installing npm dependencies for the following component packages {} (status={})".format(
57-
source_glob, status
58-
),
55+
f"🟢 Finished installing npm dependencies for component packages: {source_glob} 🟢",
5956
file=sys.stderr,
6057
)
6158

@@ -82,13 +79,11 @@ def build_components(components_source):
8279
status = proc.poll()
8380

8481
if err:
85-
print(err.decode(), file=sys.stderr)
82+
print(("🛑 " if status else "") + err.decode(), file=sys.stderr)
8683

87-
if not out:
84+
if status or not out:
8885
print(
89-
"🟢 Finished updating the following component packages {} (status={}) 🟢".format(
90-
source_glob, status
91-
),
86+
f"🚨 Finished updating component packages: {source_glob} (status={status}) 🚨",
9287
file=sys.stderr,
9388
)
9489
sys.exit(1)
@@ -117,21 +112,18 @@ def build_components(components_source):
117112

118113
if not os.path.exists(build_directory):
119114
print(
120-
"Could not locate build artifacts. Check that the npm build process completed successfully for the given package: {}".format(
121-
package
122-
)
115+
"🚨 Could not locate build artifacts."
116+
+ " Check that the npm build process completed"
117+
+ f" successfully for package: {package} 🚨"
123118
)
119+
sys.exit(1)
124120
else:
125-
print("🚚 Moving build artifacts from " + build_directory + " to Dash 🚚")
121+
print(f"🚚 Moving build artifacts from {build_directory} to Dash 🚚")
126122
shutil.rmtree(dest_path)
127123
shutil.copytree(build_directory, dest_path)
128124
with open(os.path.join(dest_path, ".gitkeep"), "w"):
129125
pass
130-
print(
131-
"🟢 Finished moving build artifacts from "
132-
+ build_directory
133-
+ " to Dash 🟢"
134-
)
126+
print(f"🟢 Finished moving build artifacts from {build_directory} to Dash 🟢")
135127

136128

137129
def cli():
@@ -143,7 +135,9 @@ def cli():
143135
)
144136
parser.add_argument(
145137
"components_source",
146-
help="A glob string that matches the Dash component libraries to be updated (eg.'dash-table' // 'dash-core-components|dash-html-components' // 'all'). The default argument is 'all'.",
138+
help="A glob string that matches the Dash component libraries to be updated"
139+
" (eg.'dash-table' // 'dash-core-components|dash-html-components' // 'all')."
140+
" The default argument is 'all'.",
147141
default="all",
148142
)
149143

@@ -153,4 +147,5 @@ def cli():
153147
build_components(args.components_source)
154148

155149

156-
cli()
150+
if __name__ == "__main__":
151+
cli()

0 commit comments

Comments
 (0)