Esempio n. 1
0
def bb_apicall(endpoint, data, use_pass = True):
    uri = 'https://api.bitbucket.org/1.0/%s/' % endpoint
    # since bitbucket doesn't return the required WWW-Authenticate header when
    # making a request without Authorization, we cannot use the standard urllib2
    # auth handlers; we have to add the requisite header from the start
    if data is not None:
        data = urllib.parse.urlencode(data)
    req = urllib.request.Request(uri, data)
    if use_pass:
        username = input("Bitbucket Username? ")
        password = getpass.getpass()
        upw = '%s:%s' % (username, password)
        req.add_header('Authorization', 'Basic %s' % base64.b64encode(upw).strip())
    return urllib.request.urlopen(req).read()
Esempio n. 2
0
def _update_yt_stack(path):
    "Rerun the install script to updated all dependencies."

    if "YT_DEST" not in os.environ:
        print()
        print("This yt installation does not appear to be managed by the")
        print("source-based install script, but 'update --all' was specified.")
        print("You will need to update your dependencies manually.")
        return

    install_script = os.path.join(path, "doc/install_script.sh")
    if not os.path.exists(install_script):
        print()
        print("Install script not found!")
        print("The install script should be here: %s," % install_script)
        print("but it was not.")
        return

    print()
    print("We will now attempt to update the yt stack located at:")
    print("    %s." % os.environ["YT_DEST"])
    print()
    print("[hit enter to continue or Ctrl-C to stop]")
    try:
        input()
    except:
        sys.exit(0)
    os.environ["REINST_YT"] = "1"
    ret = subprocess.call(["bash", install_script])
    print()
    if ret:
        print("The install script seems to have failed.")
        print("Check the output above.")
    else:
        print("The yt stack has been updated successfully.")
        print("Now get back to work!")
Esempio n. 3
0
    print("")
    repo_path = clone_new_repo()
    try:
        last_major_release = get_first_commit_after_last_major_release(
            repo_path)
        last_dev = get_branch_tip(repo_path, 'yt', 'experimental')
        last_stable = get_branch_tip(repo_path, 'stable')
        lineage = get_lineage_between_release_and_tip(repo_path,
                                                      last_major_release,
                                                      last_dev)
        prs = get_pull_requests_since_last_release(repo_path)
        commits_to_prs = create_commits_to_prs_mapping(lineage, prs)
        inv_map = invert_commits_to_prs_mapping(commits_to_prs)
        # for now, ignore commits that aren't part of a pull request since
        # the last bugfix release. These are mostly commits in pull requests
        # from before the last bugfix release but might include commits that
        # were pushed directly to the repo.
        del inv_map[None]

        inv_map = screen_already_backported(repo_path, inv_map)
        print("In another terminal window, navigate to the following path:")
        print("%s" % repo_path)
        input("Press any key to continue")
        backport_pr_commits(repo_path, inv_map, last_stable, prs)
        input(
            "Now you need to push your backported changes. The temporary\n"
            "repository currently being used will be deleted as soon as you\n"
            "press any key.")
    finally:
        shutil.rmtree(repo_path)
