Ejemplo n.º 1
0
    def test_now(self):
        now = when.now()
        utc = when.now(True)

        # Unfortunately the clock keeps ticking each time we capture a value
        # for now so we can't do a direct comparison with assertEqual.
        # It's probably safe to assume the now function is working as long as
        # the difference is less than a second. There's probably a better way
        # to test this, but for now it's sufficient.
        self.assertTrue(now - self.now < self.one_second)
        self.assertTrue(utc - self.utc < self.one_second)
Ejemplo n.º 2
0
    def test_now(self):
        """Test when.now()"""
        now = when.now()
        utc = when.now(True)

        # Unfortunately the clock keeps ticking each time we capture a value
        # for now so we can't do a direct comparison with assertEqual.
        # It's probably safe to assume the now function is working as long as
        # the difference is less than a second. There's probably a better way
        # to test this, but for now it's sufficient.
        self.assertTrue(now - self.now < self.one_second)
        self.assertTrue(utc - self.utc < self.one_second)
Ejemplo n.º 3
0
 def entity_to_model(self, news):
     model = NewsModel()
     model.no = news.no
     model.title = news.title
     model.author_name = news.author_name
     model.url = news.url
     model.date = news.date
     model.pictures = json.dumps(news.pictures)
     model.category = news.category
     model.created = when.now()
     model.modified = when.now()
     return model
Ejemplo n.º 4
0
 def test_past_years(self):
     nums = [random.randint(1, 1000) for range_index in xrange(1000)]
     for num in nums:
         past = when.past(years=num)
         leap_days = when.how_many_leap_days(past, self.now)
         now_plus = when.now() - self.one_day * (num * 365 + leap_days)
         self.assertTrue(past - now_plus < self.one_second)
Ejemplo n.º 5
0
    def checkout_order(self, store_id, order_no, money, real_money, pay_md,
                       describe):
        order = self.check_order_ctl(store_id, order_no)
        room_id = order['room_id']
        order_id = order['id']

        if order['pay_type'] == PAY_TYPE['current']:
            raise utils.APIError(errcode=50001, errmsg='落单后结才需要结账')

        # self.ctrl.open.update_room_ctl(store_id, room_id, ROOM_TYPE['clean'])
        self.update_order_ctl(
            store_id,
            order_no,
            {
                'describe': describe,
                'money': money + order.get('prepay'),
                'real_money': money + order.get('prepay'),  # real_money
                'finish_time': when.now().strftime('%Y-%m-%d %H:%M:%S')
            })

        # 去掉另一个包房的订单的key
        using_order_key = self.get_using_order_key_ctl(store_id, room_id)
        self.ctrl.rs.delete(using_order_key)

        # 现金的直接支付成功
        if pay_md in (PAY_MD['cash'], PAY_MD['pos']):
            self.after_checkout_order_ctl(store_id, order_no, pay_md)
Ejemplo n.º 6
0
 def test_future_years(self):
     nums = [random.randint(1, 1000) for range_index in xrange(1000)]
     for num in nums:
         future = when.future(years=num)
         leap_days = when.how_many_leap_days(self.now, future)
         now_plus = when.now() + self.one_day * (num * 365 + leap_days)
         self.assertTrue(now_plus - future < self.one_second)
Ejemplo n.º 7
0
    def test_future_months(self):
        nums = [random.randint(1, 1000) for range_index in xrange(1000)]
        for num in nums:
            future = when.future(months=num)
            now_plus = when.now() + self.one_month * num

            self.assertTrue(
                (now_plus - future) < self.one_day * 3 * num)
Ejemplo n.º 8
0
    def test_past_months(self):
        nums = [random.randint(1, 1000) for range_index in xrange(1000)]
        for num in nums:
            past = when.past(months=num)
            now_minus = when.now() - self.one_month * num

            self.assertTrue(
                (past - now_minus) < self.one_day * 3 * num)
Ejemplo n.º 9
0
    def test_is_timezone_naive(self):
        """Test when.is_timezone_naive()"""
        naive = when.now()
        aware = naive.replace(tzinfo=pytz.UTC)

        self.assertTrue(when.is_timezone_naive(naive))
        self.assertFalse(when.is_timezone_naive(aware))

        naive = naive.time()
        aware = naive.replace(tzinfo=pytz.UTC)

        self.assertTrue(when.is_timezone_naive(naive))
        self.assertFalse(when.is_timezone_naive(aware))
Ejemplo n.º 10
0
    def test_is_timezone_naive(self):
        """Test when.is_timezone_naive()"""
        naive = when.now()
        aware = naive.replace(tzinfo=pytz.UTC)

        self.assertTrue(when.is_timezone_naive(naive))
        self.assertFalse(when.is_timezone_naive(aware))

        naive = naive.time()
        aware = naive.replace(tzinfo=pytz.UTC)

        self.assertTrue(when.is_timezone_naive(naive))
        self.assertFalse(when.is_timezone_naive(aware))
