Example #1
0
	def test_uclogin2(self):
		test_cloudaccount_login(self.driver,self.login_url, username="******", password="", token="")
		sleep(1)
		get_screenshot(self.driver,"test_uclogin2")
		login_page=LoginPage(self.driver,u"baidu", u"baidu Cloud")
		self.assertEqual(login_page.uclogin_password_error_hint(), u"密码不能为空")
		self.assertEqual(login_page.uclogin_token_error_hint(), u"验证码不能为空")
Example #2
0
 def test_baidulogin1(self):
     test_user_login(self.driver, self.login_url, username="", password="")
     sleep(1)
     login_page = LoginPage(self.driver, u"baidu", u"baidu Cloud")
     self.assertEqual(login_page.baiduaccountlogin_error_hint(),
                      u"请您输入手机/邮箱/用户名")
     get_screenshot(self.driver, "test_baidulogin1")
Example #3
0
 def test_baidulogin4(self):
     test_user_login(self.driver,
                     self.login_url,
                     username="******",
                     password="******")
     sleep(1)
     login_page = LoginPage(self.driver, u"baidu", u"baidu Cloud")
     self.assertEqual(login_page.baiduaccountlogin_error_hint(),
                      u"用户名或密码有误,请重新输入或找回密码")
     get_screenshot(self.driver, "test_baidulogin4")
Example #4
0
	def goto_createticketpage(self,driver):
		#self.find_element(*self.ticket_loc).click()
		above=self.find_element(*self.ticket_loc)
		ActionChains(driver).move_to_element(above).perform()
		get_screenshot(driver,"ticket")
		self.find_element(*self.createticket_loc).click()
		sleep(3)
		get_screenshot(driver, "createticket")
		window_1=driver.current_window_handle
		windows=driver.window_handles
		for current_window in windows:
			if current_window!=window_1:
				driver.switch_to.window(current_window)
		sleep(3)

		ticketlist_status=self.find_element(*self.createtickettext_loc).is_displayed()
		mylogger.info("%s"%ticketlist_status)
		self.createticket(driver)
Example #5
0
 def get_location_from_game(self, search_item, game_top_left_position=None):
     a = game_top_left_position
     if game_top_left_position is None:
         a = get_position('8ball logo', self._locations['8ball logo'], 'game top left')
     b = get_position('game top left', a, 'game bottom right')
     w = b[0]-a[0]
     h = b[1]-a[1]
     x,y = a
     img = get_screenshot(x,y,w,h)
     return self._get_location_from_img(img, search_item, a[0], a[1])
Example #6
0
	def goto_ticketlistpage(self,driver):
		#self.find_element(*self.ticket_loc).click()
		above=self.find_element(*self.ticket_loc)
		ActionChains(driver).move_to_element(above).perform()
		get_screenshot(driver,"ticket")
		self.find_element(*self.ticketlist_loc).click()
		sleep(3)
		
		window_1=driver.current_window_handle
		windows=driver.window_handles
		for current_window in windows:
			if current_window!=window_1:
				driver.switch_to.window(current_window)
		sleep(3)
		get_screenshot(driver, "allticketlist")
		try:
			ticketlist_status=self.find_element(*self.ticketlisttext_loc).is_displayed()
			self.assertTrue(ticketlist_status, "'tiket list' text not existed")

		except:
			pass
Example #7
0
def parse_commands(message):
    global chat_id
    chat_id = message.chat.id
    sender_id = message.from_user.id
    sender_username = message.from_user.username
    if sender_id not in config.ALLOWED_USERS:
        bot.send_message(chat_id, "Unauthorized user")
        print(sender_id,sender_username)
    else:
        message_text = message.text
        if message_text == "/list":
            message = list_torrents()
            if message == "":
                bot.send_message(chat_id, "No torrents in progress")
            else:
                bot.send_message(chat_id, message)
        elif message_text.startswith("/magnet"):
            try:
                start_torrent_from_magnet(message_text.split()[1], chat_id)
            except:
                bot.send_message(chat_id, "Enter a magnet link")
        elif message_text == "/update_library":
            output = update_library()
            if output:
                bot.send_message(chat_id, "Updating..")
            else:
                bot.send_message(chat_id, "Unknown error")
        elif message_text == "/clean_library":
            output = clean_library()
            if output:
                bot.send_message(chat_id, "Cleaning complete")
            else:
                bot.send_message(chat_id, "Unknown error")
        elif message_text == "/screenshot":
            sct = get_screenshot()
            bot.send_photo(chat_id, open(sct, 'rb'))
            remove("monitor-1.png")
        elif message_text == "/copy_movies":
            copy_movies()
        elif message_text == "/purge_all_torrents":
            purge_all_torrents()
        elif message_text == "/parse_eztv":
            parse_eztv()
        elif message_text == "/stop_all_torrents":
            stop_all_torrents()
            send_message("All torrents stopped")
        elif message_text == "/remove_all_torrents":
            remove_all_torrents()
            send_message("All torrents removed")
