[yt-svn] commit/yt: MatthewTurk: Adding a hub_register command, which is now the only way to get into the Hub.
Bitbucket
commits-noreply at bitbucket.org
Thu Jul 26 13:27:21 PDT 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/cc0d6f5c8f83/
changeset: cc0d6f5c8f83
branch: yt
user: MatthewTurk
date: 2012-07-26 22:22:12
summary: Adding a hub_register command, which is now the only way to get into the Hub.
affected #: 1 file
diff -r 83670de989ea958a10644e2b9630f14bf420d421 -r cc0d6f5c8f83c2cbd62af00685252c8ae0a2b180 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -753,6 +753,86 @@
else: fn = args.output
hop_list.write_out(fn)
+class YTHubRegisterCmd(YTCommand):
+ name = "hub_register"
+ description = \
+ """
+ Register a user on the Hub: http://hub.yt-project.org/
+ """
+ def __call__(self, args):
+ # We need these pieces of information:
+ # 1. Name
+ # 2. Email
+ # 3. Username
+ # 4. Password (and password2)
+ # 5. (optional) URL
+ # 6. "Secret" key to make it epsilon harder for spammers
+ if ytcfg.get("yt","hub_api_key") != "":
+ print "You seem to already have an API key for the hub in"
+ print "~/.yt/config . Delete this if you want to force a"
+ print "new user registration."
+ print "Awesome! Let's start by registering a new user for you."
+ print "Here's the URL, for reference: http://hub.yt-project.org/ "
+ print
+ print "As always, bail out with Ctrl-C at any time."
+ print
+ print "What username would you like to go by?"
+ print
+ username = raw_input("Username? ")
+ if len(username) == 0: sys.exit(1)
+ print
+ print "To start out, what's your name?"
+ print
+ name = raw_input("Name? ")
+ if len(name) == 0: sys.exit(1)
+ print
+ print "And your email address?"
+ print
+ email = raw_input("Email? ")
+ if len(email) == 0: sys.exit(1)
+ print
+ print "Please choose a password:"
+ print
+ while 1:
+ password1 = getpass.getpass("Password? ")
+ password2 = getpass.getpass("Confirm? ")
+ if len(password1) == 0: continue
+ if password1 == password2: break
+ print "Sorry, they didn't match! Let's try again."
+ print
+ print
+ print "Would you like a URL displayed for your user?"
+ print "Leave blank if no."
+ print
+ url = raw_input("URL? ")
+ print
+ print "Okay, press enter to register. You should receive a welcome"
+ print "message at %s when this is complete." % email
+ print
+ loki = raw_input()
+ data = dict(name = name, email = email, username = username,
+ password = password1, password2 = password2,
+ url = url, zap = "rowsdower")
+ data = urllib.urlencode(data)
+ hub_url = "https://hub.yt-project.org/create_user"
+ req = urllib2.Request(hub_url, data)
+ try:
+ status = urllib2.urlopen(req).read()
+ except urllib2.HTTPError as exc:
+ if exc.code == 400:
+ print "Sorry, the Hub couldn't create your user."
+ print "You can't register duplicate users, which is the most"
+ print "common cause of this error. All values for username,"
+ print "name, and email must be unique in our system."
+ sys.exit(1)
+ except urllib2.URLError as exc:
+ print "Something has gone wrong. Here's the error message."
+ raise exc
+ print
+ print "SUCCESS!"
+ print
+
+
class YTHubSubmitCmd(YTCommand):
name = "hub_submit"
args = (
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