示例#1
0
class ItemWatcher(threading.Thread):
    def __init__(self, cli):
        threading.Thread.__init__(self)
        self.cli = EBayClient()
        self.logged_in = False

    def timeLeft(self, item):
        if item.info == None:
            return None
        return item.info['endtime'] - datetime.now(tzlocal())

    def watchItem(self, item):
        if item.info == None:
            return

        time_left = self.timeLeft(item)
        if (time_left == timedelta()):
            return

        if time_left < timedelta(0, Config.bidtime, 0) and not item.ignore:
            try:
                if item.maxbid >= item.info['minbid']:
                    print "Sniping item %d (our bid %d)" % (item.id,
                                                            item.maxbid)
                    self.cli.bid(item.id, item.maxbid)
                    print "Successful bid at %s! Hope you win!" % (
                        self.timeLeft(item))
                else:
                    print "Skipping item %d as our max bid is lower than current minimum" % (
                        item.maxbid)
            except Exception, e:
                print "BID FAILED: %s" % e
            finally:
示例#2
0
class ItemWatcher(threading.Thread):
	def __init__(self, cli):
		threading.Thread.__init__(self)
		self.cli = EBayClient()
		self.logged_in = False

	def timeLeft(self, item):
		if item.info == None:
			return None
		return item.info['endtime'] - datetime.now(tzlocal())

	def watchItem(self, item):
		if item.info == None:
			return

		time_left = self.timeLeft(item)
		if (time_left == timedelta()):
			return
		
		if time_left < timedelta(0, Config.bidtime, 0) and not item.ignore:
			try:
				if item.maxbid >= item.info['minbid']:
					print "Sniping item %d (our bid %d)" % (item.id, item.maxbid)
					self.cli.bid(item.id, item.maxbid)
					print "Successful bid at %s! Hope you win!" % (self.timeLeft(item))
				else:
					print "Skipping item %d as our max bid is lower than current minimum" % (item.maxbid)
			except Exception, e:
				print "BID FAILED: %s" % e
			finally:
示例#3
0
文件: snipe.py 项目: suresh/sniper
#!/usr/bin/env python

import signal, sys, os, traceback, pickle
from ebay import EBayClient
from web import WebServer
from updater import ItemUpdater
from watcher import ItemWatcher
from config import Config

cli = EBayClient()
itemUpdater = ItemUpdater(cli)
itemWatcher = ItemWatcher(cli)
webServer = WebServer(cli, itemUpdater)


def signalHandler(signum, frame):
    if (signum == signal.SIGINT):
        print 'Caught SIGINT, shutting down...'
        exit(1)


def exit(code):
    webServer.stop()
    sys.exit(code)


def main(filename):
    signal.signal(signal.SIGINT, signalHandler)

    if os.path.exists(filename):
        fileObj = open(filename, "rb")
示例#4
0
 def __init__(self, cli):
     threading.Thread.__init__(self)
     self.cli = EBayClient()
     self.logged_in = False
示例#5
0
	def __init__(self, cli):
		threading.Thread.__init__(self)
		self.cli = EBayClient()
		self.logged_in = False