コード例 #1
0
def importProductsFromBD():
    dbUtils = DbUtils()
    productsBD = dbUtils.selectProducts()
    #while(product):
    for product in productsBD:
        products.append(Product(product[0],product[1],product[2],product[3],product[4]))
        print(product)
    print(products)
    return 0
コード例 #2
0
def addhistorical():
    if not request.json:
        abort(400)

    distanceData = json.dumps(request.json)
    distanceObject = json.loads(distanceData, object_hook=JSONObject)
    dbUtils = DbUtils()

    dbUtils.addDistance(distanceObject.length, distanceObject.width)
コード例 #3
0
def getbounds():
    # Init my variables that i am going to be using
    dbUtils = DbUtils()
    top = ""
    right = ""
    bottom = ""
    left = ""
    edges = []

    # Get my bounds from the server
    boundData = dbUtils.getBounds()

    # parse my boundData and set each row to a longitute and latitude in a list of dictionaries.
    for r in boundData:
        # get longitude out
        tempStrings = str(r).split()
        tempStrings[0] = tempStrings[0][8:]
        # get latitude out
        index = tempStrings[1].find(")")
        tempStrings[1] = tempStrings[1][0:index]
        # add that to a dictionary
        a = {"lon": tempStrings[0], "lat": tempStrings[1]}
        # add the dictionary to a list
        edges.append(a)

    # Check the latitudes for a top and bottom
    if float(edges[0]["lat"]) > float(edges[1]["lat"]):
        top = edges[0]["lat"]
        bottom = edges[1]["lat"]
    else:
        top = edges[1]["lat"]
        bottom = edges[0]["lat"]

    # Check longitude for a left and right
    if float(edges[0]["lon"]) < float(edges[1]["lon"]):
        left = edges[0]["lon"]
        right = edges[1]["lon"]
    else:
        right = edges[0]["lon"]
        left = edges[1]["lon"]

    # Create my json dictionary
    bounds = {"top": top, "bottom": bottom, "left": left, "right": right}

    # return the json to the user
    return jsonify(bounds)
コード例 #4
0
def getimg(img_name):
    from DbUtils import DbUtils

    img = []
    dbUtils = DbUtils()
    imgData = dbUtils.getPNG(img_name)
    # Parse the info and return it
    for r in imgData:
        a = {
            "img_name": r[0],
            "img": r[1],
            "img_size": r[2],
            "bot_left_corner": r[3],
            "rotation": r[4],
        }
        img.append(a)
    return jsonify(img)
コード例 #5
0
def addimg():
    if not request.json:
        abort(400)

    imgData = json.dumps(request.json)
    imgObject = json.loads(imgData, object_hook=JSONObject)
    dbUtils = DbUtils()

    dbUtils.addNewPNG(
        imgObject.img_name,
        list(imgObject.img),
        imgObject.img_size,
        imgObject.corner,
        imgObject.img_rotation,
    )

    return jsonify({"Result": "Inserted"}), 201
コード例 #6
0
def logar():
    print(request.form)
    print(request.form['password'])
    print(request.form['email'])
    password = request.form['password']
    email = request.form['email']
    dbUtils = DbUtils()
    res = dbUtils.selectUsers(email,password)
    if(res):
        print(res)
        userReturn = None
        for user in res:
            userReturn = user
            print(user)
        if(userReturn == None):
            return "<h1>Usuário ou senha incorretos</h1>"
    else:
        return "<h1>Erro ao logar</h1>"
    return "<h1> Bem vindo " + userReturn[1] + "</h1>"
コード例 #7
0
def exportProductstoBD():
    products.append(Product(0,"IphoneX","5999.99","IphoneX text","iphoneX.jpg"))
    products.append(Product(1,"Galaxy S10+","3999.99","Galaxy S10+ text","Galaxy_S10+.jpg"))
    products.append(Product(2,"Huawei P30 Pro","3500.00","Huawei P30 Pro Text","Huawei_P30.jpg"))
    products.append(Product(3,"Moto G8 Plus","1999.99","Moto G8 text","MotoG8.jpg"))
    products.append(Product(4,"Xiaomi Mi9", "2299.99", "Xiaomi Mi9", "XiaomiMi9.jpg"))
    products.append(Product(5,"Alcatel Pixi 4","186.90","Alcatel Pixi 4 text","AlcatelPixi4.jpg"))
    dbUtils = DbUtils()
    dbUtils.createTableProducts()  #Table products
    for product in products:
        dbUtils.addNewProduct(product.name, product.price, product.text, product.urlImage)