Esempio n. 4
0
 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 = input("Username? ")
     if len(username) == 0: sys.exit(1)
     print()
     print("To start out, what's your name?")
     print()
     name = input("Name? ")
     if len(name) == 0: sys.exit(1)
     print()
     print("And your email address?")
     print()
     email = input("Email? ")
     if len(email) == 0: sys.exit(1)
     print()
     print("Please choose a password:"******"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 = input("URL? ")
     print()
     print("Okay, press enter to register.  You should receive a welcome")
     print("message at %s when this is complete." % email)
     print()
     input()
     data = dict(name=name,
                 email=email,
                 username=username,
                 password=password1,
                 password2=password2,
                 url=url,
                 zap="rowsdower")
     data = urllib.parse.urlencode(data)
     hub_url = "https://hub.yt-project.org/create_user"
     req = urllib.request.Request(hub_url, data)
     try:
         urllib.request.urlopen(req).read()
     except urllib.error.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 urllib.URLError as exc:
         print("Something has gone wrong.  Here's the error message.")
         raise exc
     print()
     print("SUCCESS!")
     print()
Esempio n. 5
0
 def __call__(self, args):
     print(
         "===============================================================")
     print()
     print("Hi there!  Welcome to the yt bugreport taker.")
     print()
     print(
         "===============================================================")
     print(
         "At any time in advance of the upload of the bug, you should feel free"
     )
     print(
         "to ctrl-C out and submit the bug report manually by going here:")
     print("   http://bitbucket.org/yt_analysis/yt/issues/new")
     print()
     print("Also, in order to submit a bug through this interface, you")
     print("need a Bitbucket account. If you don't have one, exit this ")
     print(
         "bugreport now and run the 'yt bootstrap_dev' command to create one."
     )
     print()
     print("Have you checked the existing bug reports to make")
     print("sure your bug has not already been recorded by someone else?")
     print(
         "   http://bitbucket.org/yt_analysis/yt/issues?status=new&status=open"
     )
     print()
     print(
         "Finally, are you sure that your bug is, in fact, a bug? It might")
     print("simply be a misunderstanding that could be cleared up by")
     print(
         "visiting the yt irc channel or getting advice on the email list:")
     print("   http://yt-project.org/irc.html")
     print(
         "   http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org"
     )
     print()
     summary = input(
         "Press <enter> if you remain firm in your conviction to continue.")
     print()
     print()
     print("Okay, sorry about that. How about a nice, pithy ( < 12 words )")
     print(
         "summary of the bug?  (e.g. 'Particle overlay problem with parallel "
     )
     print("projections')")
     print()
     try:
         current_version = get_yt_version()
     except:
         current_version = "Unavailable"
     summary = input("Summary? ")
     bugtype = "bug"
     data = dict(title=summary, type=bugtype)
     print()
     print("Okay, now let's get a bit more information.")
     print()
     print("Remember that if you want to submit a traceback, you can run")
     print("any script with --paste or --detailed-paste to submit it to")
     print("the pastebin and then include the link in this bugreport.")
     if "EDITOR" in os.environ:
         print()
         print("Press enter to spawn your editor, %s" %
               os.environ["EDITOR"])
         input()
         tf = tempfile.NamedTemporaryFile(delete=False)
         fn = tf.name
         tf.close()
         subprocess.call("$EDITOR %s" % fn, shell=True)
         content = open(fn).read()
         try:
             os.unlink(fn)
         except:
             pass
     else:
         print()
         print("Couldn't find an $EDITOR variable.  So, let's just take")
         print("take input here.  Type up your summary until you're ready")
         print("to be done, and to signal you're done, type --- by itself")
         print("on a line to signal your completion.")
         print()
         print("(okay, type now)")
         print()
         lines = []
         while 1:
             line = input()
             if line.strip() == "---": break
             lines.append(line)
         content = "\n".join(lines)
     content = "Reporting Version: %s\n\n%s" % (current_version, content)
     endpoint = "repositories/yt_analysis/yt/issues"
     data['content'] = content
     print()
     print(
         "===============================================================")
     print()
     print("Okay, we're going to submit with this:")
     print()
     print("Summary: %s" % (data['title']))
     print()
     print("---")
     print(content)
     print("---")
     print()
     print(
         "===============================================================")
     print()
     print("Is that okay?  If not, hit ctrl-c.  Otherwise, enter means")
     print("'submit'.  Next we'll ask for your Bitbucket Username.")
     print("If you don't have one, run the 'yt bootstrap_dev' command.")
     print()
     input()
     retval = bb_apicall(endpoint, data, use_pass=True)
     import json
     retval = json.loads(retval)
     url = "http://bitbucket.org/yt_analysis/yt/issue/%s" % retval[
         'local_id']
     print()
     print(
         "===============================================================")
     print()
     print(
         "Thanks for your bug report!  Together we'll make yt totally bug free!"
     )
     print("You can view bug report here:")
     print("   %s" % url)
     print()
     print("Keep in touch!")
     print()
Esempio n. 6
0
def backport_prs(repo_path, prs):
    for pr in prs:
        print('')
        print('PR %s' % pr['number'])
        print(pr['title'])
        print(pr['author']['login'])
        print(pr['body'])
        print(pr['url'])
        print("%s.diff" % pr['url'])
        input("Press any key to continue")


if __name__ == "__main__":
    key = input("Please enter your github OAuth API key\n"
                "See the github help for instructions on how to "
                "generate a personal access token.\n>>> ")
    print("")
    print("Gathering PR information, this may take a minute.")
    print("Don't worry, yt loves you.")
    print("")
    repo_path = clone_new_repo()
    try:
        date = get_date_of_last_tag(repo_path)
        prs = get_prs_since_last_release(date, key)
        print("In another terminal window, navigate to the following path:")
        print("%s" % repo_path)
        input("Press any key to continue")
        backport_prs(repo_path, prs)
        input(
            "Now you need to push your backported changes. The temporary\n"