Friday, April 15, 2016

A Web Tool for Booth's multiplication algorithm is used to multiply two numbers located in distributed environment. Use software design client-server architecture and principles for dynamic programming. Implement the design using HTML5/Scala/python/Java/C++/ Ruby on Rails. Perform 1) Risk Analysis. 2) Positive and Negative testing. Use latest open source software modeling, designing and testing tool such as Modelio, Junit, Selinium.

Commands:

sudo easy-install pip
sudo pip install flask
sudo pip install bitstring
sudo pip install selenium

File: Aa.py

from bitstring import BitArray
from flask import Flask
from flask import request
from flask import render_template
app = Flask(__name__)

def booth(m,r,x,y):
totalLength=x+y+1
mA=BitArray(int=m,length=totalLength)
A=mA<<(y+1)
mA1=BitArray(int=-m,length=totalLength)
S=mA1<<(y+1)
P1=BitArray(int=r,length=y)
P1.prepend(BitArray(int=0,length=x))
P=P1 << (1)
print "A : ",A.bin
print "S : ",S.bin

for i in range(1,y+1):
if P[-2:] == '0b01':
P=BitArray(int=P.int+A.int,length=totalLength)
elif P[-2:] == '0b10':
P=BitArray(int=P.int+S.int,length=totalLength)
P=BitArray(int=(P.int >>1),length=P.len)
P = P[:-1]
print "P : ",P.bin
return P.bin,P.int


@app.route('/')
def f():
    return render_template("h.html")

@app.route('/',methods=['POST'])
def g():
    text1 = int(request.form['text1'])
    text2 = int(request.form['text2'])
    n,m=booth(text1,text2,8,8)
    return "Answer in binary: "+str(n)+"<br>Answer: "+str(m)
   
if __name__ == '__main__':
    app.run('localhost',debug=True)

File: first.py

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://localhost:5000")
elem = driver.find_element_by_name("text1")
elem1 = driver.find_element_by_name("text2")
elem.send_keys("4")
elem1.send_keys("3")
elem.send_keys(Keys.RETURN)
assert "12" in driver.page_source
driver.close()

Folder: templates

File: h.html

<!DOCTYPE html>
<html lang="en">
<body>
<h1>Enter data</h1>
<form action="." method="POST">
Enter 1st number:
<input type="text" name="text1">
Enter 2nd number:
<input type="text" name="text2">
<input type="submit" name="my-form" value="Send">
</form>
</body>
</html>



2 comments:

  1. please mail me running program on this email
    amupatil18may@gmail.com

    ReplyDelete

Perform a suitable assignment using Xen Hypervisor or equivalent open source to configure it. Give necessary GUI.

 To install kvm on Fedora:  yum install kvm  yum install virt-manager libvirt libvirt-python python-virtinst  su -c "yum install @v...