Пример #1
0
def worker_main(worker_queue, completed_queue, log_queue, config):
    # setup logging
    qh = logging.handlers.QueueHandler(log_queue)
    root = logging.getLogger()
    root.setLevel(logging.DEBUG)
    root.addHandler(qh)

    c = config
    while True:
        item = worker_queue.get(True)

        # do work
        auction = a.Auction(item, c["chrome_driver_path"])
        auction.watch()

        # store to sources based on config settings
        if c["csv"]["active"]:
            auction.store_bid_history_to_csv(c["csv"]["path"])
        if c["s3"]["active"]:
            auction.store_to_s3(config["s3"]["bucket"])
        # if c["database"]["active"]:
        #     auction.store(c["database"]["host"], c["database"]["name"],
        #                   c["database"]["user"], c["database"]["password"])

        completed_queue.put(item)
        time.sleep(1)
Пример #2
0
def main():
    creatives = buildRandom(100)
    printList(creatives)
    print "---------------------------------------------------------------"
    a = auction.Auction("shit")
    res = a.perform(creatives, 6, "TEST")
    printList(res)
Пример #3
0
def doEverything(samdb, dbnam, title, subtitle, date):
    print 'ENTERED DOEVERYTHING'
    try:
        ''' Now create the database. '''
        samdb.createDatabase(dbnam)
        print 'Database ' + dbnam + ' created.'
        dd = donors.Donors()
        dd.createDonorsTable(samdb)
        print "Donors table created."
        db = buyers.Buyers()
        db.createBuyersTable(samdb)
        print "Buyers table created."
        di = items.Items()
        di.createItemsTable(samdb)
        print "Items table created."
        ''' The Auction table is special because the data in it are
            entered by the auction manager, rather than by other users
            of the system.  Data for the table will come eventually
            from a GUI.  For the moment, default data are entered
            into the table.  '''
        da = auction.Auction()
        da.createAuctionTable(samdb)
        print "Auction table created."
        print 'ENTERING AUCTION DATA'
        da.addAuctionTitle(samdb, title)
        da.addAuctionSubtitle(samdb, subtitle)
        da.addAuctionDate(samdb, date)
        print 'ADDED AUCTION DATA'
    except MySQLdb.Error, e:
        print "createAuction.doEverything: Error %d: %s" % \
                (e.args[0], e.args[1])
        sys.exit(1)
Пример #4
0
 def test_distribution100(self):
     print "TEST test_distribution100 init___________________________"
     creatives = helper.buildRandom(300)
     print "test 3 creatives list!"
     #helper.printList(creatives)
     a = auction.Auction()
     dict = {}
     winners = set()
     for i in range(0, 10):
         #print "iteration: " + str(i)
         res = a.perform(creatives, 6, "AS")
         print "res #" + str(i)
         print res
         print "--------------------------------------------------"
         for c in res:
             #dict [str(c)] += 1
             if str(c.ID) + "adv" + str(c.advertizer_id) in winners:
                 dict[str(c.ID) + "adv" + str(c.advertizer_id)] += 1
             else:
                 winners.add(str(c.ID) + "adv" + str(c.advertizer_id))
                 dict[str(c.ID) + "adv" + str(c.advertizer_id)] = 0
         #print dict
     print "__________________________________DICTS_____________________________________"
     print dict
     print "TEST test_distribution100 end___________________________"
Пример #5
0
 def test_simple(self):
     print "TEST test_simple init___________________________"
     global cList
     #helper.printList(cList)
     cr = []
     cr.append(creative.Creative(1, "adv1", 100))
     cr.append(creative.Creative(2, "adv1", 200, "country"))
     cr.append(creative.Creative(3, "adv2", 120))
     cr.append(creative.Creative(4, "adv2", 100, "country2"))
     cr.append(creative.Creative(5, "adv2", 100, "country3"))
     cr.append(creative.Creative(6, "adv3", 50, "country"))
     cr.append(creative.Creative(7, "adv3", 99))
     cr.append(creative.Creative(8, "adv3", 98))
     cr.append(creative.Creative(9, "adv4", 80))
     cr.append(creative.Creative(10, "adv4", 90))
     a = auction.Auction()
     res = a.perform(cr, 5, "country")
     helper.printList(res)
     correct_ids = [2, 3, 7, 10]
     self.assertTrue(len(res) == 4)
     x = 0
     for i in correct_ids:
         self.assertEqual(res[x].ID, i)
         x += 1
     print "TEST test_simple end___________________________"