Ejemplo n.º 11
0
    def close_order(self, store_id, order_no):
        order = self.check_order_ctl(store_id, order_no)
        room_id = order['room_id']

        if order['pay_type'] == PAY_TYPE['poster']:
            raise utils.APIError(errcode=50001, errmsg='落单后结要结完账才能关台')

        self.ctrl.open.update_room_ctl(store_id, room_id, ROOM_TYPE['clean'])
        self.update_order_ctl(
            store_id, order_no, {
                'state': ORDER_STATE['finish'],
                'finish_time': when.now().strftime('%Y-%m-%d %H:%M:%S')
            })
        key = self.get_using_order_key_ctl(store_id, room_id)
        self.ctrl.rs.delete(key)
Ejemplo n.º 12
0
def forecast(lat=None, lng=None):
    """ Returns the weather for a specific location"""

    if not lat or not lng:
        abort(400)

    root = app.config.get('FORECASTIO_ROOT')
    key = app.config.get('FORECASTIO_API_KEY')
    timestamp = when.format(when.now(), '%Y-%m-%dT%H:%M:%S')

    url = root + key + "/" + lat + ", " + lng + ", " + timestamp

    r = requests.get(url)

    return jsonify(r.json() if r.ok else {})
Ejemplo n.º 13
0
    def test_format(self):
        """Test when.format()"""
        now = when.now()
        today = when.today()
        current_time = now.time()

        for format_string in (
            "%a",
            "%A",
            "%b",
            "%B",
            "%c",
            "%d",
            "%f",
            "%H",
            "%I",
            "%j",
            "%m",
            "%M",
            "%p",
            "%S",
            "%U",
            "%w",
            "%W",
            "%x",
            "%X",
            "%y",
            "%Y",
            "%z",
            "%Z",
            "%A, %B %d, %Y %I:%M %p",
        ):
            # Test date objects
            builtin_date = now.strftime(format_string)
            result_date = when.format(now, format_string)
            self.assertEqual(builtin_date, result_date)

            # Test datetime objects
            builtin_datetime = today.strftime(format_string)
            result_datetime = when.format(today, format_string)
            self.assertEqual(builtin_datetime, result_datetime)

            # Test time objects
            builtin_time = current_time.strftime(format_string)
            result_time = when.format(current_time, format_string)
            self.assertEqual(builtin_time, result_time)
Ejemplo n.º 14
0
def get_data(loop=True, period=15, id_list=[], thread_number=8):
    count = 0
    if not loop:
        period = 1
    while True:
        if (int(str(when.now()).split(":")[1]) - 1) % period == 0:
            if count == 0:
                count = 1
                # Make the Pool of workers
                pool = ThreadPool(thread_number)
                # Open the urls in their own threads
                # and return the results
                results = pool.map(lambda x: handle_stock(x), id_list)
                # close the pool and wait for the work to finish
                pool.close()
                pool.join()
                # print all

                # with open("all.txt",'w') as file:
                #     file.write(stock_set.to_json())

                # CONNECTION.test.newcollection.count({"name": "focus"})

                # origin_data=connection.OSL15mk()
                # origin_data['id']='000001'
                # origin_data['data']='helloworld'
                # origin_data.save()
                #
                #
                # focus=connection.stock.Stage1()
                # focus.collection.remove({"name": "focus"})
                # focus['name']='focus'
                # focus['id_list']=focus_id_list
                # focus['stock_dict']=focus_set
                # focus.save()

                # todo: 可以改成用request发送请求的方式. 但是这样更加总是会执行啊好像
                calc_stage1()
                print "ok"
                if loop == False:
                    return
        else:
            count = 0
        time.sleep(1)
Ejemplo n.º 15
0
    def test_format(self):
        """Test when.format()"""
        now = when.now()
        today = when.today()
        current_time = now.time()

        for format_string in ('%a', '%A', '%b', '%B', '%c', '%d', '%f', '%H',
                              '%I', '%j', '%m', '%M', '%p', '%S', '%U', '%w',
                              '%W', '%x', '%X', '%y', '%Y', '%z', '%Z',
                              '%A, %B %d, %Y %I:%M %p'):
            # Test date objects
            builtin_date = now.strftime(format_string)
            result_date = when.format(now, format_string)
            self.assertEqual(builtin_date, result_date)

            # Test datetime objects
            builtin_datetime = today.strftime(format_string)
            result_datetime = when.format(today, format_string)
            self.assertEqual(builtin_datetime, result_datetime)

            # Test time objects
            builtin_time = current_time.strftime(format_string)
            result_time = when.format(current_time, format_string)
            self.assertEqual(builtin_time, result_time)