コード例 #8
0
def cadastrar():
    #global users
    print(request.form)
    #user_data = request.get_json(force=True)
    #print(user_data)
    print(request.form['name'])
    print(request.form['password'])
    print(request.form['email'])
    newUser = User(request.form['name'],request.form['password'],request.form['email'])
    users.append(newUser)
    dbUtils = DbUtils()
    dbUtils.createTableUsers()
    #for user in users:
    dbUtils.addNewUser(newUser.name, newUser.password, newUser.email)
    return "<h1>CADASTRADO</h1>"
コード例 #9
0
from DbUtils import DbUtils
import re
import sys
db = DbUtils()

tweets = db.fetchall(sys.argv[3], ("text", ), sort="id DESC")

tweets = [re.sub(r'http(s?).* ?', '', x[0]).strip().lower() for x in tweets]
tweets = list(set(tweets))

with open("resources/stopwords.txt", "rb") as f:
    stopwords = f.read().splitlines()

with open("resources/" + sys.argv[2], "w") as f:
    f.write("i,j,x\r\n")
    for i in range(len(tweets)):
        for j in range(len(words)):
            cont = tweets[i].count(words[j])
            if cont > 0:
                f.write(
                    str(i + 1) + "," + str(j + 1) + "," + str(cont) + "\r\n")
コード例 #10
0
ファイル: app.py プロジェクト: manemarron/Numerico-Twitter
parser.add_argument('-result-type', dest="result_type", default="mixed", help="Result type")
parser.add_argument('-max-id', dest="max_id", default=None, help="Maximum Id from which to start searching")
parser.add_argument('-until', dest="until", default=None, help="Last date")
parser.add_argument('-lang', dest="lang", default=None, help="Language")
parser.add_argument('-table', dest="table", default="tweets", help="DB Table")
args = parser.parse_args()
q = args.q
n = args.n
result_type = args.result_type
max_id = args.max_id
until = args.until
lang = args.lang
table = args.table

twitter = TwitterUtils()
db = DbUtils()

next_results = {"q": q, "count": 100}
if result_type is not None:
    next_results["result_type"] = result_type
if max_id is not None:
    next_results["max_id"] = max_id
if until is not None:
    next_results["until"] = until
if lang is not None:
    next_results["lang"] = lang
db.cursor = db.conn.cursor()
try:
    for i in range(0, n):
        print("Request: %d" % (i+1,))
        result = twitter.search(**next_results)
コード例 #11
0
from DbUtils import DbUtils
import re
import sys
db = DbUtils()

tweets = db.fetchall(sys.argv[3], ("text",), sort="id DESC")

tweets = [re.sub(r'http(s?).* ?', '', x[0]).strip().lower() for x in tweets]
tweets = list(set(tweets))



with open("resources/stopwords.txt","rb") as f:
    stopwords = f.read().splitlines()

with open("resources/" + sys.argv[2], "w") as f:
    f.write("i,j,x\r\n")
    for i in range(len(tweets)):
        for j in range(len(words)):
            cont = tweets[i].count(words[j])
            if cont > 0:
                f.write(str(i+1) + "," + str(j+1) + "," + str(cont) + "\r\n")
コード例 #12
0
ファイル: app.py プロジェクト: manemarron/Numerico-Twitter
                    default=None,
                    help="Maximum Id from which to start searching")
parser.add_argument('-until', dest="until", default=None, help="Last date")
parser.add_argument('-lang', dest="lang", default=None, help="Language")
parser.add_argument('-table', dest="table", default="tweets", help="DB Table")
args = parser.parse_args()
q = args.q
n = args.n
result_type = args.result_type
max_id = args.max_id
until = args.until
lang = args.lang
table = args.table

twitter = TwitterUtils()
db = DbUtils()

next_results = {"q": q, "count": 100}
if result_type is not None:
    next_results["result_type"] = result_type
if max_id is not None:
    next_results["max_id"] = max_id
if until is not None:
    next_results["until"] = until
if lang is not None:
    next_results["lang"] = lang
db.cursor = db.conn.cursor()
try:
    for i in range(0, n):
        print("Request: %d" % (i + 1, ))
        result = twitter.search(**next_results)