def run(self, opts): cache = {} if os.path.exists(self.CACHE): cache = cPickle.load(open(self.CACHE, 'rb')) for f, mtime in self.get_files(cache): self.info('\tChecking', f) errors = False ext = os.path.splitext(f)[1] if ext in {'.py', '.recipe'}: p = subprocess.Popen(['flake8', '--ignore=E,W', f]) if p.wait() != 0: errors = True else: from calibre.utils.serve_coffee import check_coffeescript try: check_coffeescript(f) except: errors = True if errors: cPickle.dump(cache, open(self.CACHE, 'wb'), -1) subprocess.call(['gvim', '-S', self.j(self.SRC, '../session.vim'), '-f', f]) raise SystemExit(1) cache[f] = mtime cPickle.dump(cache, open(self.CACHE, 'wb'), -1) wn_path = os.path.expanduser('~/work/srv/main/static') if os.path.exists(wn_path): sys.path.insert(0, wn_path) self.info('\tChecking Changelog...') import whats_new whats_new.render_changelog(self.j(self.d(self.SRC), 'Changelog.yaml')) sys.path.remove(wn_path)
def file_has_errors(self, f): ext = os.path.splitext(f)[1] if ext in {'.py', '.recipe'}: p = subprocess.Popen(['flake8-python2', '--filename', '*.py,*.recipe', f]) return p.wait() != 0 elif ext == '.pyj': p = subprocess.Popen(['rapydscript', 'lint', f]) return p.wait() != 0 elif ext == '.yaml': sys.path.insert(0, self.wn_path) import whats_new whats_new.render_changelog(self.j(self.d(self.SRC), 'Changelog.yaml')) sys.path.remove(self.wn_path) else: from calibre.utils.serve_coffee import check_coffeescript try: check_coffeescript(f) except: return True