Merge ~adam-collard/maas:nuke-scss-remnants into maas:master

Proposed by Adam Collard
Status: Merged
Approved by: Adam Collard
Approved revision: e259ec6e6196afa94d0238184edb06a1c7d8d1e7
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~adam-collard/maas:nuke-scss-remnants
Merge into: maas:master
Diff against target: 251 lines (+35/-142)
3 files modified
Makefile (+1/-1)
dev/null (+0/-64)
services/reloader/run (+34/-77)
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
MAAS Lander unittests Pending
Review via email: mp+395731@code.launchpad.net

Commit message

Remove last vestiges of scss

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

+1, small nit inline

review: Approve
e259ec6... by Adam Collard

Use f-string instead of .format()

Revision history for this message
Adam Collard (adam-collard) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index c0efcd1..42cc456 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -543,7 +543,7 @@ source-package-clean:
6
7 # Debugging target. Allows printing of any variable.
8 # As an example, try:
9-# make print-scss_input
10+# make print-BIN_SCRIPTS
11 print-%:
12 @echo $* = $($*)
13
14diff --git a/services/reloader/run b/services/reloader/run
15index 43382c9..b1083f6 100755
16--- a/services/reloader/run
17+++ b/services/reloader/run
18@@ -27,33 +27,20 @@ import pyinotify
19
20
21 TRIGGER_EVENTS = (
22- pyinotify.IN_CLOSE_WRITE |
23- pyinotify.IN_MOVED_FROM |
24- pyinotify.IN_MOVED_TO |
25- pyinotify.IN_DELETE)
26+ pyinotify.IN_CLOSE_WRITE
27+ | pyinotify.IN_MOVED_FROM
28+ | pyinotify.IN_MOVED_TO
29+ | pyinotify.IN_DELETE
30+)
31
32
33 def is_interesting_python_change(filename):
34 return (
35- filename is not None and
36- filename.endswith(".py") and
37- not filename.startswith(".") and
38- not filename.endswith("_flymake.py"))
39-
40-
41-def is_interesting_scss_change(filename):
42- return (
43- filename is not None and
44- filename.endswith(".scss") and
45- not filename.startswith("."))
46-
47-
48-def is_interesting_js_change(filename):
49- return (
50- filename is not None and
51- filename.endswith(".js") and
52- not filename.startswith(".") and
53- not filename.endswith("min.js"))
54+ filename is not None
55+ and filename.endswith(".py")
56+ and not filename.startswith(".")
57+ and not filename.endswith("_flymake.py")
58+ )
59
60
61 def is_supervised(dirname):
62@@ -64,28 +51,13 @@ def handle_python_change(event, *services):
63 for service in services:
64 service_dir = "services/%s" % service
65 if is_supervised(service_dir):
66- print("<-- {0.pathname} changed; reloading {1}.".format(
67- event, service))
68+ print(f"<-- {event.pathname} changed; reloading {service}.")
69 check_call(("svc", "-du", service_dir))
70
71
72-def handle_scss_change(event):
73- print("<-- {0.pathname} changed; rebuilding CSS.".format(event))
74- check_call(("make", "-s", "assets"))
75-
76-
77-def handle_js_change(event):
78- print("<-- {0.pathname} changed; rebuilding JavaScript.".format(event))
79- check_call(("make", "-s", "assets"))
80-
81-
82 def handle_maas_change(event):
83 if is_interesting_python_change(event.name):
84 handle_python_change(event, "regiond")
85- if is_interesting_scss_change(event.name):
86- handle_scss_change(event)
87- if is_interesting_js_change(event.name):
88- handle_js_change(event)
89
90
91 def handle_pserv_change(event):
92@@ -103,38 +75,11 @@ class TestReloader(unittest.TestCase):
93 "module.py": True,
94 ".hidden.py": False,
95 "module_flymake.py": False,
96- }
97+ }
98 observed = {
99 filename: is_interesting_python_change(filename)
100 for filename in expected
101- }
102- self.assertEqual(expected, observed)
103-
104- def test_is_interesting_scss_change(self):
105- expected = {
106- None: False,
107- "script": False,
108- "module.scss": True,
109- ".hidden.scss": False,
110- }
111- observed = {
112- filename: is_interesting_scss_change(filename)
113- for filename in expected
114- }
115- self.assertEqual(expected, observed)
116-
117- def test_is_interesting_js_change(self):
118- expected = {
119- None: False,
120- "script": False,
121- "module.js": True,
122- "module.min.js": False,
123- ".hidden.js": False,
124- }
125- observed = {
126- filename: is_interesting_js_change(filename)
127- for filename in expected
128- }
129+ }
130 self.assertEqual(expected, observed)
131
132
133@@ -155,13 +100,25 @@ if __name__ == "__main__":
134 # Start watch src/ for changes.
135 wm = pyinotify.WatchManager(
136 exclude_filter=lambda path: (
137- "/test/" in path or "/testing/" in path or "/." in path))
138+ "/test/" in path or "/testing/" in path or "/." in path
139+ )
140+ )
141 wm.add_watch(
142- ["src/maasserver", "src/metadataserver"], TRIGGER_EVENTS,
143- proc_fun=handle_maas_change, rec=True, auto_add=True, do_glob=True)
144+ ["src/maasserver", "src/metadataserver"],
145+ TRIGGER_EVENTS,
146+ proc_fun=handle_maas_change,
147+ rec=True,
148+ auto_add=True,
149+ do_glob=True,
150+ )
151 wm.add_watch(
152- ["src/prov*"], TRIGGER_EVENTS, proc_fun=handle_pserv_change,
153- rec=True, auto_add=True, do_glob=True)
154+ ["src/prov*"],
155+ TRIGGER_EVENTS,
156+ proc_fun=handle_pserv_change,
157+ rec=True,
158+ auto_add=True,
159+ do_glob=True,
160+ )
161 # Open log file.
162 if "logdir" in environ:
163 logdir = environ["logdir"]
164@@ -173,13 +130,13 @@ if __name__ == "__main__":
165 if not sys.stdout.line_buffering:
166 sys.stdout.flush()
167 sys.stdout = TextIOWrapper(
168- sys.stdout.buffer, sys.stdout.encoding,
169- line_buffering=True)
170+ sys.stdout.buffer, sys.stdout.encoding, line_buffering=True
171+ )
172 if not sys.stderr.line_buffering:
173 sys.stderr.flush()
174 sys.stderr = TextIOWrapper(
175- sys.stderr.buffer, sys.stderr.encoding,
176- line_buffering=True)
177+ sys.stderr.buffer, sys.stderr.encoding, line_buffering=True
178+ )
179 # Keep watching for ever.
180 notifier = pyinotify.Notifier(wm)
181 notifier.loop()
182diff --git a/src/maastesting/tests/test_scss.py b/src/maastesting/tests/test_scss.py
183deleted file mode 100644
184index a9c33e5..0000000
185--- a/src/maastesting/tests/test_scss.py
186+++ /dev/null
187@@ -1,64 +0,0 @@
188-# Copyright 2015 Canonical Ltd. This software is licensed under the
189-# GNU Affero General Public License version 3 (see the file LICENSE).
190-
191-"""Check the current generated css matches generated css."""
192-
193-
194-import os
195-from os.path import exists, join
196-from pipes import quote
197-from subprocess import PIPE, Popen, STDOUT
198-from unittest import skipUnless
199-
200-from testtools.content import Content, UTF8_TEXT
201-
202-from maastesting import root
203-from maastesting.testcase import MAASTestCase
204-
205-
206-class TestCompiledSCSS(MAASTestCase):
207- def execute(self, *command):
208- process = Popen(command, stdout=PIPE, stderr=STDOUT, cwd=root)
209- output, _ = process.communicate()
210- if len(output) != 0:
211- name = "stdout/err from `%s`" % " ".join(map(quote, command))
212- self.addDetail(name, Content(UTF8_TEXT, lambda: [output]))
213- self.assertEqual(0, process.wait(), "failed to compile css.")
214-
215- def read_content(self, filename):
216- with open(filename, "rb") as stream:
217- return stream.read()
218-
219- @skipUnless(
220- exists(join(root, "bin", "sass")), "bin/sass is not available."
221- )
222- def test_css_up_to_date(self):
223- """
224- In-tree compiled CSS must match SCSS compilation.
225- """
226- in_tree_css_path = os.path.join(
227- root, "src", "maasserver", "static", "css", "build.css"
228- )
229-
230- self.assertIs(
231- os.path.exists(in_tree_css_path), True, "build.css is missing."
232- )
233-
234- # Compile the scss into css into a temp directory.
235- output_dir = self.make_dir()
236- self.execute(
237- "bin/sass",
238- "--include-path=src/maasserver/static/scss",
239- "--output-style",
240- "compressed",
241- "src/maasserver/static/scss/build.scss",
242- "-o",
243- output_dir,
244- )
245-
246- # Content should be equal. Doesn't use assertEquals so the error
247- # output doesn't contain the contents.
248- in_tree_css = self.read_content(in_tree_css_path)
249- tmp_css = self.read_content(os.path.join(output_dir, "build.css"))
250- if in_tree_css != tmp_css:
251- self.fail("build.css is out-of-date. (run 'make styles')")

Subscribers

People subscribed via source and target branches