コード例 #1
0
def run_worker(queries_tag, results_tag, ids):
    engine = os.getenv('EST_ENGINE')
    url = os.getenv('EST_ENGINE_PARAMS')
    module = importlib.import_module('engines.' + engine)
    api = getattr(module, 'SearchApi')(url)
    db = DbConnection()

    for id in ids:
        row = db.execute(
            "select q from search_queries_volume_%s where id = %d" %
            (queries_tag, id)).first()
        results = api.search(row['q'])
        if type(results) != list:
            results = api.search(row['q'])
            if type(results) != list:
                continue

        db.execute(
            "delete from search_results_items_volume_%s where result_id = %d" %
            (results_tag, id))
        db.execute(
            "update search_results_volume_%s set processed = 0 where id = %d" %
            (results_tag, id))

        order = 1
        for result in results:
            db.execute(
                "insert into search_results_items_volume_%s (result_id, order_id, item_id) values (%d, %d, %d)"
                % (results_tag, id, order, result))
            order += 1
        db.execute(
            "update search_results_volume_%s set processed = 1, count = %d where id = %d"
            % (results_tag, len(results), id))
コード例 #2
0
 def getInventory(self):
     self.inventoryPage = Toplevel()
     self.inventoryPage.geometry("800x800")
     self.label = Label(self.inventoryPage, text="ProductId")
     self.label.grid(row=0, column=0, padx=10)
     self.label1 = Label(self.inventoryPage, text="ProductName")
     self.label1.grid(row=0, column=1, padx=10)
     self.label2 = Label(self.inventoryPage, text="ProductQty")
     self.label2.grid(row=0, column=2, padx=10)
     self.update = Button(self.inventoryPage,
                          text="Update Inventory",
                          cursor="hand2",
                          command=self.updateInventory)
     self.update.grid(row=0, column=3, padx=10, ipadx=20, ipady=5)
     from db import DbConnection
     dbConn = DbConnection()
     from addtocart import getDetails
     productDet = getDetails()
     self.productDetail = productDet.getInventory()
     a = 0
     b = 1
     for i in self.productDetail:
         for j in i:
             self.fname = Label(self.inventoryPage, text=j)
             self.fname.grid(row=b, column=a, sticky=W, padx=10, pady=20)
             # for j in range(0, len(self.productDetail)):
             #     self.fname = Label(self.OrderListPage, text=i)
             #     self.fname.grid(row=b, column=a, sticky=W, padx=10)
             a += 1
         a = 0
         b += 1
コード例 #3
0
 def getOrderList(self):
     self.OrderListPage = Toplevel()
     self.OrderListPage.geometry("800x800")
     from db import DbConnection
     dbConn = DbConnection()
     from addtocart import getDetails
     productDet = getDetails()
     self.productDetail = productDet.getCartList()
     # for key in self.productDetails:
     self.label = Label(self.OrderListPage, text="UserEmail")
     self.label.grid(row=0, column=0, padx=10, sticky=W)
     self.label1 = Label(self.OrderListPage, text="ProductName")
     self.label1.grid(
         row=0,
         column=1,
     )
     self.label2 = Label(self.OrderListPage, text="ProductQty")
     self.label2.grid(row=0, column=2, padx=10, sticky=W)
     a = 0
     b = 1
     for i in self.productDetail:
         for j in i:
             self.fname = Label(self.OrderListPage, text=j)
             self.fname.grid(row=b, column=a, sticky=W, padx=10, pady=20)
             # for j in range(0, len(self.productDetail)):
             #     self.fname = Label(self.OrderListPage, text=i)
             #     self.fname.grid(row=b, column=a, sticky=W, padx=10)
             a += 1
         a = 0
         b += 1
コード例 #4
0
ファイル: addtocart.py プロジェクト: gsauarv/shoppy
 def productDetails(self, email):
     self.a = email
     from db import DbConnection
     dbConn = DbConnection()
     lists = dbConn.getProductDetails(email=self.a)
     dictDetails = dict(lists)
     return dictDetails