Ejemplo n.º 16
0
    def test_format(self):
        """Test when.format()"""
        now = when.now()
        today = when.today()
        current_time = now.time()

        for format_string in ('%a', '%A', '%b', '%B', '%c', '%d', '%f', '%H',
                              '%I', '%j', '%m', '%M', '%p', '%S', '%U', '%w',
                              '%W', '%x', '%X', '%y', '%Y', '%z', '%Z',
                              '%A, %B %d, %Y %I:%M %p'):
            # Test date objects
            builtin_date = now.strftime(format_string)
            result_date = when.format(now, format_string)
            self.assertEqual(builtin_date, result_date)

            # Test datetime objects
            builtin_datetime = today.strftime(format_string)
            result_datetime = when.format(today, format_string)
            self.assertEqual(builtin_datetime, result_datetime)

            # Test time objects
            builtin_time = current_time.strftime(format_string)
            result_time = when.format(current_time, format_string)
            self.assertEqual(builtin_time, result_time)
Ejemplo n.º 17
0
root.wm_attributes('-topmost', 1)
##label标签设置文本变量
Label(root, textvariable=var, font=100).pack()

while True:
    time.sleep(1)
    try:
        # if gate_query.ticker('btc_usdt')['lowestAsk'] > 7700:
        # 	print ('gogogoogogogogogogo')
        # 	os.system("1.mp3")
        # var.set("BUY: "+str(gate_query.ticker('btc_usdt')['lowestAsk']) \
        # 	+"~~~ SELL: "+str(gate_query.ticker('btc_usdt')['highestBid'])+'~~~~'+str(when.now().strftime("%H:%M:%S")))
        # root.update()

        print ("TRX_BUY: " +str(gate_query.ticker('trx_usdt')['lowestAsk']) \
         +"~~~~SELL: "+str(gate_query.ticker('trx_usdt')['highestBid'])+'~~~~'+str(when.now().strftime("%H:%M:%S")))
    except:
        pass

# Market depth of pair
# print(gate_query.orderBook('btc_usdt'))

# Trade History
# print(gate_query.tradeHistory('btc_usdt'))

# Get account fund balances
# print(gate_trade.balances())

# get new address
# print(gate_trade.depositAddres('btc'))
Ejemplo n.º 18
0
def run_proc(PlayPiccoordinate, PlayerPicName, PlayerLeftJudgeCoordinate,
             PlayerCutCoordinate, PlayerLeftPicName, q, lock):
    while True:
        # print "PLAYER-left.jpg here"

        ##各进程时间分离
        if PlayerPicName == "testnew.jpg":
            time.sleep(0.2)
        else:
            time.sleep(0.7)

        lock.acquire()

        ##锁定进程,其它进程不能访问图片
        try:
            # ScreenShot()

            cutpic(PlayPiccoordinate, PlayerPicName)
            img = Image.open(PlayerPicName)
            # print img.getpixel((23,23))

            ##坐标变更为像素列表
            tempx = []
            x = 0
            while x < len(PlayerLeftJudgeCoordinate):
                tempx.append(img.getpixel(PlayerLeftJudgeCoordinate[x]))
                # print type(img.getpixel(PlayerLeftJudgeCoordinate[x]))
                x = x + 1

            # print tempx
            # print len(list(set(tempx).intersection(set(ifcolor))))
            # print len(PlayerLeftJudgeCoordinate)
            # print "PlayerLeftJudgeCoordinate........."+str(len(PlayerLeftJudgeCoordinate))
            ##判断列表中元素是否在ifcolor中,如果一样,再进行截图操作
            if len(list(set(tempx).intersection(
                    set(ifcolor)))) == len(PlayerLeftJudgeCoordinate):
                cutnum(img, (PlayerCutCoordinate), PlayerLeftPicName)
                ##旋转图片
                leftpic = Image.open(PlayerLeftPicName)
                newLP = leftpic.rotate(270)
                newLP.save(PlayerLeftPicName)

                # if imgBANKER.getpixel((137,26)) in ifcolor:
                ##先移除像素点值,便于只输出一次
                # playLeftColorRecode = img.getpixel(i)
                # ifcolor.remove(playLeftColorRecode)

                # if str(getverify1(PlayerLeftPicName)) == None:
                # 	continue

                del PlayerLeftJudgeCoordinate[0]

                ##根据文件名来打印字体dos颜色
                if "BANKER" in PlayerLeftPicName:
                    clr.print_blue_text(
                        PlayerLeftPicName.split('.')[0] + u"。。。。。" +
                        str(getverify1(PlayerLeftPicName)))

                else:
                    print PlayerLeftPicName.split('.')[0] + u"。。。。。" + str(
                        getverify1(PlayerLeftPicName))  #leftcard

                ##录屏
                im = ImageGrab.grab()
                im.save(os.getcwd() + "\\pic\\" +
                        str(when.now()).split(".")[0].replace(":", "-") +
                        "screenshot.png")  #保存图片

                # print str(getverify1(PlayerLeftPicName))
                # print cardAllNum
                ##q为多进程的共享变量列表
                q.remove(str(getverify1(PlayerLeftPicName)))
                ##进程休眠时间分离
                if PlayerLeftPicName == 'PLAYER-left.jpg':
                    time.sleep(2.5)
                else:
                    time.sleep(1)
                break
            else:
                break
        finally:
            ##解除进程锁定
            lock.release()
        break