Example #8
0
    def get_player_status(self):
        a = get_position('logo', self._locations['8ball logo'], 'player status top left')
        b = get_position('player status top left', a, 'player status bottom right')
        w = b[0]-a[0]
        h = b[1]-a[1]
        x,y = a
        img = get_screenshot(x,y,w,h,grayscale=False)

        status = self._get_player_status_from_img(img)
        if self._debug and status == PS_OTHER:
            plt.imshow(img)
            plt.draw()
            plt.show(block=False)

        return status
Example #9
0
    def get_target(self):
        a = get_position('logo', self._locations['8ball logo'], 'target ball top left')
        b = get_position('logo', self._locations['8ball logo'], 'target ball bottom right')
        w = b[0]-a[0]
        h = b[1]-a[1]
        x,y = a
        img = get_screenshot(x,y,w,h,grayscale=False)

        if self._debug:
            import uuid
            # cv2.imwrite('ball-target-%s.jpg' % (uuid.uuid4(),), img)
            img2 = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
            # print img
            plt.imshow(img2)
            plt.draw()
            plt.show(block=False)
        return self._get_target_from_img(img)
Example #10
0
    def get_table(self):
        a = self.get_table_offset()
        b = get_position('table top left', a, 'table bottom right')
        w = b[0]-a[0]
        h = b[1]-a[1]
        x,y = a
        img = get_screenshot(x,y,w,h,grayscale=False)
        table = table_reader.TableReader(img, debug=self._debug).get_table()

        if self._debug:
            # same the images for debug and write tests for different statuses
            # import time
            # cv2.imwrite('%d_table.jpg' % (time.time()*10000,), img)
            # plt.imshow(img)
            # plt.draw()
            # plt.show(block=False)
            pass

        return table
Example #11
0
    def __init__(self):
        super(GameInspector, self).__init__(name='GameInspector')
        self.main_layout = BoxLayout(orientation='vertical')
        self.first_row = BoxLayout(orientation='horizontal')
        self.second_row = BoxLayout(orientation='horizontal')
        self.main_layout.add_widget(self.first_row)
        self.main_layout.add_widget(self.second_row)

        self.fps_plot = fps_plot.get_fps_plot()
        self.video = video_player.get_video_player()
        self.screenshot = screenshot.get_screenshot()
        self.config = options.get_config(self.fps_plot, self.video,
                                         self.screenshot)

        self.first_row.add_widget(self.config)
        self.first_row.add_widget(self.fps_plot)
        self.second_row.add_widget(self.video)
        self.second_row.add_widget(self.screenshot)

        self.add_widget(self.main_layout)