コード例 #5
0
    def clicker(self):
        from userLogin import loginUser
        import hashlib
        from db import DbConnection
        dbConn = DbConnection()
        login = loginUser()
        tempEmail = self.email.get()
        tempPassword = self.password.get()
        # tempEmail = "*****@*****.**"
        # tempPassword = "******"
        lists = dbConn.userLogin(email=tempEmail)
        dictDetails = dict(lists)
        userEmail = ""
        userPassword = ""
        for key in dictDetails:
            userEmail = key
            userPassword = dictDetails.get(key)

        if (userEmail == 'admin' and userPassword == tempPassword):
            self.adminPage()
        elif (userEmail == tempEmail and userPassword == (hashlib.md5(
                tempPassword.encode()).hexdigest())):
            # self.userDashboard()
            self.Groceries()
        else:
            print("SO")
def _save_db(address,
             contract_name,
             duration,
             result,
             found=True,
             failed=False):
    with DbConnection() as db:
        db.add_run(address, contract_name, duration,
                   filter_mythril_result(result) if found else '', found,
                   failed)
コード例 #7
0
 def __init__(self, queries_tag, results_a_tag, results_b_tag,
              search_items_csv_path, filename, sample, sample_size, diff):
     self.results_a_tag = results_a_tag
     self.results_b_tag = results_b_tag
     self.queries_tag = queries_tag
     self.search_items_csv_path = search_items_csv_path
     self.volumes = [self.results_a_tag, self.results_b_tag]
     self.db = DbConnection()
     self.load_search_items(self.search_items_csv_path)
     self.sample = self.get_sample_value(sample)
     self.sample_size = sample_size if sample_size else '300'
     self.all_results = not diff
コード例 #8
0
class loginUser:
    from db import DbConnection
    dbConn = DbConnection()
    import hashlib
    tempEmail = ""
    tempPassword = ""
    lists = dbConn.userLogin(email=tempEmail)
    dictDetails = dict(lists)
    userEmail = ""
    userPassword = ""
    for key in dictDetails:
        userEmail = key
        userPassword = dictDetails.get(key)
def get_new_contracts(blocks):
    with DbConnection() as db:
        for index, block_no in blocks.items():
            eth = Etherscan(os.getenv('KEY'))
            logger.info(
                "Searching for contracts starting with block %s, index %s",
                block_no, index)
            prev_call = time.time()

            while db.get_amount(index) < int(
                    os.getenv('CONTRACTS_PER_TIMESTAMP')):
                time.sleep(time.time() -
                           (prev_call - 0.2))  # Max 5 api calls per second
                contracts, block_no = get_contracts_from_block_range(
                    eth, block_no)
                prev_call = time.time()
                logger.debug(
                    "For block_nos %s-%s (timestamp index %s), found %s contracts.",
                    block_no, block_no + 100, index, len(contracts))

                db.add_contracts(contracts, block_no, index)
コード例 #10
0
 def getTopData(self):
     namefirst = self.fnameEntry.get()
     nameLast = self.lnameEntry.get()
     addEmail = self.emailAddEntry.get()
     noPhone = self.phoneNoEntry.get()
     from userLogin import Userregister
     userLog = Userregister()
     a = userLog.generatePassword()
     from db import DbConnection
     db = DbConnection()
     db.registerUser(namefirst, nameLast, addEmail, noPhone, a)
     userLog.mailAddress = addEmail
     userLog.sendUserDetails()
     alertLabel = Label(
         self.top, text="Register SuccessFull Check Your Email To Login")
     alertLabel.grid(row=7, column=1, pady=10)
     backButton = Button(self.top,
                         text="Login",
                         command=self.quit,
                         cursor="hand2",
                         width=15,
                         height=1)
     backButton.grid(row=8, column=1)
コード例 #11
0
def run_controller(search_queries_tag, search_results_tag, sample, size):
    db = DbConnection()

    data = db.execute(
        "select id as ids from search_queries_volume_%s order by %s limit %s" %
        (search_queries_tag, get_sample_value(sample), size))
    ids = [str(item[0]) for item in data.fetchall()] if data else None
    batches = create_batches(ids)

    while len(batches) > 0:
        procs = []

        for allowed in range(1, 8):
            if len(batches) > 0:
                batch = batches.pop()
                p = subprocess.Popen([
                    "python", "worker.py", "--results_tag", search_results_tag,
                    "--queries_tag", search_queries_tag, "--ids"
                ] + batch)
                procs.append(p)

        for p in procs:
            p.wait()
