• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

修訂23f55a39ea529fb2111b99944cd457733b95c3a2 (tree)
時間2012-07-04 02:52:42
作者Cory Johns <johnsca@geek...>
CommiterCory Johns

Log Message

Suppress warnings when running scripts

Signed-off-by: Cory Johns <johnsca@geek.net>

Change Summary

差異

--- a/Allura/allura/command/script.py
+++ b/Allura/allura/command/script.py
@@ -1,10 +1,12 @@
11 import sys
22 import os.path
33 import cProfile
4+import warnings
45
56 from pylons import c
67 import pylons
78 import webob
9+from sqlalchemy import exc
810
911 from ming.orm import session
1012 from allura.lib import helpers as h
@@ -23,20 +25,22 @@ class ScriptCommand(base.Command):
2325 help='Drop to a debugger on error')
2426
2527 def command(self):
26- self.basic_setup()
27- request = webob.Request.blank('--script--', environ={
28- 'paste.registry':self.registry})
29- self.registry.register(pylons.request, request)
30- if self.options.pdb:
31- base.log.info('Installing exception hook')
32- sys.excepthook = utils.postmortem_hook
33- with open(self.args[1]) as fp:
34- ns = dict(__name__='__main__')
35- sys.argv = self.args[1:]
36- if self.options.profile:
37- cProfile.run(fp, '%s.profile' % os.path.basename(self.args[1]))
38- else:
39- exec fp in ns
28+ with warnings.catch_warnings():
29+ warnings.simplefilter("ignore", category=exc.SAWarning)
30+ self.basic_setup()
31+ request = webob.Request.blank('--script--', environ={
32+ 'paste.registry':self.registry})
33+ self.registry.register(pylons.request, request)
34+ if self.options.pdb:
35+ base.log.info('Installing exception hook')
36+ sys.excepthook = utils.postmortem_hook
37+ with open(self.args[1]) as fp:
38+ ns = dict(__name__='__main__')
39+ sys.argv = self.args[1:]
40+ if self.options.profile:
41+ cProfile.run(fp, '%s.profile' % os.path.basename(self.args[1]))
42+ else:
43+ exec fp in ns
4044
4145 class SetToolAccessCommand(base.Command):
4246 min_args=3