Esempio n. 1
0
def passwordchange(old_pw, new_pw, un):
    header = {}
    header['Authorization']= 'Token '+ token
    response = requests.post(constants.server_url + '/ChangePassword/', {'oldPass': old_pw, 'newPass': new_pw},
                  headers=header)
    if response.content == constants.h_changePassword_success:
        print constants.indent(constants.h_changePassword_success)
    else:
        print constants.indent(constants.h_changePassword_fail)
Esempio n. 2
0
def listfiles(un):
    header = {}
    header['Authorization']= 'Token '+ token
    response = requests.get(constants.server_url + '/ListFiles/' + un, headers=header)
    if response.content == constants.h_listFiles_fail:
        print constants.indent(constants.p_listFiles_fail)
    else:
        json_data = json.loads(response.content)
        if len(json_data) == 0:
            print constants.indent(constants.p_listFiles_nofiles)
        else:
            print constants.indent(constants.p_listFiles_success)
            i = 0
            while i < len(json_data):
                print 'File name: ' + json_data[i][0] +  ' | File size: ' + str(json_data[i][1]) + ' | Last updated: ' + json_data[i][3]
                i += 1
Esempio n. 3
0
            syncOn()
            # mySync = synchronization.Synchronization(t, username, sync)
            # Synchronization needs username. Syncing won't begin until after login/registration.


    try:
        print constants.p_welcome
        input = raw_input('Enter 1 to login or 2 to register: ')

	# Check for exit
        if input == '0':
	    print constants.p_goodbye
            exit()

        while input != '1' and input != '2':
            print constants.indent(constants.p_incorrect_input)
            input = raw_input('Enter 1 to login or 2 to register: ')


        # Login
        if input == '1':
            while True:
                un = raw_input('Username: ')
                pw = getpass.getpass()
                if login(un, pw):
                    print constants.indent(constants.p_login_success)
                    # mySync = synchronization.Synchronization(token, un, sync) # This authenticates checking the server for files
                    # mySync.start()
                    subprocess.call("python synchronization.py " + token + " " + un + " &", shell=True)
                    break
                print constants.indent(constants.p_login_fail)