def update_current_stack_log_session(self, screen_area): if len(screen_area) > 0: for item in screen_area: db = postgresql.open(db_query.connection_string()) db.query( "UPDATE screen_coordinates SET active = CASE active WHEN 0 THEN 1 WHEN 1 THEN 0 ELSE active END " "where screen_area = " + str(item))
def error_log(module_name, error_message): db = postgresql.open(db_query.connection_string()) insert = db.prepare( "insert into error_log (module_name, error_message) values($1,$2)") insert(module_name, str(error_message)) data = ({'error_message': error_message}) requests.post(url='http://cru.im/errorlog', json=data) play_alarm_sound()
def check_is_folder_exist(): folder_name = os.path.join(IMAGES_FOLDER, str(datetime.datetime.now().date())) if not os.path.exists(str(folder_name)): os.makedirs(str(folder_name)) db = postgresql.open(db_query.connection_string()) data = db.query( "select screen_area from screen_coordinates " "union select screen_area from opponent_screen_coordinates") for value in data: if not os.path.exists( str(folder_name) + "/" + str(value['screen_area'])): os.makedirs(str(folder_name) + "/" + str(value['screen_area']))
import datetime import math import postgresql import requests import image_processing import session_log import mouse import introduction import bar as metka import postflop import db_query import remote_control IMAGES_FOLDER = "images/" FOLDER_NAME = IMAGES_FOLDER + str(datetime.datetime.now().date()) DB = postgresql.open(db_query.connection_string()) SCREEN_DATA = db_query.get_screen_data(DB) DECK = db_query.get_cards(DB) STACK_COLLECTION = db_query.get_stack_images(DB) APP_STATE = False def start(): global APP_STATE if not APP_STATE: APP_STATE = remote_control.get_app_state() for item in SCREEN_DATA: mouse.move_mouse(item['x_mouse'], item['y_mouse']) if metka.search_bar(item['screen_area'], DB): image_name = str(math.floor(time.time())) + ".png" image_path = os.path.join(IMAGES_FOLDER,
def error_log(module_name, error_message): db = postgresql.open(db_query.connection_string()) print('Error:' + error_message) insert = db.prepare("insert into error_log (module_name, error_message) values($1,$2)") insert(module_name, str(error_message)) play_alarm_sound()
def get_curren_value(self, screen_area): db = postgresql.open(db_query.connection_string()) data = db.query( "select active from screen_coordinates where screen_area = " + str(screen_area)) return data[0]['active']
def truncate_screenshot_table(self): db = postgresql.open(db_query.connection_string()) db.query("truncate screenshots restart identity")
import pytest import postgresql import db_query import session_log @pytest.mark.parametrize( 'screen_area, db', (['1', '2', '3', '4'], [postgresql.open(db_query.connection_string())])) def test_get_hand_value(screen_area, db): print(session_log.get_hand_value(screen_area, db))