Пример #6
0
 def __init__(self, samdb):
     self.samdb = samdb
     self.auction = auction.Auction()
     self.buyers = buyers.Buyers()
     self.donors = donors.Donors()
     self.items = items.Items()
     self.fname = self.rand_fname('xxx', 8)
     lines = []
Пример #7
0
 def test_get_bid_case_1(self, input):
     game_instance = monopoly.Monopoly()
     game_instance.add_player('David')
     game_instance.generate_in_game_players()
     item = cards.HoldableCard(name='Go to BEENUS', action=None, parent_deck='Beenus')
     auc_instance = auction.Auction(game=game_instance, seller=game_instance.players[0], item=item)
     auc_instance.current_bidder = game_instance.players[0]
     auc_instance.highest_bid = 5
     self.assertEqual(10, auc_instance.get_bid())
Пример #8
0
def testConnectAndPopulate():

    profile = profileservices.getProfile()
    samdb = dbservices.Samdb(profile['dbName'], profile['hostName'],
                             int(profile['portNumber']), profile['userName'],
                             profile['password'])
    samdb.useDatabase(profile['dbName'])
    ## Create objects for Auction, Donors, Buyers, Items, and Purchases
    da = auction.Auction()
    dd = donors.Donors()
    db = buyers.Buyers()
    di = items.Items()
    dp = purchases.Purchases()
    populate(samdb, da, dd, db, di, dp)
 def initialize_auction(self, leveled):
     params = {
         "n_buyers": 3,
         "n_sellers": 2,
         "n_rounds": 1,
         "max_price": 10,
         "penalty": 0.1,
         "leveled": leveled,
         "display": False
     }
     auc = auction.Auction(**params)
     auc.bidding_factors = np.array([[2.0, 3.0], [4.0, 5.0], [6.0, 7.0]])
     auc.decrease_factors = np.array([[0.1, 0.2], [0.3, 0.4], [0.5, 0.6]])
     auc.increase_factors = np.array([[1.1, 1.2], [1.2, 1.4], [1.5, 1.6]])
     return (auc)
Пример #10
0
    def round(self):
        """Process a single round in the game and return a win, if any"""
        self.add_stateviz()
        self.determine_player_order()

        turn_auction = auction.Auction(self.players, self.power_plant_market)
        if not turn_auction.auction_all():
            self.power_plant_market.discard_lowest()
        self.detect_step_three()
        self.buy_resources()
        self.building()
        self.power_plant_market.discard_low_power_plants(self.players)
        self.detect_step_two()
        self.detect_step_three()
        winner = self.detect_game_end()
        if winner:
            self.add_stateviz()
            return winner
        self.bureaucracy()
        self.detect_step_three()
    "n_sellers": 2,
    "n_rounds": 100,
    "max_price": 10,
    "penalty": 0.1,
    "bidding_factors": None,
    "increase_factors": None,
    "decrease_factors": None,
    "leveled": False,
    "display": False,
    "experiment_name": "experiment_6.csv"
}

if __name__ == "__main__":
    np.random.seed(42)

    auc = auction.Auction(**experiment_1)
    auc.run_auction()

    auc = auction.Auction(**experiment_2)
    auc.run_auction()

    auc = auction.Auction(**experiment_3)
    auc.run_auction()

    auc = auction.Auction(**experiment_4)
    auc.run_auction()

    auc = auction.Auction(**experiment_5)
    auc.run_auction()

    auc = auction.Auction(**experiment_6)
Пример #12
0
import auction

auction1154 = auction.Auction("iii1154")
auction1154.scrape_item_ids()
auction1154.scrape_item_info()
print(auction1154.items[0].info)