def validate_css(self, log): env = cmd_env.PrefixCmdEnv(self._classpath_cmd(), self._in_release_dir) # env.cmd(["java", "org.w3c.css.css.CssValidator", "--help"]) """ Usage: java org.w3c.css.css.CssValidator [OPTIONS] | [URL]* OPTIONS -p, --printCSS Prints the validated CSS (only with text output, the CSS is printed with other outputs) -profile PROFILE, --profile=PROFILE Checks the Stylesheet against PROFILE Possible values for PROFILE are css1, css2, css21 (default), css3, svg, svgbasic, svgtiny, atsc-tv, mobile, tv -medium MEDIUM, --medium=MEDIUM Checks the Stylesheet using the medium MEDIUM Possible values for MEDIUM are all (default), aural, braille, embossed, handheld, print, projection, screen, tty, tv, presentation -output OUTPUT, --output=OUTPUT Prints the result in the selected format Possible values for OUTPUT are text (default), xhtml, html (same result as xhtml), soap12 -lang LANG, --lang=LANG Prints the result in the specified language Possible values for LANG are de, en (default), es, fr, ja, ko, nl, zh-cn, pl, it -warning WARN, --warning=WARN Warnings verbosity level Possible values for WARN are -1 (no warning), 0, 1, 2 (default, all the warnings URL URL can either represent a distant web resource (http://) or a local file (file:/) """ validate_cmd = ["java", "org.w3c.css.css.CssValidator"] for dirpath, dirnames, filenames in os.walk(self._mirror_path): for filename in filenames: if filename.endswith(".css"): path = os.path.join(dirpath, filename) temp_path, tear_down = self._sanitise_css(path) try: page_url = "file://" + temp_path output = release.get_cmd_stdout( env, validate_cmd + [page_url]) finally: tear_down() # the validator doesn't fail properly: it exits # successfully on validation failure if "Sorry! We found the following errors" in output: raise CSSValidationError(path, output)
def _ensure_installed(self, package_name, ppa): release.ensure_installed(self._env, cmd_env.PrefixCmdEnv(["sudo"], self._env), package_name, ppa=ppa)
def clean_environ_env(env): return cmd_env.PrefixCmdEnv( ["sh", "-c", 'env -i HOME="$HOME" PATH="$PATH" "$@"', "clean_environ_env"], env)