def fill_html(link: str): """Заполняет html файл по ссылке""" if keyboard.is_pressed('ctrl'): exit() web_open(link) with open(cords_path, 'r', encoding='UTF-8') as file: json_file = load(file) assert json_file.get('HTML') is not None, 'Вначале запустите __init__.py' assert json_file.get('TAB') is not None, 'Вначале запустите __init__.py' assert json_file.get('PYCHARM') is not None, 'Вначале запустите __init__.py' assert json_file.get('YANDEX') is not None, 'Вначале запустите __init__.py' sleep(4) # ждём загрузки страницы keyboard.press_and_release('ctrl+shift+i') sleep(1) # ждём загрузки html pyautogui.moveTo(*json_file['HTML']) pyautogui.click(button='left') sleep(0.5) keyboard.press_and_release('ctrl+c') # копируем html pyautogui.moveTo(*json_file['TAB']) pyautogui.click(button='left') # закрываем вкладку pyautogui.moveTo(*json_file['PYCHARM']) pyautogui.click(button='left') # открываем PyCharm sleep(0.5) pyautogui.moveTo(*json_file['YANDEX']) pyautogui.click(button='left') keyboard.press_and_release('ctrl+A') keyboard.press_and_release('backspace') keyboard.press_and_release('ctrl+v') sleep(0.5) keyboard.press_and_release('ctrl+s') # записываем всё в файл и сохраняем sleep(2)
def launch_rust(): # web_open('http://playrust.com') web_open('steam://run/252490') found_rust = False while not found_rust: found_rust = does_window_exist('Rust Configuration') print('Rust Configuration is open') pyautogui.press('enter')
def __init__(self): self.create_cartoons_txt() cartoons_list = self.get_cartoons_list() if cartoons_list: web_open(random.choice(cartoons_list)) else: os.startfile("cartoons_list.txt")
def get_download_url(self, token: client.Token, Format, autoraise=False): '''Returns a time-limited HTTPS link to an output file of the specified format.<br> Scope - data:read<br><br> Note: The link will expire 30 days after the date of processing completion.''' checkScopes(token, "data:read") params = {"format": Format} endpoint_url = RECAP_API + "/photoscene/{phId}".format(phId=self.id) r = requests.get(endpoint_url, headers=token.get_header, params=params).json() if autoraise: web_open(r["Photoscene"]["scenelink"], new=0, autoraise=autoraise) print(r["Photoscene"]["scenelink"])
def display(self): self.setTabEnabled(0, False) self.text.setText('') self.setCurrentIndex(1) if not mac.FOUNDED: self.text.insertPlainText(u'未经检测到以太网网卡\n') else: self.text.insertPlainText('本机mac为: ' + mac.mac + '\n') self.text.insertPlainText('尝试进行登陆......\n') result = spider.login(self.usr_edit.text(), self.pwd_edit.text(), self.sc_edit.text()) if result == 1: self.text.insertPlainText('图片验证码有误。\n') elif result == 2: self.text.insertPlainText('不存在此校园卡号:' + self.usr_edit.text() + '\n') elif result == 3: self.text.insertPlainText('账号或密码错误。\n') elif result == 4: self.text.insertPlainText('网络未开户。请登陆自助营业厅进行开户\n') time.sleep(5) web_open("https://ip.jlu.edu.cn/pay/") else: ip, mac_address = result mac_ = ''.join(mac.mac.split("-")) if mac_ != mac_address: self.text.insertPlainText('mac地址不符。尝试修改...\n') self.text.insertPlainText(spider.modify_mac(ip, mac_)) gateway = ip.split('.') gateway[3] = '254' gateway = '.'.join(gateway) self.text.insertPlainText('尝试设置ip地址为: %s' % ip + '\n') self.text.insertPlainText(' 子网掩码为: %s' % '255.255.255.0\n') self.text.insertPlainText(' 默认网关为: %s' % gateway + '\n') self.text.insertPlainText( mac.execute('netsh interface ipv4 set address ' 'name="%s" ' 'source=static ' 'addr=%s ' 'mask=255.255.255.0 ' 'gateway=%s' % (mac.FOUNDED, ip, gateway))) self.text.insertPlainText('尝试设置默认DNS为: 10.10.10.10(时间可能稍长请稍等)\n') self.text.insertPlainText( mac.execute('netsh interface ipv4 add dns ' 'name="%s" ' 'address=10.10.10.10 ' 'index=1' % mac.FOUNDED)) self.text.insertPlainText('尝试设置默认DNS为: 10.10.10.10(时间可能稍长请稍等)\n') self.text.insertPlainText('程序将在10秒后自动关闭。\n') time.sleep(10) QCoreApplication.quit()
def check_updates(self): def update_msg_box(): msg_box = QMessageBox(self) msg_box.setWindowTitle("There is a new version available.") msg_box.setText( "Do you want to open the latest release in your browser?") msg_box.setStandardButtons(QMessageBox.Ok | QMessageBox.Ignore) msg_box.setDefaultButton(QMessageBox.Ok) answer = msg_box.exec_() self.get_msg_box_answer.emit(answer) def check_remote(): try: response = get( "https://api.github.com/repos/GandaG/fomod-validator/releases", timeout=1) if response.status_code == codes.ok and response.json( )[0]["tag_name"][1:] > __version__: self.load_msg_box.emit() except (Timeout, ConnectionError): pass self.load_msg_box.connect(update_msg_box) self.close_app.connect(self.close) self.get_msg_box_answer.connect(lambda answer: self.close_app.emit() if answer == QMessageBox.Ok else None) self.get_msg_box_answer.connect(lambda answer: web_open( "https://github.com/GandaG/fomod-validator/releases/latest") if answer == QMessageBox.Ok else None) self.get_msg_box_answer.connect(lambda answer: exit() if answer == QMessageBox.Ok else None) Thread(target=check_remote).start()
def init(self): self.opacity_label = QLabel('透明度 ', self) self.opacity_label.move(30, 30) self.opacity_label.setFixedSize(80, 20) self.height_label = QLabel('高度 ', self) self.height_label.move(35, 70) self.height_label.setFixedSize(90, 20) self.opacity_slider = QSlider(Qt.Horizontal, self) self.opacity_slider.setFixedSize(100, 20) self.opacity_slider.setMinimum(1) self.opacity_slider.setMaximum(10) self.opacity_slider.move(10, 10) self.opacity_slider.valueChanged[int].connect(self.change_opacity) self.height_slider = QSlider(Qt.Horizontal, self) self.height_slider.setFixedSize(100, 20) self.height_slider.setMinimum(150) self.height_slider.setMaximum(900) self.height_slider.move(10, 50) self.height_slider.valueChanged[int].connect(self.change_height) self.save_button = QPushButton('保存', self) self.save_button.clicked.connect(self.save_json) self.save_button.move(130, 15) self.about_button = QPushButton('关于', self) self.about_button.clicked.connect(lambda: web_open( 'https://github.com/yunyuyuan/invoker/tree/master/pyqt/日程')) self.about_button.move(130, 55) self.load_json() self.set_data()
def get_pkce_credentials(self, print_auth_url: bool = False) -> OAuthCredentials: """ Try to get an OAuth access token and its associated metadata. :param print_auth_url: Whether to print the auth url to the console instead of opening it. :return: OAuth credentials and some associated metadata to check if they have expired. """ code_verifier, code_challenge = generate_pkce_pair() state = "".join(choice(ascii_lowercase) for i in range(10)) authorization_url = (f"https://{self.auth_domain}/v1/authorize?" f"scope={self.scope}&" f"response_type=code&" f"response_mode=query&" f"client_id={self.client_id}&" f"code_challenge={code_challenge}&" f"state={state}&" f"code_challenge_method=S256&" f"redirect_uri={self.redirect_uri}") httpd = _RedirectServer( ("", self.redirect_port), _Handler, self.redirect_uri, self.auth_domain, self.client_id, code_verifier, ) if print_auth_url: print( "Please open the below url in a browser and sign in if necessary" ) print(authorization_url) else: web_open(authorization_url) httpd.handle_request() if not httpd.pkce_credentials: raise ValueError( "Could not retrieve Okta credentials to talk to Kanopy with. " "Please sign out of Okta in your browser and try runnning this script again" ) return httpd.pkce_credentials
def subroutine_error_popup(subroutine, error, message): """Display a popup for errors in subroutines. Parameters ---------- subroutine : str The name of the subroutine causing the error. error : Exception or str The error caused by the subroutine. message : str The additional error message to be displayed. """ # ===== Error Window Definition ===== # error_layout = [ [sg.Text(an.ERROR_INTRO.format(subroutine))], [sg.Text(message)], [sg.Text(an.ERROR_OUTRO, text_color='red')], [sg.Text('', font='default 10 italic', key='-COPY_DONE-', size=(40, 1))], [sg.Button('Copy to clipboard', key='-CLIPBOARD-'), sg.Button('Send as e-mail', key='-EMAIL-', bind_return_key=True, focus=True), sg.Exit('Close', key='close')] ] error_window = sg.Window('Subroutine Error', error_layout, modal=True) # ===== Handle Button Actions ===== # while True: event_error, values_error = error_window.Read() if event_error in [sg.WIN_CLOSED, 'close']: error_window.close() break # Copy trace to clipboard elif event_error == '-CLIPBOARD-': sg.clipboard_set('Version: {}\n\n{}\n\n{}'.format(__version__, str(error), message)) error_window['-COPY_DONE-']('(Error message copied to clipboard.)') # Compose bug report as e-mail elif event_error == '-EMAIL-': query = {'subject': f'Error in {subroutine}', 'body': 'Version:\n{}\n\nMessage:\n{}\n\nComment:\n'.format(__version__, message)} web_open(f'mailto:{__email__}?{urlencode(query, quote_via=quote)}', new=1)
def main(): logger.info('Taking user input...') user_input = input('Enter search criteria: ') logger.info(f'Searching for {user_input}') articles = api.search(user_input) print(f'Found {len(articles)} articles') id_to_article_dict = {} for r in articles: id_to_article_dict[r.id] = r print(f"[{r.id}] {r.title}: {r.category}") print("*" * 20) user_input = input( 'For which article do you need more information [q for quit]: ') if user_input != 'q': web_open("http://talkpython.fm" + id_to_article_dict[int(user_input)].url, new=2) logger.info('End of execution')
def open_website(link): try: print("Opening link: " + link) web_open(link) except Exception as e: print("Error Occurred:\n {}".format(e))
if search_mode == "id": cprint("Please enter target item ID.", "cyan") item_id = input("> ") elif search_mode == "name": cprint("Please enter exact item name (as seen in mobile_stock.json).", "cyan") item_name = input("> ") if search_mode == "id": while True: mobile_stock = urlopen( "https://www.supremenewyork.com/mobile_stock.json") stock = mobile_stock.read().decode() if item_id in stock: cprint("Found! Opening shop webpage.") web_open("https://www.supremenewyork.com/shop/%s" % item_id) sys_exit() print("Not found, retrying...") sleep(0.1) elif search_mode == "name": while True: mobile_stock = urlopen( "https://www.supremenewyork.com/mobile_stock.json") stock = mobile_stock.read().decode() stock_json = json_loads(stock) products = stock_json["products_and_categories"] for category in products: for item in products[category]: if item["name"] == item_name: cprint("Found! Opening shop webpage.") web_open("https://www.supremenewyork.com/shop/%s" %
def build_main_book(self): """ Функция отрисовки главной вкладки программы :return: ничего """ left_frame = ttk.Frame(self.main_book, borderwidth=2, relief='groove', padding=10) left_frame.grid(row=0, column=0, sticky='SN', padx=10) right_frame = ttk.Frame(self.main_book, padding=10, borderwidth=2, relief='groove') right_frame.grid(row=0, column=1, sticky='N') label_FPVK = ttk.Label(left_frame, image=self.app_ico['348x348_FPVK'], cursor='heart') button_update = ttk.Button(left_frame, text='Проверить обновления', cursor='exchange') button_authorization = ttk.Button(left_frame, text='Авторизоваться') label_version = ttk.Label(left_frame, text=f'Version: {VERSION}') label_FH = ttk.Label(left_frame, image=self.app_ico['148x30_FH'], cursor='heart', justify='center') label_name_app = ttk.Label(right_frame, text=APP_NAME, justify='center', font=fonts.H1_FONT, foreground='#A3DAFF') label_description = ttk.Label(right_frame, text=LABEL_DESCRIPTION, justify='center', font=fonts.H5_FONT, wraplength=750) label_help_description = ttk.Label(right_frame, text=LABEL_HELP_DESCRIPTION, justify='center', font=fonts.H6_FONT, wraplength=750) label_help = ttk.Label(right_frame, text=LABEL_PLEASE_HELP_BOT, justify='center', font=fonts.H6_FONT, wraplength=750, foreground='red') btn_open_community_app = ttk.Button( right_frame, text='Группа FPVK', cursor='star', command=lambda: web_open(APP_COMMUNITY)) btn_open_bot_app = ttk.Button(right_frame, text='VK бот FPVK', cursor='star', command=lambda: web_open(VK_BOT_APP)) label_version.grid(row=0, column=0, pady=5) label_FPVK.grid(row=1, rowspan=2, column=0) button_authorization.grid(row=4, column=0, pady=10) button_update.grid(row=5, column=0) label_FH.grid(row=6, column=0, pady=10) label_name_app.grid(row=0, column=0, pady=10, columnspan=2) label_description.grid(row=1, column=0, columnspan=2) label_help_description.grid(row=2, column=0, pady=10, columnspan=2) label_help.grid(row=3, column=0, columnspan=2, pady=15) btn_open_community_app.grid(row=4, column=0, pady=15, sticky='SWE') btn_open_bot_app.grid(row=4, column=1, pady=15, sticky='SWE') self.main_book.columnconfigure(0, weight=1) self.main_book.columnconfigure(1, weight=3) left_frame.columnconfigure(0, weight=1) right_frame.columnconfigure(0, weight=1) right_frame.columnconfigure(1, weight=1) self.main_book.rowconfigure(0, weight=1) label_FPVK.bind('<Button-1>', lambda event: web_open(APP_PAGE)) label_FH.bind('<Button-1>', lambda event: web_open(AUTHOR_PAGE)) button_authorization.bind( '<Button-1>', lambda event: ConfigureVkApi(ignore_existing_token=True)) button_update.bind( '<Button-1>', lambda event: self.function_windows.check_update(call=True, os_name=self.OS))
def abrir_link(url): web_open(url)
def scan_for_style(self, item_id, category): item_info = urlopen("https://www.supremenewyork.com/shop/%s.json" % item_id).read().decode() item = json_loads(item_info) for style in item["styles"]: for style_id in self.target_style_ids: if style["id"] == style_id: for size in style["sizes"]: for size_id in self.target_size_ids: if size["id"] == size_id: print("Found matching style") self.matches += 1 if self.matches == self.target_matches: web_open( "https://www.supremenewyork.com/shop/%s/%s/%s?turbocop_size_id=%s&checkout" % (category.lower(), item_id, style_id, size_id)) elif self.matches < self.target_matches: web_open( "https://www.supremenewyork.com/shop/%s/%s/%s?turbocop_size_id=%s" % (category.lower(), item_id, style_id, size_id)) for size_name in self.target_size_names: if size["name"] == size_name: print("Found matching style") self.matches += 1 if self.matches == self.target_matches: web_open( "https://www.supremenewyork.com/shop/%s/%s/%s?turbocop_size_id=%s&checkout" % (category.lower(), item_id, style_id, size["id"])) elif self.matches < self.target_matches: web_open( "https://www.supremenewyork.com/shop/%s/%s/%s?turbocop_size_id=%s" % (category.lower(), item_id, style_id, size["id"])) for style_name in self.target_style_names: if style["name"] == style_name: for size in style["sizes"]: for size_id in self.target_size_ids: if size["id"] == size_id: print("Found matching style") self.matches += 1 if self.matches == self.target_matches: web_open( "https://www.supremenewyork.com/shop/%s/%s/%s?turbocop_size_id=%s&checkout" % (category.lower(), item_id, style["id"], size_id)) elif self.matches < self.target_matches: web_open( "https://www.supremenewyork.com/shop/%s/%s/%s?turbocop_size_id=%s" % (category.lower(), item_id, style["id"], size_id)) for size_name in self.target_size_names: if size["name"] == size_name: print("Found matching style") self.matches += 1 if self.matches == self.target_matches: web_open( "https://www.supremenewyork.com/shop/%s/%s/%s?turbocop_size_id=%s&checkout" % (category.lower(), item_id, style["id"], size["id"])) elif self.matches < self.target_matches: web_open( "https://www.supremenewyork.com/shop/%s/%s/%s?turbocop_size_id=%s" % (category.lower(), item_id, style["id"], size["id"]))
def openwebsite(): web_open('https://supreme-gamers.com')
def open_website(link): try: print("Opening....: " + link) web_open(link) except Exception as e: print("Error !!:\n {}".format(e))
window_about = sg.Window('About …', layout_about, modal=True) # ····· Handle Citation Exports and Link Clicks ····· # while True: event_about, values_about = window_about.read() if event_about in [sg.WIN_CLOSED, 'Done']: window_about.close() break elif event_about == '-CITATION_EXPORT-': if values_about['-FORMAT_RIS-']: sp.run([doc_handler(), os.path.join('data', 'citation.ris')], **sp_args()) else: sp.run([doc_handler(), os.path.join('data', 'citation.bib')], **sp_args()) elif event_about.startswith('-LINK_'): web_open(an.LINKS[int(event_about.removeprefix('-LINK_').removesuffix('-'))], new=1) # ----- Start Calculations ----- # else: # ····· Check 2D PDF Input Values for Errors ····· # error_message = '' if event_main == '2d_okay': if not values_main['2d_file_in']: error_message += '\nNo input file is given.' elif not file_exists(values_main['2d_file_in']): error_message += '\nInput file does not exist.' if values_main['2d_output_opp_err'] or values_main['2d_output_pdf_err']: if not values_main['2d_file_err']: error_message += '\nNo error file is given.' elif not file_exists(values_main['2d_file_err']):