<commit_before>import json
import urllib2
import requests,sys

choice = raw_input('Email upoload or contributor key [1/2] ')
while choice != '1' and choice != '2':
    print "saldkfjNot a valid input"
    choice = raw_input('Email upoload or contributor key [1/2] ')
if choice == '1':
    project = raw_input('Enter a project id: ')
    data = json.load(urllib2.urlopen('http://rsense-dev.cs.uml.edu/api/v1/projects/'+project))
    title = raw_input('Enter a project title: ')
    email = raw_input('Enter email: ')
    password = raw_input('Enter password: ')
    url = 'http://rsense-dev.cs.uml.edu/api/v1/projects/'+project+'/jsonDataUpload'
    payload = {
        'email': email,
        'password': password,
        'title': title,
        'data':
        {
            ''+ str(data['fields'][0]['id']): [20]
        }
    }
    headers = {'content-type': 'application/json'}
    r = requests.post(url, data=json.dumps(payload), headers=headers)
    if r.status_code == 200:
        print "\nUploaded fine, with a code of 200!"
    if r.status_code == 401:
        print "\nHmm, got an error code of 401."
        print "Try entering  the correct contributor key."
    if r.status_code == 422:
        print "\nGot an error code of 422."
        print "Try entering all the data fields correctly, with the right type for each field."
        print "Examples: A number must be a number, a string must be a series of characters,"
        print "Lat/Long should be GPS coordinates and a timestamp should be correctly formatted."
elif choice == '2':
    project = raw_input('Enter a project id: ')
    contributor_name = raw_input("Enter a contibutor name")
    contributor = raw_input("Enter a contributor key: ")
    title = raw_input("Enter the title of the dataset: ")
    number = raw_input("Enter a number: ")
    data = json.load(urllib2.urlopen('http://rsense-dev.cs.uml.edu/api/v1/projects/'+project))
    print "\nUPLOADING TO iSENSE."
    # POST stuff.
    url = 'http://rsense-dev.cs.uml.edu/api/v1/projects/683/jsonDataUpload'
    payload = {
        'title': title,                     # Note, spent forever trying to figure this out.
        'contribution_key': contributor,    # But it's contribution_key - not contributor_key
        'contributor_name': contributor_name,   
        'data':
        {
            ''+ str(data['fields'][0]['id']): [number]
        }
    }
    # This is needed, otherwise I got code 422s and the data wasn't showing up right in the log.
    headers = {'content-type': 'application/json'}
    r = requests.post(url, data=json.dumps(payload), headers=headers)
    # Detects status codes and tells the user what went right or wrong.
    if r.status_code == 200:
        print "\nUploaded fine, with a code of 200!"
    if r.status_code == 401:
        print "\nHmm, got an error code of 401."
        print "Try entering  the correct contributor key."
    if r.status_code == 422:
        print "\nGot an error code of 422."
        print "Try entering all the data fields correctly, with the right type for each field."
        print "Examples: A number must be a number, a string must be a series of characters,"
        print "Lat/Long should be GPS coordinates and a timestamp should be correctly formatted."<commit_msg>fixed spaces again<commit_after>import json
import urllib2
import requests,sys

choice = raw_input('Email upoload or contributor key [1/2] ')

while choice != '1' and choice != '2':
    print "Not a valid input"
    choice = raw_input('Email upoload or contributor key [1/2] ')

if choice == '1':
    project = raw_input('Enter a project id: ')
    data = json.load(urllib2.urlopen('http://rsense-dev.cs.uml.edu/api/v1/projects/'+project))
    title = raw_input('Enter a project title: ')
    email = raw_input('Enter email: ')
    password = raw_input('Enter password: ')
    url = 'http://rsense-dev.cs.uml.edu/api/v1/projects/'+project+'/jsonDataUpload'

    payload = {
        'email': email,
        'password': password,
        'title': title,
        'data':
        {
            ''+ str(data['fields'][0]['id']): [20]
        }
    }

    headers = {'content-type': 'application/json'}
    r = requests.post(url, data=json.dumps(payload), headers=headers)

    if r.status_code == 200:
        print "\nUploaded fine, with a code of 200!"

    if r.status_code == 401:
        print "\nHmm, got an error code of 401."
        print "Try entering  the correct contributor key."

    if r.status_code == 422:
        print "\nGot an error code of 422."
        print "Try entering all the data fields correctly, with the right type for each field."
        print "Examples: A number must be a number, a string must be a series of characters,"
        print "Lat/Long should be GPS coordinates and a timestamp should be correctly formatted."

elif choice == '2':
    project = raw_input('Enter a project id: ')
    contributor_name = raw_input("Enter a contibutor name")
    contributor = raw_input("Enter a contributor key: ")
    title = raw_input("Enter the title of the dataset: ")
    number = raw_input("Enter a number: ")
    data = json.load(urllib2.urlopen('http://rsense-dev.cs.uml.edu/api/v1/projects/'+project))

    print "\nUPLOADING TO iSENSE."

    # POST stuff.
    url = 'http://rsense-dev.cs.uml.edu/api/v1/projects/683/jsonDataUpload'
    payload = {
        'title': title,                     # Note, spent forever trying to figure this out.
        'contribution_key': contributor,    # But it's contribution_key - not contributor_key
        'contributor_name': contributor_name,   
        'data':
        {
            ''+ str(data['fields'][0]['id']): [number]
        }
    }

    # This is needed, otherwise I got code 422s and the data wasn't showing up right in the log.
    headers = {'content-type': 'application/json'}
    r = requests.post(url, data=json.dumps(payload), headers=headers)

    # Detects status codes and tells the user what went right or wrong.
    if r.status_code == 200:
        print "\nUploaded fine, with a code of 200!"

    if r.status_code == 401:
        print "\nHmm, got an error code of 401."
        print "Try entering  the correct contributor key."

    if r.status_code == 422:
        print "\nGot an error code of 422."
        print "Try entering all the data fields correctly, with the right type for each field."
        print "Examples: A number must be a number, a string must be a series of characters,"
        print "Lat/Long should be GPS coordinates and a timestamp should be correctly formatted."
{'fraction_non_alphanumeric': 0.11893870082342177, 'fraction_numerical': 0.018603232692894173, 'mean_word_length': 2.724588302101079, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7445378', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1922, 'n_words': 673}