コード例 #1
0
def recordclient(s):
	#gives a file of the name testcase_name which has two lists.The first list is parsed one and the second list is unparsed.
	testcase_name=raw_input("Enter the name in which the test case has to be saved:")
	print "Recording started,you can start giving keystrokes..."
	s.send('continue')
	qwer=0
	testcase=[]	#testcase contains the unparsed lines as srecieved	
	link=[]		#link contains parsed lines of the logfile.
	
	link.append([0,"0000",'0:0:0'])
	

	global l
	l=0
	while qwer==0:
		
		
		stop_button=open("stop_button.txt","r")
		stop_button.seek(0,0)
		u_input=stop_button.readline()                            
		stop_button.close()
		
		#stop_button.py waits for 2 seconds after recieving the stop command to actually send stop to alclient.py
		#this is necessary as the last few current window lines in the log_file after the last keyboard event line is also required.
		line=s.recv(1024)
		testcase.append(str(line))
		if 'Keyboard event received' in line:
			ji=ex(str(line))
			print_ln=str(ji) + ' : ' + str(ex2(str(line)))
			print print_ln	
			link[l].append(ji) #make sure ex is imported
			
			l=l+1
			link.append([l,line,timeparse(line)])	
		elif ('Current window' in line) or ('BRF data' in line):
			link[l].append(line)
		
		if u_input=='stop':
			s.send('stop')			
			qwer+=1
		
		else:
			
			s.send('continue')
	
	link[len(link)-1].append(ex(link[l][1])) #last line parsing
	for i in range(0,len(link)):     #adding time difference
		if i==0 or i==len(link)-1:
			link[i].append(0)
		else :
			link[i].append(timedifference(link[i][2],link[i+1][2]))

	print s.recv(1024)
	print 'The test case recorded is:'
	for i in testcase:
		print i
	test_file=open(testcase_name,'w')
	test_file.write(str(link)+'\n')
	test_file.write(str(testcase))
	test_file.close()
コード例 #2
0
def recordclient0(s):
	testcase_name=raw_input("Enter the name in which the test case has to be saved:")
	print "Recording started,you can start giving keystrokes..."
	s.send('continue')
	qwer=0
	testcase=[]
	l=0
	while qwer==0:
		
		
		stop_button=open("stop_button.txt","r")
		stop_button.seek(0,0)
		u_input=stop_button.readline()                            
		stop_button.close()
		
		#stop_button.py waits for 2 seconds after recieving the stop command to actually send stop to alclient.py

		line=s.recv(1024)
		if 'Keyboard event received' in line:
			print_ln=str(ex(str(line))) + ' : ' + str(ex2(str(line)))
			print print_ln		
		testcase.append(str(line))
		
		if u_input=='stop':
			s.send('stop')			
			qwer+=1
			
		else:
			
			s.send('continue')
	
	print s.recv(1024)
	print 'The test case recorded is:'
	for i in testcase:
		print i
	test_file=open(testcase_name,'w')
	test_file.write(str(testcase))
コード例 #3
0
def recording(self, s, qu, stop_but):
    #elf.listbox1.insert(END,"sonu")

    #gives a file of the name testcase_name which has two lists.The first list is parsed one and the second list is unparsed.
    wut = 'r'
    s.send(wut)  #sending wut
    recv_msg = s.recv(1024)

    testcase_name = self.finalpath1 + "/" + self.Entry.get() + '.txt'

    qu.put("Recording started,you can start giving keystrokes...")
    print "Recording started,you can start giving keystrokes..."

    s.send('continue')
    qwer = 0
    testcase = []  #testcase contains the unparsed lines as srecieved
    blink = [
    ]  #blink contains parsed lines of the logfile. blink=BRF_BASED_link
    '''blink= [ 'o',b0,[l01],[l02],...,b1,[l11],[l12],...,b2,....,bn,[ln1],[ln2],...,bn_1,........bfinal/[lfinal] ]
	
		where bn = string containg nth BRF data line,bn_1 = string containg (n+1)th BRF data line
		and [lnm] = list of the form : [lnm]=[line,time,['k=uinput.KEY_K1','k=uinput.KEY_K2',...],timediff] .
		line is a string containing Keyboard Event, time is a string, third element is a list of the given format,
		timediff is an int and is the time difference (lnm_1 - lnm)
		b0 might come or might not come based on whether during recording first line from logfile is brfdata or keyboard event	

	'''
    blink.append('o')

    while qwer == 0:

        if stop_but.qsize() != 0:

            u_input = 'stop'
        else:
            u_input = 'blah blah'

        #stop_button.py waits for 2 seconds after recieving the stop command to actually send stop to alclient.py
        #this is necessary as the last few BRF data lines in the log_file after the last keyboard event line is also required.
        line = s.recv(1024)
        testcase.append(str(line))

        if ('BRF data' in line):
            blink.append(line)

        elif ('Keyboard event received' in line):
            ji = ex(line)
            blink.append([line, timeparse(line), ji])
            print_ln = str(ji) + ' : ' + str(ex2(line))
            print print_ln
            qu.put(print_ln)

            #self.listbox1.insert(tk.END,print_ln+'\n')
            #self.listbox1.update_idletasks() 	#or else listbox is updated only after whole fxn is called
        if u_input == 'stop':
            s.send('stop')
            f = s.recv(1024)
            print f

            qwer += 1

        else:

            s.send('continue')

    for i in range(len(blink) - 1):  #adding timedifference
        if str(type(blink[i])) == "<type 'list'>":

            k = i + 1

            while k < len(blink) - 1:
                if str(type(blink[k])) == "<type 'list'>":
                    break
                else:
                    k += 1
            print blink[i][1], blink[k][1], blink[k]

            if str(
                    type(blink[k])
            ) == "<type 'list'>":  #to make sure that last line is a keyboard event list
                blink[i].append(timedifference(blink[i][1], blink[k][1]))
    ik = len(blink) - 1
    while ik > 0:
        if str(type(blink[ik])
               ) == "<type 'list'>":  #adding timediff to last element
            blink[ik].append(0)
            break
        else:
            ik -= 1

    #print 'The test case recorded is:'
    self.listbox1.insert(0, 'The test case recorded is:')
    for i in range(len(testcase) - 1):

        print testcase[i]

        print blink[i + 1]

        print ' '

    with open(testcase_name, "w") as f1:

        f1.write(str(blink) + '\n')
        f1.write(str(testcase) + '\n')