コード例 #12
0
 def getRecords(self):
     self.detailPage = Toplevel()
     self.detailPage.geometry("600x500")
     from db import DbConnection
     dbConn = DbConnection()
     from addtocart import getDetails
     productDet = getDetails()
     self.productDetail = productDet.getDetail()
     # for key in self.productDetails:
     a = 0
     b = 1
     self.label = Label(self.detailPage, text="Fname")
     self.label.grid(row=0, column=0, padx=10)
     self.label1 = Label(self.detailPage, text="Lname")
     self.label1.grid(row=0, column=1, padx=10)
     self.label2 = Label(self.detailPage, text="email")
     self.label2.grid(row=0, column=2, padx=10, sticky=W)
     for i in self.productDetail:
         for j in range(0, len(self.productDetail) + 1):
             self.fname = Label(self.detailPage, text=i[j])
             self.fname.grid(row=b, column=a, sticky=W, padx=10)
             a += 1
         b += 1
         a = 0
コード例 #13
0
ファイル: addtocart.py プロジェクト: gsauarv/shoppy
 def getInventory(self):
     from db import DbConnection
     dbConn = DbConnection()
     inventory = dbConn.getInventory()
     dictDetails = list(inventory)
     return dictDetails
コード例 #14
0
ファイル: addtocart.py プロジェクト: gsauarv/shoppy
 def getCartList(self):
     from db import DbConnection
     dbConn = DbConnection()
     proList = dbConn.getOrderList()
     dictDetails = list(proList)
     return dictDetails
コード例 #15
0
ファイル: addtocart.py プロジェクト: gsauarv/shoppy
 def getDetail(self):
     from db import DbConnection
     dbConn = DbConnection()
     lis = dbConn.getCustDetails()
     dictDetail = list(lis)
     return dictDetail
コード例 #16
0
ファイル: addtocart.py プロジェクト: gsauarv/shoppy
from db import DbConnection
dbConn = DbConnection()


class addtoCart:
    def __init__(self, email, productname, productQty):
        self.productName = productname
        self.productQuantity = productQty
        self.emails = email
        dbConn.addToCart(self.emails, self.productName, self.productQuantity)


class getProduct:
    def productDetails(self, email):
        self.a = email
        from db import DbConnection
        dbConn = DbConnection()
        lists = dbConn.getProductDetails(email=self.a)
        dictDetails = dict(lists)
        return dictDetails


class getDetails:
    def getDetail(self):
        from db import DbConnection
        dbConn = DbConnection()
        lis = dbConn.getCustDetails()
        dictDetail = list(lis)
        return dictDetail

    def getCartList(self):
コード例 #17
0
 def updateBeans(self):
     self.riceQty = self.beansEntry.get()
     self.productId = "2"
     from db import DbConnection
     dbConn = DbConnection()
     dbConn.updateInventory(self.riceQty, self.productId)
コード例 #18
0
 def updateCoffee(self):
     self.riceQty = self.coffeeEntry.get()
     self.productId = "3"
     from db import DbConnection
     dbConn = DbConnection()
     dbConn.updateInventory(self.riceQty, self.productId)
コード例 #19
0
 def updateTea(self):
     self.riceQty = self.teaEntry.get()
     self.productId = "4"
     from db import DbConnection
     dbConn = DbConnection()
     dbConn.updateInventory(self.riceQty, self.productId)
コード例 #20
0
ファイル: main.py プロジェクト: etainativ/ArsPoker
from gameserver import GameServer
from db import DbConnection


if __name__ == "__main__":
    DbConnection()
    GameServer().run()
コード例 #21
0
 def __init__(self, queries_tag, results_tag):
     self.queries_tag = queries_tag
     self.results_tag = results_tag
     self.db = DbConnection()
コード例 #22
0
from db import DbConnection

db = DbConnection('bd_paq.txt')
db.mountA1()
db.mountA2()
db.mountA3()
db.mountA4()
db.mountA5()
db.mountA6()
db.mountA7()
db.mountA8()
コード例 #23
0
 def __init__(self, tag):
     self.tag = tag
     self.db = DbConnection()
コード例 #24
0
def analyze_contracts():
    with DbConnection() as db:
        contracts = db.get_non_analyzed_contracts()

    logger.info('Using contracts: %s', contracts)
    analyze(contracts)