Ejemplo n.º 19
0
            #    or clr.intCardNum(getverify1('BANKER-middle.jpg'))+clr.intCardNum(getverify1('BANKER-left.jpg')) < 6:
            ####先移除像素点值,便于只输出一次
            colorRecorde = img.getpixel((79, 16))
            ifcolor.remove(img.getpixel((79, 16)))

            ##识别牌后从列表中移除
            q.remove(str(getverify1('PLAYER-middle.jpg')))
            q.remove(str(getverify1('PLAYER-right.jpg')))
            q.remove(str(getverify1('BANKER-middle.jpg')))
            q.remove(str(getverify1('BANKER-left.jpg')))
            # time.sleep(15)

            #录屏
            im = ImageGrab.grab()
            im.save(os.getcwd() + "\\pic\\" +
                    str(when.now()).split(".")[0].replace(":", "-") +
                    "screenshot.png")  #保存图片

        # if  clr.intCardNum(getverify1('PLAYER-middle.jpg')) + clr.intCardNum(getverify1('PLAYER-right.jpg')) > 10:
        # 	mainCard = clr.intCardNum(getverify1('PLAYER-middle.jpg')) + clr.intCardNum(getverify1('PLAYER-right.jpg')) -10
        # 	# print mainCard
        # else:
        # 	mainCard =  clr.intCardNum(getverify1('PLAYER-middle.jpg')) + clr.intCardNum(getverify1('PLAYER-right.jpg'))
        # # print mainCard

        # if clr.intCardNum(getverify1('BANKER-middle.jpg')) + clr.intCardNum(getverify1('BANKER-left.jpg')) > 10:
        # 	BankerCard = clr.intCardNum(getverify1('BANKER-middle.jpg')) + clr.intCardNum(getverify1('BANKER-left.jpg')) - 10
        # else:
        # 	BankerCard = clr.intCardNum(getverify1('BANKER-middle.jpg')) + clr.intCardNum(getverify1('BANKER-left.jpg'))

        ##根据百家乐发牌规则编写
Ejemplo n.º 20
0
def gen_order_no():
    return when.now().strftime('%Y%m%d%H%M%S') + str(random.randint(0, 99)).zfill(2)
