def _ref_js(self, js_source): js_file = u"_" + os.path.basename(js_source) try: if not os.path.exists(js_file): urlretrieve(js_source, js_file) _script_src = QUrl.fromLocalFile(QDir.current().filePath(js_file)).toString() except Exception as exc: print('Download %s failed, using CDN: %s' % (js_source, exc)) _script_src = js_source return u"""<script src='""" + _script_src + u"""'></script>"""