예제 #1
0
파일: check.py 프로젝트: sss/calibre
 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/servers/src/calibre_servers/main')
     if os.path.exists(wn_path):
         sys.path.insert(0, wn_path)
         self.info('\tChecking Changelog...')
         os.environ['DJANGO_SETTINGS_MODULE'] = 'calibre_servers.status.settings'
         import whats_new
         whats_new.test()
         sys.path.remove(wn_path)
예제 #2
0
 def run(self, opts):
     cache = {}
     if os.path.exists(self.CACHE):
         cache = cPickle.load(open(self.CACHE, 'rb'))
     builtins = list(set_builtins(self.BUILTINS))
     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'}:
             w = check_for_python_errors(open(f, 'rb').read(), f)
             if w:
                 errors = True
                 self.report_errors(w)
         else:
             try:
                 subprocess.check_call(['coffee', '-c', '-p', f],
                                       stdout=open(os.devnull, 'wb'))
             except:
                 errors = True
         if errors:
             cPickle.dump(cache, open(self.CACHE, 'wb'), -1)
             subprocess.call(['gvim', '-f', f])
             raise SystemExit(1)
         cache[f] = mtime
     for x in builtins:
         delattr(__builtin__, x)
     cPickle.dump(cache, open(self.CACHE, 'wb'), -1)
     wn_path = os.path.expanduser('~/work/servers/src/calibre_servers/main')
     if os.path.exists(wn_path):
         sys.path.insert(0, wn_path)
         self.info('\tChecking Changelog...')
         os.environ[
             'DJANGO_SETTINGS_MODULE'] = 'calibre_servers.status.settings'
         import whats_new
         whats_new.test()
         sys.path.remove(wn_path)
예제 #3
0
 def run(self, opts):
     cache = {}
     if os.path.exists(self.CACHE):
         cache = cPickle.load(open(self.CACHE, 'rb'))
     builtins = list(set_builtins(self.BUILTINS))
     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'}:
             w = check_for_python_errors(open(f, 'rb').read(), f)
             if w:
                 errors = True
                 self.report_errors(w)
         else:
             try:
                 subprocess.check_call(['coffee', '-c', '-p', f],
                         stdout=open(os.devnull, 'wb'))
             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
     for x in builtins:
         delattr(__builtin__, x)
     cPickle.dump(cache, open(self.CACHE, 'wb'), -1)
     wn_path = os.path.expanduser('~/work/servers/src/calibre_servers/main')
     if os.path.exists(wn_path):
         sys.path.insert(0, wn_path)
         self.info('\tChecking Changelog...')
         os.environ['DJANGO_SETTINGS_MODULE'] = 'calibre_servers.status.settings'
         import whats_new
         whats_new.test()
         sys.path.remove(wn_path)