def create(self): if self.ttl: return main.create(self.client, self.key, self.value, ttl=int(self.ttl), filepath=self.filepath) else: return main.create(self.client, self.key, self.value, filepath=self.filepath)
def generate_image(self): if self.textEdit_5.toPlainText() == "": self.label_9.setText( "Укажите используемую модель в \"Путь к файлу модели\"!") elif self.textEdit_6.toPlainText() == "": self.label_9.setText("Укажите название генерируемого файла!") else: try: main.create(self.textEdit_5.toPlainText(), self.textEdit_6.toPlainText()) except: traceback.print_exc() self.label_9.setText("Произошла ошибка")
def create(crd): print(main.create(crd.client, crd.key, crd.value_json_type)+"\n\n") print(main.create(crd.client, crd.key_int, crd.value_json_type)+"\n\n") print(main.create("pinky", "student1", crd.value_dict)+"\n\n") print(main.create(crd.client, crd.key_more_than_32, crd.value_json_type)+"\n\n") print(main.create("87Lane", crd.key_int, crd.value_string)+"\n\n") print(main.create("pinky", "student1", crd.value_dict)+"\n\n") print(main.create(crd.client, "Executive", crd.value_dict, ttl = crd.ttl_value)+"\n\n")
def test_PUT_Method(self): logger.info('Running Test case for PUT Method ...') temp = create(file_name) k = "succesfully modified key value" self.assertEquals(url_methods("/benchmark", "PUT", temp[0]), k)
def test_GET_Method(self): logger.info('Running Test case for GET Method ...') temp = create(file_name) k = [{"1":{"u":"XXXX", "p":"****", "x":"11111"}}] self.assertEquals(url_methods("/benchmark", "GET", temp[0]), k)
def test_create(self): self.assertEqual(main.create("kolkata",25),"Data Inserted successfully") self.assertEqual(main.create("upgb5@85",65695565),"error: Invalid key_name!! key_name must consists of only alphabets and no special characters or numbers") self.assertEqual(main.create("Delhi",100,240),"Data Inserted successfully") self.assertEqual(main.create("kolkata",50),"Error: given key already exists")
#here are the commands to demonstrate how to access and perform operations on a main file #run the MODULE of MAIN FILE and import mainfile as a library import main #importing the main file("code" is the name of the file I have used) as a library main.create("sankar", 25) #to create a key with key_name,value given and with no time-to-live property main.create("src", 70, 20) #to create a key with key_name,value given and with time-to-live property value given(number of seconds) main.read("sankar") #it returns the value of the respective key in Jasonobject format 'key_name:value' main.read("src") #it returns the value of the respective key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR main.read("example__key") #if we try to read an unknown key main.create("sankar", 50) #it returns an ERROR since the key_name already exists in the database #To overcome this error #either use modify operation to change the value of a key #or use delete operation and recreate it main.modify("sankar", 55) #it replaces the initial value of the respective key with new value main.read('sankar')
import main as x import time x.create('dog',8,10,1) x.create('cat',6) x.create('donkey',10) x.read('cat') x.destroy('donkey') time.sleep(10) x.read('dog')
import main import cv2 import helperfuncs ## TESTS FOR IMAGE WARPING ## # scalefactor = 0.25 # testimage = cv2.imread('spherical_testimages2/img_00_0.jpg') # testimage = cv2.resize(testimage, None, fx = scalefactor, fy = scalefactor, interpolation = cv2.INTER_CUBIC) # cv2.imshow('original',testimage) # warped = main.warp(testimage,2000) # cv2.imshow('warped',warped) # while(True): # if cv2.waitKey(1) & 0xFF == ord('q'): # break # cv2.destroyAllWindows() ## TESTS FOR DATA RETRIEVAL ## dataset = main.getImages() # print(dataset) # print(str(dataset.shape)) ## TESTS FOR TRANSLATION COMPUTATION ## # translations = main.computeTranslation(dataset) ## TESTS FOR PANO CREATE FUNCTION ## main.create(dataset, 2000) print("I survived.")
import main as crd crd.create("pawan", 28) crd.create("pp", 70, 3600) crd.read("pawan") crd.read("pp") crd.create("pawan", 50) #it throws an ERROR since the key already exists in the db crd.modify("pawan", 55) crd.delete("pawan") # it can be access through thread thrd1 = Thread(target=(create or read or delete), args=(key, value, t_out)) thrd1.start() thrd1.sleep() thrd2 = Thread(target=(create or read or delete), args=(key, value, t_out)) thrd2.start() thrd2.sleep() thrd3 = Thread(target=(create or read or delete), args=(key, value, t_out)) thrd3.start() thrd3.sleep()
def delete_2(crd): print(main.create("sherlock", crd.key, crd.value_dict)+"\n\n") print(main.delete("sherlock", crd.key)+"\n\n")
def create_2(crd): print(main.create("sherlock", crd.key, crd.value_json_type)+"\n\n")
#This are the inputs to explain, how to perform operations on a mail file... import threading # For multi-threading purpose import main as m # importing the main file as a library that act as a data-store... m.create("execution", 25) m.create("Test", 50) m.create("Demo", 70) m.create("example", 100) # To create a key with name of the key,value given and with no time-to-live property... m.create("source", 70, 3600) #to create a key with name of the key,value given and with time-to-live property value given(in number of seconds) m.read("execution") # it returns the value of desired key in Jasonobject format 'key_name:value'm m.read("Demo") # it returns the value of desired key in Jasonobject format if the TIME-TO-LIVE IS NOT EXPIRED else it returns an ERROR m.create("Test", 150) #it returns an ERROR since the name of the key already exists in the datastore... # If we want to create this key again with some other value then delete this key using # delete operation and then recreate it... m.delete("execution" ) #it deletes the respective key and its value from the datastore... #we can access these using multiple threads like
def test_DELETE_Method(self): logger.info('Running Test case for DELETE Method ...') temp = create(file_name) k = "succesfully deleted key value" self.assertEquals(url_methods("/benchmark", "DELETE", temp[0]), k)
import json print("Options :") print("1 for Creating a key value pair without Time-To-Live,") print("2 for Creating a key value pair with Time-To-Live,") print("3 for Knowing the value of a given key,") print("4 for Deleting a key.") print("5 to save the datastore locally") print("Enter your option") option = int(input()) while(option in [1,2,3,4]): if(option == 1): print("Enter the key:") key = input() print("Enter its value:") value = input() res = app.create(key,value) if(res): print("Key Value pair has been added successfully") elif(option == 2): print("Enter the key:") key = input() print("Enter its value:") value = input() print("Enter the time-to-live") ttl = int(input()) res = app.create(key,value,ttl) if(res): print("Key Value pair has been added successfully") elif(option == 3): print("Enter the key:") key = input()
import main as c c.create("") # import main file # where will u create the file # overwriting the previous data # cant load data from file
from gevent import monkey monkey.patch_all() from main import create app = create()
import main as main_file main_file.create("Avinash", 25) main_file.create("src", 70, 3600) main_file.read("Avinash") main_file.read("src") main_file.create("Avinash", 50) main_file.modify("Avinash", 55) main_file.delete("Avinash") th1 = Thread(target=(create or read or delete), args=(key_name, value, timeout)) th1.start() th1.sleep() th2 = Thread(target=(create or read or delete), args=(key_name, value, timeout)) th2.start() th2.sleep()
import main as data data.create("chetan",30 data.create("shivam",75,3610) data.read("chetan") data.read("shivam") data.create("chetan",55) data.modify("chetan",50) data.delete("chetan") thread1=Thread(target=(create or read or delete),args=(key_name,value,timeout)) thread1.start() thread1.sleep() thread2=Thread(target=(create or read or delete),args=(key_name,value,timeout)) thread2.start() thread2.sleep()
import main as x x.create("amrita", 25) x.create("school", 70, 3600) x.read("amrita") x.read("src") x.create("amrita", 50) x.modify("amrita", 55) x.delete("amrita") t1 = Thread(target=(create or read or delete), args=(key_name, value, timeout)) t1.start() t1.sleep() t2 = Thread(target=(create or read or delete), args=(key_name, value, timeout)) t2.start() t2.sleep()
def _create(): return create(request)