|
@@ -12,25 +12,32 @@ class Ssgdfs(object):
|
|
|
|
|
|
def start(self):
|
|
|
if 'product' in self.config and self.config['product']:
|
|
|
-
|
|
|
- self.open()
|
|
|
-
|
|
|
- self.login()
|
|
|
-
|
|
|
- self.core()
|
|
|
-
|
|
|
- self.close()
|
|
|
+ try:
|
|
|
+
|
|
|
+ self.open()
|
|
|
+
|
|
|
+ self.login()
|
|
|
+
|
|
|
+ self.core()
|
|
|
+
|
|
|
+ self.close()
|
|
|
+ except BaseException, e:
|
|
|
+ print e
|
|
|
+ self.start()
|
|
|
|
|
|
def core(self):
|
|
|
|
|
|
+ '''
|
|
|
task = []
|
|
|
for v in self.config['product']:
|
|
|
task.append(gevent.spawn(self.buy, v))
|
|
|
gevent.joinall(task)
|
|
|
+ '''
|
|
|
+ for v in self.config['product']:
|
|
|
+ self.buy(v)
|
|
|
|
|
|
def buy(self, config):
|
|
|
product = Demeter.service('product')
|
|
|
- product.status(config['id'], 2)
|
|
|
while 1:
|
|
|
state = self.check(config['link'])
|
|
|
if state == True:
|
|
@@ -46,10 +53,9 @@ class Ssgdfs(object):
|
|
|
product.order(order, pic, config['site_id'], config['id'])
|
|
|
product.status(config['id'], 4)
|
|
|
break
|
|
|
- except Exception:
|
|
|
- print 'error'
|
|
|
- continue
|
|
|
- else:
|
|
|
+ except BaseException, e:
|
|
|
+ print e
|
|
|
+ product.status(config['id'], 2)
|
|
|
continue
|
|
|
else:
|
|
|
gevent.sleep(30)
|