Ejemplo n.º 21
0
def run_proc(PlayPiccoordinate, PlayerPicName, PlayerLeftJudgeCoordinate,
             PlayerCutCoordinate, PlayerLeftPicName):

    clr = Color()

    # print PlayerLeftPicName

    # while True:
    # time.sleep(1)
    # 	# print "PLAYER-left.jpg here"
    # print PlayerLeftPicName

    ## if PlayerPicName == "testnew.jpg" :
    ## 	time.sleep(2)
    ## 	break
    ## else:
    ## 	time.sleep(1)

    if PlayerPicName == "testnew.jpg":
        time.sleep(0.2)
    else:
        time.sleep(1)

    ##准备加入当中牌识别,这里是判断是否切图
    if PlayPiccoordinate == 0:
        pass
    else:
        cutpic(PlayPiccoordinate, PlayerPicName)

    img = Image.open(PlayerPicName)
    # print img.getpixel((23,23))

    tempx = []
    x = 0
    while x < len(PlayerLeftJudgeCoordinate):
        tempx.append(img.getpixel(PlayerLeftJudgeCoordinate[x]))
        # print type(img.getpixel(PlayerLeftJudgeCoordinate[x]))
        x = x + 1

    # print tempx
    # print len(list(set(tempx).intersection(set(ifcolor))))
    # print "PlayerLeftJudgeCoordinate........."+str(len(PlayerLeftJudgeCoordinate))
    ##判断列表中元素是否在ifcolor中,如果一样,再进行截图操作
    if len(list(set(tempx).intersection(
            set(ifcolor)))) == len(PlayerLeftJudgeCoordinate):
        cutnum(img, (PlayerCutCoordinate), PlayerLeftPicName)

        if "PLAYER-middle" in PlayerLeftPicName or "PLAYER-right" in PlayerLeftPicName \
         or "BANKER-middle" in PlayerLeftPicName or "BANKER-left"  in PlayerLeftPicName:
            pass

        if 'PLAYER-left.jpg' in PlayerLeftPicName or 'BANKER-right.jpg' in PlayerLeftPicName:
            leftpic = Image.open(PlayerLeftPicName)
            newLP = leftpic.rotate(270)
            newLP.save(PlayerLeftPicName)

        # if imgBANKER.getpixel((137,26)) in ifcolor:
        ##先移除像素点值,便于只输出一次
        # playLeftColorRecode = img.getpixel(i)
        # ifcolor.remove(playLeftColorRecode)

        del PlayerLeftJudgeCoordinate[0]

        if "BANKER" in PlayerLeftPicName:
            clr.print_blue_text(
                PlayerLeftPicName.split('.')[0] + u"。。。。。" +
                str(getverify1(PlayerLeftPicName)))
        else:
            print PlayerLeftPicName.split('.')[0] + u"。。。。。" + str(
                getverify1(PlayerLeftPicName))  #leftcard

        ##录屏
        im = ImageGrab.grab()
        im.save(os.getcwd() + "\\pic\\" +
                str(when.now()).split(".")[0].replace(":", "-") +
                "screenshot.png")  #保存图片

        return str(getverify1(PlayerLeftPicName))

        # if PlayerLeftPicName == 'PLAYER-left.jpg':
        # 	time.sleep(5)
        # elif PlayerLeftPicName == 'PLAYER-middle.jpg':
        # 	time.sleep(20)
        # elif PlayerLeftPicName == 'BANKER-left.jpg':
        # 	time.sleep(12)
        # elif PlayerLeftPicName == 'PLAYER-right.jpg':
        # 	time.sleep(10)
        # elif PlayerLeftPicName == 'BANKER-middle.jpg':
        # 	time.sleep(8)
        # else:
        # 	time.sleep(3)
        # break
    # else:
    # 	break
    # break
    return PlayerLeftPicName.split('.')[0] + " is run.........."
Ejemplo n.º 22
0
def run_proc(PlayPiccoordinate,PlayerPicName,PlayerLeftJudgeCoordinate,PlayerCutCoordinate,PlayerLeftPicName):

	clr = Color()

	# print PlayerLeftPicName

	# while True:
		# time.sleep(1)
	# 	# print "PLAYER-left.jpg here"
		# print PlayerLeftPicName

		## if PlayerPicName == "testnew.jpg" :
		## 	time.sleep(2)
		## 	break
		## else:
		## 	time.sleep(1)

	if PlayerPicName == "testnew.jpg" :
		time.sleep(0.2)
	else:
		time.sleep(1)
	
	##准备加入当中牌识别,这里是判断是否切图
	if PlayPiccoordinate == 0:
		pass
	else:
		cutpic(PlayPiccoordinate,PlayerPicName)

	img = Image.open(PlayerPicName)
	# print img.getpixel((23,23))
	
	tempx = []
	x = 0
	while x < len(PlayerLeftJudgeCoordinate):
		tempx.append(img.getpixel(PlayerLeftJudgeCoordinate[x]))
		# print type(img.getpixel(PlayerLeftJudgeCoordinate[x]))
		x = x + 1

	# print tempx
	# print len(list(set(tempx).intersection(set(ifcolor))))
	# print "PlayerLeftJudgeCoordinate........."+str(len(PlayerLeftJudgeCoordinate))
	##判断列表中元素是否在ifcolor中,如果一样,再进行截图操作
	if len(list(set(tempx).intersection(set(ifcolor)))) == len(PlayerLeftJudgeCoordinate):
		cutnum(img,(PlayerCutCoordinate),PlayerLeftPicName)

		if "PLAYER-middle" in PlayerLeftPicName or "PLAYER-right" in PlayerLeftPicName \
		 or "BANKER-middle" in PlayerLeftPicName or "BANKER-left"  in PlayerLeftPicName:
			pass


		if 'PLAYER-left.jpg' in PlayerLeftPicName or 'BANKER-right.jpg' in PlayerLeftPicName:
			leftpic = Image.open(PlayerLeftPicName)
			newLP = leftpic.rotate(270)
			newLP.save(PlayerLeftPicName)

		# if imgBANKER.getpixel((137,26)) in ifcolor:
		##先移除像素点值,便于只输出一次
		# playLeftColorRecode = img.getpixel(i)
		# ifcolor.remove(playLeftColorRecode)

		del PlayerLeftJudgeCoordinate[0]

		if "BANKER" in PlayerLeftPicName:
			clr.print_blue_text(PlayerLeftPicName.split('.')[0]+u"。。。。。"+str(getverify1(PlayerLeftPicName)))
		else:
			print PlayerLeftPicName.split('.')[0]+u"。。。。。"+str(getverify1(PlayerLeftPicName))  #leftcard

		##录屏
		im = ImageGrab.grab() 
		im.save(os.getcwd()+"\\pic\\"+str(when.now()).split(".")[0].replace(":","-")+"screenshot.png")#保存图片 

		return str(getverify1(PlayerLeftPicName))

		# if PlayerLeftPicName == 'PLAYER-left.jpg':
		# 	time.sleep(5)
		# elif PlayerLeftPicName == 'PLAYER-middle.jpg':
		# 	time.sleep(20)
		# elif PlayerLeftPicName == 'BANKER-left.jpg':
		# 	time.sleep(12)
		# elif PlayerLeftPicName == 'PLAYER-right.jpg':
		# 	time.sleep(10)
		# elif PlayerLeftPicName == 'BANKER-middle.jpg':
		# 	time.sleep(8)
		# else:
		# 	time.sleep(3)
		# break
	# else:
	# 	break
	# break
	return PlayerLeftPicName.split('.')[0]+" is run.........."