Example #12
0
def get_score(website):
    # get screenshot of suspect website and convert to numpy array
    screenshot_binary_string = get_screenshot(website)
    ss_array = string_to_image(screenshot_binary_string)
    # get html score, whois response and google page rank
    html_score, whois_response, rank_checker_response = get_html_score(website)
    registration_date = re.findall(
        r'Registered On:</div><div class="df-value">([^<]+)</div>',
        whois_response.text)
    registrar = re.findall(
        r'Registrar:</div><div class="df-value">([^<]+)</div>',
        whois_response.text)
    update_date = re.findall(
        r'Updated On:</div><div class="df-value">([^<]+)</div>',
        whois_response.text)
    state = re.findall(r'State:</div><div class="df-value">([^<]+)</div>',
                       whois_response.text)
    country = re.findall(r'Country:</div><div class="df-value">([^<]+)</div>',
                         whois_response.text)

    # save image for matlab
    cv2.imwrite("imgs/screenshot.png", ss_array)
    # path_for_matlab = os.path.join(os.getcwd(), "imgs\screenshot.png")
    path_for_matlab = os.path.join(os.getcwd(),
                                   os.path.normpath("imgs/screenshot.png"))
    # get CV score
    blur_score = get_blur_score(path_for_matlab)  # score for blur
    logo_score = get_logo_score(path_for_matlab)  # score for logo found
    final_score_dict = {
        "prob_ok": str(html_score[0][0]),
        "prob_phish": str(html_score[0][1]),
        "registrar": registrar,
        "registered_on": registration_date,
        "expiration_date": update_date,
        "state": state,
        "country": country,
        "blurriness": str(blur_score),
        "prob_found_logo": str(logo_score)
    }
    return final_score_dict
Example #13
0
def get_score(website):
    # put code for capture site here
    # website_screenshot = #get site sc here and load it into matlab

    ss = get_screenshot(website)
    ss_array = string_to_image(ss)
    html_score, whois_response, rank_checker_response = get_html_score(website)
    registration_date = re.findall(
        r'Registered On:</div><div class="df-value">([^<]+)</div>',
        whois_response.text)
    registrar = re.findall(
        r'Registrar:</div><div class="df-value">([^<]+)</div>',
        whois_response.text)
    update_date = re.findall(
        r'Updated On:</div><div class="df-value">([^<]+)</div>',
        whois_response.text)
    state = re.findall(r'State:</div><div class="df-value">([^<]+)</div>',
                       whois_response.text)
    country = re.findall(r'Country:</div><div class="df-value">([^<]+)</div>',
                         whois_response.text)

    # save image for matlab
    cv2.imwrite("imgs/screenshot.png", ss_array)
    path_for_matlab = os.path.join(os.getcwd(), "imgs\screenshot.png")
    blur_score = get_blur_score(path_for_matlab)  # score for blur
    found_score = get_found_score(path_for_matlab)  # score for found logo

    final_score_dict = {
        "prob_ok": str(html_score[0][0]),
        "prob_phish": str(html_score[0][1]),
        "registrar": registrar,
        "registered_on": registration_date,
        "expiration_date": update_date,
        "state": state,
        "country": country,
        "blurriness": str(blur_score),
        "prob_found_logo": str(found_score)
    }

    return final_score_dict
Example #14
0
import time
import random

import numpy as np
import Image
import ImageFilter

import screenshot
import screen_parser
import mouse
from ai_greedy import AI

if __name__ == "__main__":
    image = screenshot.get_screenshot()
    #image = Image.open('e0.jpg')
    sp = screen_parser.ScreenParser()
    print(np.array(sp.cells).T)
    ai = AI()
    while 1:
        image = screenshot.get_screenshot()
        image = image.resize((image.size[0]/2, image.size[1]/2))
        image = image.filter(ImageFilter.SMOOTH)
        image = image.resize((image.size[0]*2, image.size[1]*2))
        board = sp.parse(image)
        if random.random() < .5:
            bad_spots = len([x for x in np.array(board).ravel() if x == None or x == 'w'])
            if bad_spots > 30:
                mouse.move_click((490,575))
                time.sleep(.1)
                mouse.move_click((910,298))
                time.sleep(.5)
Example #15
0
def screenshot(request, generation, orgname):
    gdir = 'gen-%s' % generation
    gdir = os.path.join(BASEDIR, gdir)
    img = get_screenshot(gdir, orgname)
    return HttpResponse(img, mimetype="image/png")
Example #16
0
 def input_newcontactname(self, driver, newcontactname):
     self.find_element(*self.newcontactname_loc).send_keys(newcontactname)
     mylogger.info("input contact name")
     get_screenshot(driver, "input_newcontactname")
Example #17
0
 def get_location_from_entire_screen(self, search_item):
     img = get_screenshot()
     pos = self._get_location_from_img(img, search_item)
     self._locations[search_item] = pos
     return pos