def test_GEToneTextSecureBox(): from create import CREATE from put import PUT from get import GET print 'testing GET from secure box with messages' CREATE('test_GEToneTextSecureBox', 0) PUT('test_GEToneTextSecureBox', 'message test_GEToneTextSecureBox') assert GET('test_GEToneTextSecureBox', 0) == 'OK' assert GET('test_GEToneTextSecureBox', 0) == ('ERROR', 'Box is empty')
def parseArgs(): if len(sys.argv) < 2: usage() if sys.argv[1] == 'PUT' and len(sys.argv) == 5: print(PUT(sys.argv[2], sys.argv[3], sys.argv[4])) elif sys.argv[1] == 'MKDIR' and len(sys.argv) == 4: print(MKDIR(sys.argv[2], sys.argv[3])) elif sys.argv[1] == 'LS' and len(sys.argv) == 4: LS(sys.argv[2], sys.argv[3]) elif sys.argv[1] == 'LS' and len(sys.argv) == 5: LS(sys.argv[2], sys.argv[3], sys.argv[4]) elif sys.argv[1] == 'GET' and len(sys.argv) == 5: GET(sys.argv[2], sys.argv[3], sys.argv[4]) elif sys.argv[1] == 'GET' and len(sys.argv) == 6: GET(sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]) elif sys.argv[1] == 'CP' and len(sys.argv) == 5: print(CP(sys.argv[2], sys.argv[3], sys.argv[4])) elif sys.argv[1] == 'RM' and len(sys.argv) == 4: print(RM(sys.argv[2], sys.argv[3])) elif sys.argv[1] == 'MV' and len(sys.argv) == 5: print(MV(sys.argv[2], sys.argv[3], sys.argv[4])) else: usage()
consumer_key = '' consumer_secret = '' auth = tweepy.OAuthHandler(consumer_key, consumer_secret) # This will create a url in which you will authorize your app for the account you're signed in. # You should click 'authorize app' in order to get the pin. try: redirect_url = auth.get_authorization_url() except tweepy.TweepError: print("Error! Failed to get the request token.") # Store request token in session. session = {'request_token': auth.request_token} # Enter the pin here as input. This will be used as verifier in order to access token. verifier = GET.get('oauth_verifier') print(redirect_url) verifier = input('Verifier: ') # OAuth process with keys and tokens auth = tweepy.OAuthHandler(consumer_key, consumer_secret) token = session.get('request_token') auth.request_token = token # Get access token. try: auth.get_access_token(verifier) except: print('Error! Failed to get access token.') # These are the keys for the account.
def test_GETsecureEmptyBox(): from create import CREATE from get import GET print 'testing GET from a secure empty box with wrong argument' CREATE('test_GETsecureEmptyBox', 1) assert GET('test_GETsecureEmptyBox', 1) == ('ERROR', 'Box is empty')
def test_GETwrongSecure(): from create import CREATE from get import GET print 'testing GET from a secure box with wrong argument' CREATE('test_GETwrongSecureBox', 1) assert GET('testGETwrongSecureBox', 2) == ('ERROR', 'Invalid user input')
def test_GETemptyBox(): from create import CREATE from get import GET print 'testing GET from empty box' CREATE('test_GETemptybox', 0) assert GET('test_GETemptybox', 0) == ('ERROR', 'Box is empty')
def test_GETnoSuchBox(): from get import GET print 'testing GET from unexisting box' assert GET('testGETnoSuchBox', 0) == ('ERROR', 'Box not found')
MKDIR(fs, curr_dirpath) end = datetime.now() time_res = formatTimeDelta(start, end) mf.write("{}, {}\n".format(k, time_res)) if not k % test_incs: # time put start = datetime.now() put_loc = '{}/{}'.format(curr_dirpath, file_to_put) PUT(fs, file_to_put, put_loc) end = datetime.now() time_res = formatTimeDelta(start, end) pf.write("{}, {}\n".format(k, time_res)) # untimed GET to load into cache GET(fs, put_loc, get_path) # time get start = datetime.now() GET(fs, put_loc, get_path) end = datetime.now() time_res = formatTimeDelta(start, end) gf.write("{}, {}\n".format(k, time_res)) print(k) curr_dirpath += dirname mf.close() pf.close() gf.close()