Ejemplo n.º 23
0
def gen_no(prefix=''):
    no = prefix + when.format(when.now(), '%Y%m%d%H%M%S') + str(
        random.randint(10000, 99999))
    return no
Ejemplo n.º 24
0
 def now():
     return when.now().strftime(r'[%Y-%m-%d %H:%M:%S]')
Ejemplo n.º 25
0
 def is_expired(self):
     if self.access_token and self.expires is not None:
         return when.now() > self.expires
Ejemplo n.º 26
0
#coding=utf8
import when

print when.timezone()

print when.today()

print when.tomorrow()

print when.now()
Ejemplo n.º 27
0
root.wm_attributes('-topmost',1)
##label标签设置文本变量
Label(root, textvariable = var,font = 100).pack()

while True:
	time.sleep(1)
	try:
		# if gate_query.ticker('btc_usdt')['lowestAsk'] > 7700:
		# 	print ('gogogoogogogogogogo')
		# 	os.system("1.mp3")
		# var.set("BUY: "+str(gate_query.ticker('btc_usdt')['lowestAsk']) \
		# 	+"~~~ SELL: "+str(gate_query.ticker('btc_usdt')['highestBid'])+'~~~~'+str(when.now().strftime("%H:%M:%S")))
		# root.update()

		print ("TRX_BUY: " +str(gate_query.ticker('trx_usdt')['lowestAsk']) \
			+"~~~~SELL: "+str(gate_query.ticker('trx_usdt')['highestBid'])+'~~~~'+str(when.now().strftime("%H:%M:%S")))
	except:
		pass

# Market depth of pair
# print(gate_query.orderBook('btc_usdt'))

# Trade History
# print(gate_query.tradeHistory('btc_usdt'))

# Get account fund balances
# print(gate_trade.balances())

# get new address
# print(gate_trade.depositAddres('btc'))
Ejemplo n.º 28
0
import when
datadir = '../data/'
mid_datadir = '../mid_data/'
final_datadir = '../final_data/'
dict_dir = '../dict/'
file_suffix = when.now().strftime("%Y%m%d")
newest_time = when.past(0, 3).strftime("%Y%m%d")

gentime_type = {'year': ['1', '0'], 'newest': ['3', newest_time],
                '2014': ['2', '0'], '2013': ['3', '20130101']}
Ejemplo n.º 29
0
    setText(codes)
    ctrlV()
    time.sleep(0.2)
    enter()


# fillInnerPicFirst()
# fillInnerPicSecond()

##带参数运行python命令
# print sys.argv

if len(sys.argv) > 1:
    if list(sys.argv)[1] == "Second":
        fillInnerPicSecond()
    elif list(sys.argv)[1] == "First":
        fillInnerPicFirst()
    elif list(sys.argv)[1] == "lg":
        while True:
            signLaoGongTV()
            print(when.now())
            time.sleep(601)
    elif list(sys.argv)[1] == "cr":
        while True:
            clickSendRoom()
            print(when.now())
            time.sleep(30)
    elif list(sys.argv)[1] == "hz":
        HZadmin()