コード例 #4
0
def recordclient(s):
	#gives a file of the name testcase_name which has two lists.The first list is parsed one and the second list is unparsed.
	testcase_name=raw_input("Enter the name in which the test case has to be saved:")
	print "Recording started,you can start giving keystrokes..."
	s.send('continue')
	qwer=0
	testcase=[]	#testcase contains the unparsed lines as srecieved	
	blink=[]		#blink contains parsed lines of the logfile. blink=BRF_BASED_link
	'''blink= [ 'o',b0,[l01],[l02],...,b1,[l11],[l12],...,b2,....,bn,[ln1],[ln2],...,bn_1,........bfinal/[lfinal] ]
	
		where bn = string containg nth BRF data line,bn_1 = string containg (n+1)th BRF data line
		and [lnm] = list of the form : [lnm]=[line,time,['k=uinput.KEY_K1','k=uinput.KEY_K2',...],timediff] .
		line is a string containing Keyboard Event, time is a string, third element is a list of the given format,
		timediff is an int and is the time difference (lnm_1 - lnm)
		b0 might come or might not come based on whether during recording first line from logfile is brfdata or keyboard event	

	'''
	blink.append('o')
	
	while qwer==0:
		
		
		stop_button=open("stop_button.txt","r")
		stop_button.seek(0,0)
		u_input=stop_button.readline()                            
		stop_button.close()
		
		#stop_button.py waits for 2 seconds after recieving the stop command to actually send stop to alclient.py
		#this is necessary as the last few BRF data lines in the log_file after the last keyboard event line is also required.
		line=s.recv(1024)
		testcase.append(str(line))
		
		if ('BRF data' in line):
			blink.append(line)	
                        
			
		elif ('Keyboard event received' in line):
			ji=ex(line)
			blink.append([line,timeparse(line),ji])
			print_ln=str(ji) + ' : ' + str(ex2(line))
			print print_ln
		if u_input=='stop':
			s.send('stop')	
			f=s.recv(1024)	
			print f	
			qwer+=1
		
		else:
			
			s.send('continue')

	for i in range(len(blink)-1): #adding timedifference
		if str(type(blink[i]))=="<type 'list'>":
			
			k=i+1
                        
			while k<len(blink)-1:
				if str(type(blink[k]))=="<type 'list'>":
					break
				else:
					k+=1
			print blink[i][1],blink[k][1],blink[k]
			if str(type(blink[k]))=="<type 'list'>":	#to make sure that last line is a keyboard event list
				blink[i].append(timedifference(blink[i][1],blink[k][1]))
	ik=len(blink)-1	
	while ik >0:
		if str(type(blink[ik]))=="<type 'list'>": #adding timediff to last element
			blink[ik].append(0)
			ik-=1
	
	
	print 'The test case recorded is:'
	for i in range(len(testcase)-1):
				
			print testcase[i]
			
			print blink[i+1]
			print ' '
	  		
    	with open(testcase_name+'.txt', "w") as f1:
        		
			f1.write(str(blink)+'\n')
			f1.write(str(testcase)+'\n')