[Yt-svn] commit/yt: 3 new changesets
Bitbucket
commits-noreply at bitbucket.org
Tue Aug 23 13:00:26 PDT 2011
3 new changesets in yt:
http://bitbucket.org/yt_analysis/yt/changeset/b67d3d674f84/
changeset: b67d3d674f84
branch: yt
user: MatthewTurk
date: 2011-08-23 19:18:14
summary: Removing "intents" which never got off the ground.
affected #: 3 files (584 bytes)
--- a/yt/mods.py Tue Aug 23 08:14:55 2011 -0400
+++ b/yt/mods.py Tue Aug 23 13:18:14 2011 -0400
@@ -40,7 +40,6 @@
from yt.utilities.performance_counters import yt_counters, time_function
from yt.config import ytcfg
import yt.utilities.physical_constants as physical_constants
-from yt.utilities.cookbook import Intent
from yt.data_objects.api import \
BinnedProfile1D, BinnedProfile2D, BinnedProfile3D, \
--- a/yt/utilities/command_line.py Tue Aug 23 08:14:55 2011 -0400
+++ b/yt/utilities/command_line.py Tue Aug 23 13:18:14 2011 -0400
@@ -1253,24 +1253,6 @@
while 1:
time.sleep(1)
- def do_intents(self, subcmd, opts, *intents):
- """
- ${cmd_name}: What are your ... intentions?
-
- ${cmd_usage}
- ${cmd_option_list}
- """
- from yt.utilities.cookbook import Intent
- if len(intents) == 0:
- Intent.list_intents()
- else:
- intent = Intent.select_intent(intents[0])
- if intent is None:
- print "Could not find %s" % intents[0]
- return 1
- intent_inst = intent(intents[1:])
- intent_inst.run()
-
def run_main():
for co in ["--parallel", "--paste"]:
if co in sys.argv: del sys.argv[sys.argv.index(co)]
--- a/yt/utilities/cookbook.py Tue Aug 23 08:14:55 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-"""
-A way to find an utilize recipes
-
-Author: Matthew Turk <matthewturk at gmail.com>
-Affiliation: KIPAC/SLAC/Stanford
-Homepage: http://yt-project.org/
-License:
- Copyright (C) 2011 Matthew Turk. All Rights Reserved.
-
- This file is part of yt.
-
- yt is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-# See also:
-# http://en.wikipedia.org/wiki/Me_(mythology)
-
-import os
-import argparse
-import abc
-import glob
-import imp
-import types
-import sys
-import pprint
-
-def _load_intent(intent_path):
- mname = os.path.basename(intent_path[:-3])
- f, filename, desc = imp.find_module(mname,
- [os.path.dirname(intent_path)])
- intent = imp.load_module(mname, f, filename, desc)
- for i in sorted(dir(intent)):
- obj = getattr(intent, i)
- if issubclass(obj, Intent) and \
- isinstance(obj.desc, types.StringTypes):
- return obj
- return None
-
-def _find_cookbook_dir():
- yt_dest = os.environ.get("YT_DEST", None)
- if yt_dest is None:
- print "YT_DEST is not set! Set it and try again."
- return False
- cookbook_dir = os.path.join(yt_dest,
- "src/yt-supplemental/yt-cookbook/intents")
- if not os.path.isdir(cookbook_dir):
- print "Cookbook does not contain 'intents' directory."
- print "Update with 'yt instinfo -u' and try again."
- print "(%s)" % cookbook_dir
- return False
- return cookbook_dir
-
-class Intent(object):
- __metaclass__ = abc.ABCMeta
-
- def __init__(self, args):
- self.args = args
- if "help" in self.args:
- print
- print "The arguments to supply, in order:"
- print
- print self.help
- print
- sys.exit()
-
- @abc.abstractmethod
- def run(self):
- pass
-
- @abc.abstractproperty
- def desc(self): pass
-
- @abc.abstractproperty
- def help(self): pass
-
- @classmethod
- def list_intents(self):
- intents = []
- cookbook_dir = _find_cookbook_dir()
- if cookbook_dir is False: return 1
- for fn in sorted(glob.glob(os.path.join(cookbook_dir, "*"))):
- # We skim them, looking for the 'Intent' subclass
- if any(("(Intent):" in line for line in open(fn))):
- intents.append((os.path.basename(fn)[:-3],
- _load_intent(fn)))
- print
- print "Found these Intents:"
- print "\n".join(("% 15s: %s" % (a, b.desc) for a, b in intents))
- print
-
- @classmethod
- def select_intent(self, intent_name):
- cookbook_dir = _find_cookbook_dir()
- intent = None
- for fn in glob.glob(os.path.join(cookbook_dir, "*")):
- if os.path.basename(fn)[:-3] == intent_name:
- intent = _load_intent(fn)
- return intent
http://bitbucket.org/yt_analysis/yt/changeset/2830c0d96a5f/
changeset: 2830c0d96a5f
branch: yt
user: MatthewTurk
date: 2011-08-23 21:37:37
summary: Adding a hubsubmit command.
affected #: 1 file (7.3 KB)
--- a/yt/utilities/command_line.py Tue Aug 23 13:18:14 2011 -0400
+++ b/yt/utilities/command_line.py Tue Aug 23 15:37:37 2011 -0400
@@ -294,6 +294,35 @@
req.add_header('Authorization', 'Basic %s' % base64.b64encode(upw).strip())
return urllib2.urlopen(req).read()
+def _get_yt_supp():
+ supp_path = os.path.join(os.environ["YT_DEST"], "src",
+ "yt-supplemental")
+ # Now we check that the supplemental repository is checked out.
+ if not os.path.isdir(supp_path):
+ print
+ print "*** The yt-supplemental repository is not checked ***"
+ print "*** out. I can do this for you, but because this ***"
+ print "*** is a delicate act, I require you to respond ***"
+ print "*** to the prompt with the word 'yes'. ***"
+ print
+ response = raw_input("Do you want me to try to check it out? ")
+ if response != "yes":
+ print
+ print "Okay, I understand. You can check it out yourself."
+ print "This command will do it:"
+ print
+ print "$ hg clone http://hg.yt-project.org/yt-supplemental/ ",
+ print "%s" % (supp_path)
+ print
+ sys.exit(1)
+ rv = commands.clone(uu,
+ "http://hg.yt-project.org/yt-supplemental/", supp_path)
+ if rv:
+ print "Something has gone wrong. Quitting."
+ sys.exit(1)
+ # Now we think we have our supplemental repository.
+ return supp_path
+
class YTCommands(cmdln.Cmdln):
name="yt"
@@ -839,32 +868,7 @@
print "*** to point to the installation location! ***"
print
sys.exit(1)
- supp_path = os.path.join(os.environ["YT_DEST"], "src",
- "yt-supplemental")
- # Now we check that the supplemental repository is checked out.
- if not os.path.isdir(supp_path):
- print
- print "*** The yt-supplemental repository is not checked ***"
- print "*** out. I can do this for you, but because this ***"
- print "*** is a delicate act, I require you to respond ***"
- print "*** to the prompt with the word 'yes'. ***"
- print
- response = raw_input("Do you want me to try to check it out? ")
- if response != "yes":
- print
- print "Okay, I understand. You can check it out yourself."
- print "This command will do it:"
- print
- print "$ hg clone http://hg.yt-project.org/yt-supplemental/ ",
- print "%s" % (supp_path)
- print
- sys.exit(1)
- rv = commands.clone(uu,
- "http://hg.yt-project.org/yt-supplemental/", supp_path)
- if rv:
- print "Something has gone wrong. Quitting."
- sys.exit(1)
- # Now we think we have our supplemental repository.
+ supp_path = _get_yt_supp()
print
print "I have found the yt-supplemental repository at %s" % (supp_path)
print
@@ -1253,6 +1257,177 @@
while 1:
time.sleep(1)
+ @cmdln.option("-R", "--repo", action="store", type="string",
+ dest="repo", default=".", help="Repository to upload")
+ def do_hubsubmit(self, subcmd, opts):
+ """
+ Submit a mercurial repository to the yt Hub
+ (http://hub.yt-project.org/), creating a BitBucket repo in the process
+ if necessary.
+
+ ${cmd_usage}
+ ${cmd_option_list}
+ """
+ import imp
+ from mercurial import hg, ui, commands, error, config
+ uri = "http://hub.yt-project.org/3rdparty/API/api.php"
+ supp_path = _get_yt_supp()
+ try:
+ result = imp.find_module("cedit", [supp_path])
+ except ImportError:
+ print "I was unable to find the 'cedit' module in %s" % (supp_path)
+ print "This may be due to a broken checkout."
+ print "Sorry, but I'm going to bail."
+ sys.exit(1)
+ cedit = imp.load_module("cedit", *result)
+ try:
+ result = imp.find_module("hgbb", [supp_path + "/hgbb"])
+ except ImportError:
+ print "I was unable to find the 'hgbb' module in %s" % (supp_path)
+ print "This may be due to a broken checkout."
+ print "Sorry, but I'm going to bail."
+ sys.exit(1)
+ hgbb = imp.load_module("hgbb", *result)
+ uu = ui.ui()
+ try:
+ repo = hg.repository(uu, opts.repo)
+ conf = config.config()
+ if os.path.exists(os.path.join(opts.repo,".hg","hgrc")):
+ conf.read(os.path.join(opts.repo, ".hg", "hgrc"))
+ needs_bb = True
+ if "paths" in conf.sections():
+ default = conf['paths'].get("default", "")
+ if default.startswith("bb://") or "bitbucket.org" in default:
+ needs_bb = False
+ bb_url = default
+ else:
+ for alias, value in conf["paths"].items():
+ if value.startswith("bb://") or "bitbucket.org" in value:
+ needs_bb = False
+ bb_url = value
+ break
+ except error.RepoError:
+ print "Unable to create repo at:"
+ print " %s" % (os.path.abspath(opts.repo))
+ print
+ print "Would you like to initialize one? If this message"
+ print "surprises you, you should perhaps press Ctrl-C to quit."
+ print "Otherwise, type 'yes' at the prompt."
+ print
+ loki = raw_input("Create repo? ")
+ if loki.upper() != "YES":
+ print "Okay, rad -- we'll let you handle it and get back to",
+ print " us."
+ return
+ commands.init(uu, dest=opts.repo)
+ repo = hg.repository(uu, opts.repo)
+ commands.add(uu, repo)
+ commands.commit(uu, repo, message="Initial automated import by yt")
+ needs_bb = True
+ if needs_bb:
+ print
+ print "Your repository is not yet on BitBucket, as near as I can tell."
+ print "Would you like to create a repository there and upload to it?"
+ print "Without this, I don't know what URL to submit!"
+ print
+ print "Type 'yes' to accept."
+ print
+ loki = raw_input("Upload to BitBucket? ")
+ hgrc_path = [cedit.config.defaultpath("user", uu)]
+ hgrc_path = cedit.config.verifypaths(hgrc_path)
+ uu.readconfig(hgrc_path[0])
+ bb_username = uu.config("bb", "username", None)
+ if bb_username is None:
+ print "Can't find your Bitbucket username. Run the command:"
+ print
+ print "$ yt bootstrap_dev"
+ print
+ print "to get set up and ready to go."
+ return 1
+ bb_repo_name = os.path.basename(os.path.abspath(opts.repo))
+ print
+ print "I am now going to create the repository:"
+ print " ", bb_repo_name
+ print "on BitBucket.org and upload this repository to that."
+ print "If that is not okay, please press Ctrl-C to quit."
+ print
+ loki = raw_input("Press Enter to continue.")
+ data = dict(name=bb_repo_name)
+ hgbb._bb_apicall(uu, 'repositories', data)
+ print
+ print "Created repository! Now I will set this as the default path."
+ print
+ bb_url = "https://%s@bitbucket.org/%s/%s" % (
+ bb_username, bb_username, bb_repo_name)
+ cedit.config.addsource(uu, repo, "default", bb_url)
+ commands.push(uu, repo, bb_url)
+ if bb_url.startswith("bb://"):
+ bb_username, bb_repo_name = bb_url.split("/")[-2:]
+ bb_url = "https://%s@bitbucket.org/%s/%s" % (
+ bb_username, bb_username, bb_repo_name)
+ # Now we can submit
+ import xml.etree.ElementTree as etree
+ print
+ print "Okay. Now we're ready to submit to the Hub."
+ print "Remember, you can go to the Hub at any time at"
+ print " http://hub.yt-project.org/"
+ print
+ print "(Especially if you don't have a user yet! We can wait.)"
+ print
+ hub_username = raw_input("What is your Hub username? ")
+ hub_password = getpass.getpass("What is your Hub password? ")
+ data = urllib.urlencode(dict(fn = "list",
+ username=hub_username,
+ password=hub_password))
+ req = urllib2.Request(uri, data)
+ rv = urllib2.urlopen(req).read()
+ try:
+ cats = etree.fromstring(rv)
+ except:
+ print "I think you entered your password wrong. Please check!"
+ return
+
+ categories = {}
+
+ for cat in cats.findall("./cate"):
+ cat_id = int(cat.findall("id")[0].text)
+ cat_name = cat.findall("name")[0].text
+ categories[cat_id] = cat_name
+
+ print
+ for i, n in sorted(categories.items()):
+ print "%i. %s" % (i, n)
+ print
+ cat_id = int(raw_input("Which category number does your script fit into? "))
+ print
+ print "What is the title of your submission? (Usually a repository name) "
+ title = raw_input("Title? ")
+ print
+ print "What tags should be applied to this submission? Separate with commas."
+ print "(e.g., enzo, flash, gadget, ramses, nyx, yt, visualization, analysis,"
+ print " utility, cosmology)"
+ print
+ tags = raw_input("Tags? ")
+ print
+ print "Give us a very brief summary of the project -- enough to get someone"
+ print "interested enough to click the link and see what it's about. This"
+ print "should be a few sentences at most."
+ print
+ summary = raw_input("Summary? ")
+ print
+ print "Okay, we're going to submit! Press enter to submit, Ctrl-C to back out."
+ print
+ loki = raw_input()
+
+ data = urllib.urlencode(dict(fn = "post",
+ username=hub_username, password=hub_password,
+ url = bb_url, category = cat_id, title = title,
+ content = summary, tags = tags))
+ req = urllib2.Request(uri, data)
+ rv = urllib2.urlopen(req).read()
+ print rv
+
+
def run_main():
for co in ["--parallel", "--paste"]:
if co in sys.argv: del sys.argv[sys.argv.index(co)]
http://bitbucket.org/yt_analysis/yt/changeset/83cdb09992a5/
changeset: 83cdb09992a5
branch: yt
user: MatthewTurk
date: 2011-08-23 22:00:06
summary: Few changes to hubsubmit
affected #: 1 file (63 bytes)
--- a/yt/utilities/command_line.py Tue Aug 23 15:37:37 2011 -0400
+++ b/yt/utilities/command_line.py Tue Aug 23 16:00:06 2011 -0400
@@ -1307,7 +1307,7 @@
bb_url = value
break
except error.RepoError:
- print "Unable to create repo at:"
+ print "Unable to find repo at:"
print " %s" % (os.path.abspath(opts.repo))
print
print "Would you like to initialize one? If this message"
@@ -1315,10 +1315,10 @@
print "Otherwise, type 'yes' at the prompt."
print
loki = raw_input("Create repo? ")
- if loki.upper() != "YES":
+ if loki.upper().strip() != "YES":
print "Okay, rad -- we'll let you handle it and get back to",
print " us."
- return
+ return 1
commands.init(uu, dest=opts.repo)
repo = hg.repository(uu, opts.repo)
commands.add(uu, repo)
@@ -1333,6 +1333,7 @@
print "Type 'yes' to accept."
print
loki = raw_input("Upload to BitBucket? ")
+ if loki.upper().strip() != "YES": return 1
hgrc_path = [cedit.config.defaultpath("user", uu)]
hgrc_path = cedit.config.verifypaths(hgrc_path)
uu.readconfig(hgrc_path[0])
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