print('The current pointer position is {0}'.format(mouse.position))
Ejemplo n.º 30
0
def produce(c,d,e):

	##生成器函数初始化
	c.send(None)
	d.send(None)
	e.send(None)
	#传递值初始化
	n = 0
	##锁定每个生成器函数值设置为0
	MAINCARD = 0
	PLAYLEFTCARD = 0
	BANKERRIGHTCARD = 0

	##延时押注,以避免进程检测(这个方法会有漏洞,不用)
	# xxxx = when.future(seconds = 600)

	##防止闲置变量
	spareTime = 0

	##开始循环检查是否已经开牌
	while True:

		
		n = n + 1
		# time.sleep(0.2)
		##截屏,原先所用延时方法会导致文件抢读取错误,现在用进程锁保证任务顺利执行完毕
		##
		# ScreenShotPic = Process(target=ScreenShot,args=())
		# ScreenShotPic.start()
		# ScreenShotPic.join()
		ScreenShot()
		time.sleep(0.2)

		#点击确定在此桌
		clickDevice()

		##分辨切PLAYER和BANKER和牌重置的图
		cutpic((569,751,746,817),"testnew.jpg")
		cutpic((1173,751,1350,817),"BANKER.jpg")
		cutpic((1468,121,1485,138),"Point.jpg")

		##Screenimg
		Screenimg = Image.open("Point.jpg")

		##PLAYERimg
		img = Image.open("testnew.jpg")

		##BANKERimg
		imgBANKER = Image.open("BANKER.jpg")
		
		##插入ipython断点,待进入循环时停止检查变量
		##from IPython import embed
		##embed()

		##定时押注,默认为10分钟一次防呆滞(有漏洞,弃用)
		# if when.now() == xxxx:
		# 	oneCoin()
		# 	Player_wager(1)
		# 	xxxx = when.now()

		#检查是否又是新牌,如果新牌的话,重置牌数
		if Screenimg.getpixel((13,9))  in pointColor and Screenimg.getpixel((8,14))  in pointColor:
			del cardAllNum[:] 
			k = 0
			# print cardAllNum.count('A')
			basicCard =['0','A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] 
			for i in basicCard:
				while k < 32:
					cardAllNum.append(i)
					k = k + 1
				k = 0

			##延时点击重置(有漏洞,弃用)
			# xxxx = when.future(seconds = 600)

		##检查是否桌面已清空,清空的话每处归零
		if MAINCARD != 0 and img.getpixel((79,16))  not in ifcolor and imgBANKER.getpixel((62,26))   \
		not in ifcolor and img.getpixel((130,3)) not in ifcolor and imgBANKER.getpixel((7,26)) not in ifcolor and \
		imgBANKER.getpixel((137,26)) not in ifcolor and img.getpixel((23,23)) not in ifcolor:
			MAINCARD = 0
			PLAYLEFTCARD = 0
			BANKERRIGHTCARD = 0

			# #当中点击一下,防锁定
			clickmiddle()

			##防止闲置
			spareTime = spareTime + 1

			if spareTime == 12:
				oneCoin()
				Player_wager(1)
				spareTime = 0 

			##打印剩余牌数目
			clr.print_red_text('---------------------------------')
			print clr.print_green_text([
			'0'+':'+str(cardAllNum.count('0')), 
			'A'+':'+str(cardAllNum.count('A')), 
			'2'+':'+str(cardAllNum.count('2')), 
			'3'+':'+str(cardAllNum.count('3')), 
			'4'+':'+str(cardAllNum.count('4')),
			'5'+':'+str(cardAllNum.count('5')), 
			'6'+':'+str(cardAllNum.count('6')), 
			'7'+':'+str(cardAllNum.count('7')), 
			'8'+':'+str(cardAllNum.count('8')), 
			'9'+':'+str(cardAllNum.count('9')), 
			'10'+':'+str(cardAllNum.count('10')), 
			'J'+':'+str(cardAllNum.count('J')), 
			'Q'+':'+str(cardAllNum.count('Q')), 
			'K'+':'+str(cardAllNum.count('K'))
			]) 
			clr.print_red_text('---------------------------------')

			# ##UI显示
			Uilist = \
			'0'+':'+str(cardAllNum.count('0'))+',\n' \
			+  'A'+':'+str(cardAllNum.count('A'))+',\n' \
			+  '2'+':'+str(cardAllNum.count('2'))+',\n' \
			+  '3'+':'+str(cardAllNum.count('3'))+',\n' \
			+  '4'+':'+str(cardAllNum.count('4'))+',\n' \
			+ '5'+':'+str(cardAllNum.count('5'))+',\n' \
			+  '6'+':'+str(cardAllNum.count('6'))+',\n' \
			+  '7'+':'+str(cardAllNum.count('7'))+',\n' \
			+  '8'+':'+str(cardAllNum.count('8'))+',\n' \
			+  '9'+':'+str(cardAllNum.count('9'))+',\n' \
			+  '10'+':'+str(cardAllNum.count('10'))+',\n' \
			+  'J'+':'+str(cardAllNum.count('J'))+',\n' \
			+  'Q'+':'+str(cardAllNum.count('Q'))+',\n' \
			+  'K'+':'+str(cardAllNum.count('K'))+',\n' \
			+ 'Total :'+str(len(cardAllNum)-32)
			
			var.set(str(Uilist))
			root.update()

			

			#打印当前时间
			print when.now()

			##准备c的ARRAY准备传入dll做运算
			finallist = [
					cardAllNum.count('0'), 
					cardAllNum.count('A'), 
					cardAllNum.count('2'), 
					cardAllNum.count('3'), 
					cardAllNum.count('4'),
					cardAllNum.count('5'), 
					cardAllNum.count('6'), 
					cardAllNum.count('7'), 
					cardAllNum.count('8'), 
					cardAllNum.count('9'), 
					cardAllNum.count('10'), 
					cardAllNum.count('J'),
					cardAllNum.count('Q'), 
					cardAllNum.count('K')
					]
			# print finallist
			#生成14个变量的ARRAY
			m = (ctypes.c_int *14)(*finallist)

			import numpy as np
			arraytolist = np.array(m)
			# print arraytolist.tolist()

			t=pDll.Dec_bet(m) 

			print t.Banker_wager  
			print t.Player_wager
			print t.DB_wager
			print t.Tie_wager
			print t.Pair_wager
			# print t.DB_EV

			wagerlist = {"t.Banker_wager":t.Banker_wager, "t.Player_wager":t.Player_wager, "t.DB_wager":t.DB_wager, "t.Tie_wager":t.Tie_wager, "t.Pair_wager":t.Pair_wager}

			for wagerName,wagerValue in wagerlist.items():
				if wagerValue > 0:
					time.sleep(1)
					gogogo (wagerName.split('.')[1],wagerValue)
					


			clr.print_red_text('---------------------------------')

		##检测当中的四张牌
		if MAINCARD == 0 and img.getpixel((79,16))  in ifcolor  and imgBANKER.getpixel((62,26)) in ifcolor  \
		and img.getpixel((130,3)) in ifcolor and imgBANKER.getpixel((7,26)) in ifcolor \
		and imgBANKER.getpixel((2,3)) in ifcolor and imgBANKER.getpixel((103,3)) in ifcolor:
			r = c.send(n)
			MAINCARD = r
			# print ('[PRODUCER] Consumer return: %s' % str(r))
			for i in r:
				cardAllNum.remove(i)

		##检查PLAYER的最左面牌
		if PLAYLEFTCARD == 0 and img.getpixel((23,23)) in ifcolor:
			r1 = d.send(n)
			PLAYLEFTCARD = r1
			cardAllNum.remove(r1)
			# print ('[PRODUCER] Consumer return: %s' % r1)

		##检查BANKER的最后面牌
		if BANKERRIGHTCARD == 0 and imgBANKER.getpixel((137,26)) in ifcolor:
			r2 = e.send(n)
			BANKERRIGHTCARD = r2
			cardAllNum.remove(r2)
			##from IPython import embed
			##embed()
		# r = c.send(n)
		# print('[PRODUCER] Consumer return: %s' % r)	
		
	c.close()
Ejemplo n.º 31
0
	setText(codes)
	ctrlV()
	time.sleep(0.2)
	enter()

# fillInnerPicFirst()
# fillInnerPicSecond()

##带参数运行python命令
# print sys.argv

if len(sys.argv)>1:
	if list(sys.argv)[1] == "Second":
		fillInnerPicSecond()
	elif list(sys.argv)[1] == "First":
		fillInnerPicFirst()
	elif list(sys.argv)[1] == "lg":
		while True:
			signLaoGongTV()
			print (when.now())
			time.sleep(601)
	elif list(sys.argv)[1] == "cr":
		while True:
			clickSendRoom()
			print (when.now())
			time.sleep(30)
	elif list(sys.argv)[1] == "hz":
		HZadmin()

print('The current pointer position is {0}'.format(
    mouse.position))
Ejemplo n.º 32
0
    return id_list_of_set
    # print re_stock_id.findall(text_string)
    # stock_id_list=open('stock_id_list.txt','w')
    # print >>stock_id_list, re_stock_id.findall(text_string)


id_list_of_set = get_set_from_file(set_name_list)

focus_set = {}
all_set = {}
hold_set = {}
test_set = {}

import when, time

print "time is " + str(when.now()).split(":")[1]

from stock.core.algorithm.stage1 import calc_stage1


def get_data(loop=True, period=15, id_list=[], thread_number=8):
    count = 0
    if not loop:
        period = 1
    while True:
        if (int(str(when.now()).split(":")[1]) - 1) % period == 0:
            if count == 0:
                count = 1
                # Make the Pool of workers
                pool = ThreadPool(thread_number)
                # Open the urls in their own threads