[yt-svn] commit/yt: xarthisius: Remove duplicated code in yt reason/serve
Bitbucket
commits-noreply at bitbucket.org
Thu Feb 16 11:20:28 PST 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/edab16cb41c9/
changeset: edab16cb41c9
branch: yt
user: xarthisius
date: 2012-02-16 20:17:35
summary: Remove duplicated code in yt reason/serve
affected #: 1 file
diff -r cee5d1dd61520761f8b4a1ff103cc9c0b90a857f -r edab16cb41c9df3919691687f993e6b4adfe576b yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -1140,76 +1140,6 @@
if not os.path.isdir(args.output): os.makedirs(args.output)
pc.save(os.path.join(args.output,"%s" % (pf)))
-class YTReasonCmd(YTCommand):
- name = "reason"
- args = (
- dict(short="-o", long="--open-browser", action="store_true",
- default = False, dest='open_browser',
- help="Open a web browser."),
- dict(short="-p", long="--port", action="store",
- default = 0, dest='port',
- help="Port to listen on"),
- dict(short="-f", long="--find", action="store_true",
- default = False, dest="find",
- help="At startup, find all *.hierarchy files in the CWD"),
- dict(short="-d", long="--debug", action="store_true",
- default = False, dest="debug",
- help="Add a debugging mode for cell execution")
- )
- description = \
- """
- Run the Web GUI Reason
- """
-
- def __call__(self, args):
- # We have to do a couple things.
- # First, we check that YT_DEST is set.
- if "YT_DEST" not in os.environ:
- print
- print "*** You must set the environment variable YT_DEST ***"
- print "*** to point to the installation location! ***"
- print
- sys.exit(1)
- if args.port == 0:
- # This means, choose one at random. We do this by binding to a
- # socket and allowing the OS to choose the port for that socket.
- import socket
- sock = socket.socket()
- sock.bind(('', 0))
- args.port = sock.getsockname()[-1]
- del sock
- elif args.port == '-1':
- port = raw_input("Desired yt port? ")
- try:
- args.port = int(port)
- except ValueError:
- print "Please try a number next time."
- return 1
- base_extjs_path = os.path.join(os.environ["YT_DEST"], "src")
- if not os.path.isfile(os.path.join(base_extjs_path, "ext-resources", "ext-all.js")):
- print
- print "*** You are missing the ExtJS support files. You ***"
- print "*** You can get these by either rerunning the ***"
- print "*** install script installing, or downloading ***"
- print "*** them manually. ***"
- print
- sys.exit(1)
- from yt.config import ytcfg;ytcfg["yt","__withinreason"]="True"
- import yt.utilities.bottle as bottle
- from yt.gui.reason.extdirect_repl import ExtDirectREPL
- from yt.gui.reason.bottle_mods import uuid_serve_functions, PayloadHandler
- hr = ExtDirectREPL(base_extjs_path)
- hr.debug = PayloadHandler.debug = args.debug
- if args.find:
- # We just have to find them and store references to them.
- command_line = ["pfs = []"]
- for fn in sorted(glob.glob("*/*.hierarchy")):
- command_line.append("pfs.append(load('%s'))" % fn[:-10])
- hr.execute("\n".join(command_line))
- bottle.debug()
- uuid_serve_functions(open_browser=args.open_browser,
- port=int(args.port), repl=hr)
-
class YTRenderCmd(YTCommand):
args = ("width", "unit", "center","enhance",'outputfn',
@@ -1312,8 +1242,7 @@
import rpdb
rpdb.run_rpdb(int(task))
-class YTServeCmd(YTCommand):
- name = "serve"
+class YTGUICmd(YTCommand):
args = (
dict(short="-o", long="--open-browser", action="store_true",
default = False, dest='open_browser',
@@ -1382,6 +1311,12 @@
uuid_serve_functions(open_browser=args.open_browser,
port=int(args.port), repl=hr)
+class YTServeCmd(YTGUICmd):
+ name = "serve"
+
+class YTReasonCmd(YTGUICmd):
+ name = "reason"
+
class YTStatsCmd(YTCommand):
args = ('outputfn','bn','skip','pf', 'field',
dict(long="--max", action="store_true", default=False,
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list