def login(): code_verifier, code_challenge = oauth_pkce(s256) login_params = { "code_challenge": code_challenge, "code_challenge_method": "S256", "client": "pixiv-android", } open_url(f"{LOGIN_URL}?{urlencode(login_params)}") try: code = input("code: ").strip() except (EOFError, KeyboardInterrupt): return response = requests.post(AUTH_TOKEN_URL, data={ "client_id": CLIENT_ID, "client_secret": CLIENT_SECRET, "code": code, "code_verifier": code_verifier, "grant_type": "authorization_code", "include_policy": "true", "redirect_uri": REDIRECT_URI, }, headers={"User-Agent": USER_AGENT}, proxies={'https': 'http://127.0.0.1:1087'}) print_auth_token_response(response)
def dog(transformation, open): cloudinary._config.cloud_name = "demo" res = cloudinary_url('dog', raw_transformation=transformation, resource_type="video")[0] print(res) if open: open_url(res)
def alarm(json: dict): if check_reminder(json): speak("Comme prévu, je viens te réveiller !") open_url(json['url']) r = get_all_reminders() r.pop(int(json['id'])) rewrite_reminders_file(r)
def login(): ''' open browser to login and get the code :return access token and refresh token''' code_verifier, code_challenge = oauth_pkce(s256) login_params = { "code_challenge": code_challenge, "code_challenge_method": "S256", "client": "pixiv-android", } print(Style.BRIGHT + Fore.YELLOW + "Instructions: " + Style.RESET_ALL) print( "1. This will open a new browser to login to Pixiv site to get the code." ) print( "1b. In case the browser will not open, or you are using an headless server, use this link: " + f"{LOGIN_URL}?{urlencode(login_params)}") print("2. Open dev console " + Fore.YELLOW + "(F12)" + Style.RESET_ALL + " and switch to network tab." + Style.RESET_ALL) print("3. Enable persistent logging (" + Fore.YELLOW + "\"Preserve log\"" + Style.RESET_ALL + "). " + Style.RESET_ALL) print("4. Type into the filter field: '" + Fore.YELLOW + "callback?" + Style.RESET_ALL + "'." + Style.RESET_ALL) print("5. Proceed with Pixiv login.") print( "6. After logging in you should see a blank page and request that looks like this:" + Style.RESET_ALL) print( " 'https://app-api.pixiv.net/web/v1/users/auth/pixiv/callback?state=...&" + Fore.YELLOW + "code=..." + Style.RESET_ALL + "'" + Style.RESET_ALL) print("7. Copy value of the " + Fore.YELLOW + "code param" + Style.RESET_ALL + " into the prompt and hit the Enter key.") input("Press enter when you ready.") open_url(f"{LOGIN_URL}?{urlencode(login_params)}") try: code = input("code: ").strip() except (EOFError, KeyboardInterrupt): return response = requests.post( AUTH_TOKEN_URL, data={ "client_id": CLIENT_ID, "client_secret": CLIENT_SECRET, "code": code, "code_verifier": code_verifier, "grant_type": "authorization_code", "include_policy": "true", "redirect_uri": REDIRECT_URI, }, headers={"User-Agent": USER_AGENT}, ) return response
def _handle_sample_command(source, transformation=None, open_in_browser=False, resource_type="image"): cloudinary.config(cloud_name="demo", secure_distribution=None, cname=None) res = cloudinary_url(source, raw_transformation=transformation, resource_type=resource_type)[0] print(res) if open_in_browser: open_url(res)
def open_pixiv_login(): code_verifier, code_challenge = oauth_pkce(s256) login_params = { "code_challenge": code_challenge, "code_challenge_method": "S256", "client": "pixiv-android", } url = f"{LOGIN_URL}?{urlencode(login_params)}" print(url) open_url(url) return code_verifier
def url(public_id, transformation, resource_type, type, open, sign): if type == "authenticated" or resource_type == "url2png": sign = True elif type == "list": public_id += ".json" res = cld_url(public_id, resource_type=resource_type, raw_transformation=transformation, type=type, sign_url=sign)[0] print(res) if open: open_url(res)
def parse_args(args): "parse arguments" if len(args) == 0: url = "https://github.com/Charlie-Sumorok/PMM" else: package_manager_name = args[0] raw_repo_url = "https://raw.githubusercontent.com/Charlie-Sumorok/PMM" branch = "main" path = "package-managers/data.json" data_url = f"{raw_repo_url}/{branch}/{path}" package_manager_data = requests.get(data_url).json() package_manager = package_manager_data[package_manager_name] urls = package_manager["urls"] url = urls["standard"] open_url(url)
def url(public_id, transformation, resource_type, delivery_type, open_in_browser, sign): if delivery_type == "authenticated" or resource_type == "url2png": sign = True elif delivery_type == "list": public_id += ".json" res = cloudinary_url(public_id, resource_type=resource_type, raw_transformation=transformation, type=delivery_type, sign_url=sign)[0] echo(res) if open_in_browser: open_url(res)
def more_info(stdscr, current_option): URL = "https://github.com/afgalvan" options = ("Créditos", "Github", "Licencia", "Volver al menú") current_option = menu_displayer(stdscr, options, "MÁS INFORMACIÓN", current_option) if current_option == 0: show_credits(stdscr) elif current_option == 1: open_url(URL) elif current_option == 2: show_license(stdscr) else: stdscr.clear() return 0 more_info(stdscr, current_option)
def _preview(self): "Save a file" "" path = fd.asksaveasfilename(title='Save for previewing', parent=self.root, filetypes=self.save_filetypes) try: file = open(path, mode='w') file.write(self.main_text_input.get(1.0, tk.END)) file.close() self.root.title('HTML | ' + path) open_url('file://' + path) except: mbox.showerror( 'Error Saving File', 'There was an error saving your file. Please try a different directory.', parent=self.root)
def _Texty_settings(self): """Texty Settings""" self.set_root = tk.Tk() self.set_root.title('Texty | Settings') self.sr_theme = ttk.Style(self.set_root) self.sr_theme.theme_use(self.root_theme.theme_use()) os_values = ['clam', 'classic', 'default', 'alt'] os_values.sort() win_values = [ 'clam', 'classic', 'default', 'alt', 'xpnative', 'winnative' ] win_values.sort() linux_values = ['clam', 'classic', 'default', 'alt'] linux_values.sort() mac_values = ['clam', 'classic', 'default', 'alt', 'aqua'] mac_values.sort() # Do some O.S. checking here if sys.platform == 'darwin': # mac OS self.tc = ttk.Combobox(self.set_root, values=mac_values) elif sys.platform == 'linux': # Linux self.tc = ttk.Combobox(self.set_root, values=linux_values) elif sys.platform == 'win32': # Windows self.tc = ttk.Combobox(self.set_root, values=win_values.sort()) else: # O.S. not recognized self.tc = ttk.Combobox(self.set_root, values=os_values) self.tc_l = ttk.Label(self.set_root, text='App Theme: ') self.tc_l.pack() self.tc.pack() self.c_l = ttk.Label(self.set_root, text='———Credits———') self.c_l.pack() self.v_l = ttk.Label(self.set_root, text='JK Texty Version: ' + self.Texty_version) self.v_l.pack() self.a_l = ttk.Label(self.set_root, text='JK Texty Author: ' + self.Texty_author) self.a_l.pack() self.l_l = ttk.Label(self.set_root, text='JK Texty License: ' + self.Texty_license) self.l_l.pack() self.w_l = ttk.Label(self.set_root, text='JK Texty Website: ') self.w_l.pack() self.w_b = ttk.Button(self.set_root, text='JK Texty Website', command=lambda: open_url(self.Texty_website)) self.w_b.pack() self.o_l = ttk.Label(self.set_root, text='JK Texty O.S. version: ' + self.Texty_os) self.o_l.pack() self.s_b = ttk.Button(self.set_root, text='Save Changes', command=lambda: self.save_changes()) self.s_b.pack()
def main(): print("Начинается новый час образования!") sleep(60) s = check_subject() sleep(3600) done_hour(s) names = [process.name() for process in psutil.process_iter()] open_url("https://vk.com/audios358433008") sleep(600) if not "browser.exe" in names: system("taskkill /f /im browser.exe" ) # If browser was opened before , do not close it startfile("work.mp3") sleep(10) try: system("taskkill /f /im AIMP.exe") except: pass main()
def admin(params, optional_parameter, optional_parameter_parsed, ls, save, doc): if doc: open_url("https://cloudinary.com/documentation/admin_api") exit(0) if ls or len(params) < 1: print(get_help(api)) exit(0) try: func = api.__dict__[params[0]] if not callable(func): raise Exception(F_FAIL("{} is not callable.".format(func))) exit(1) except: print(F_FAIL("Method {} does not exist in the Admin API.".format(params[0]))) exit(1) parameters, options = parse_args_kwargs(func, params[1:]) if len(params) > 1 else ([], {}) res = func(*parameters, **{ **options, **{k: v for k, v in optional_parameter}, **{k: parse_option_value(v) for k, v in optional_parameter_parsed}, }) log(res) if save: write_out(res, save)
def search(query, with_field, sort_by, aggregate, max_results, next_cursor, auto_paginate, force, filter_fields, json, csv, doc): if doc: return open_url("https://cloudinary.com/documentation/search_api") fields_to_keep = [] if filter_fields: for f in list(filter_fields): if "," in f: fields_to_keep += f.split(",") else: fields_to_keep.append(f) fields_to_keep = tuple(fields_to_keep) + with_field expression = cloudinary.search.Search().expression(" ".join(query)) if auto_paginate: max_results = DEFAULT_MAX_RESULTS if with_field: for f in with_field: expression.with_field(f) if sort_by: expression.sort_by(*sort_by) if aggregate: expression.aggregate(aggregate) if next_cursor: expression.next_cursor(next_cursor) expression.max_results(max_results) res = execute_single_request(expression, fields_to_keep) if auto_paginate: res = handle_auto_pagination(res, expression, force, fields_to_keep) print_json(res) if json: write_json_to_file(res['resources'], json) logger.info(f"Saved search JSON to '{json}' file") if csv: write_json_list_to_csv(res['resources'], csv, fields_to_keep) logger.info(f"Saved search to '{csv}.csv' file")
def handle_api_command(params, optional_parameter, optional_parameter_parsed, ls, save, doc, doc_url, api_instance, api_name): """ Used by Admin and Upload API commands """ if doc: return open_url(doc_url) if ls or len(params) < 1: return print_help(api_instance) try: func = api_instance.__dict__[params[0]] if not callable(func): raise Exception(f"{func} is not callable") except Exception: raise Exception( f"Method {params[0]} does not exist in the {api_name.capitalize()} API." ) args, kwargs = parse_args_kwargs( func, params[1:]) if len(params) > 1 else ([], {}) res = func( *args, **{ **kwargs, **{k: v for k, v in optional_parameter}, **{k: parse_option_value(v) for k, v in optional_parameter_parsed}, }) print_json(res) if save: write_json_to_file(res, save)
from urllib.request import pathname2url as pathtourl def log_info(text): print('wrdplus:', text) # CWD: /wrdplus/ filepaths = { "redirect_page": "release/redirect.html", "built_script": "build/wrdplus.user.js", "dest_script": "release/wrdplus.user.js", "meta_data": "release/wrdplus.meta.js", } if path.exists(filepaths["meta_data"]): log_info('Launching build...') system("start /wait cmd /c yarn build") log_info('Appending metadata to source-code...') if (path.exists(filepaths.get("built_script"))): with (open(filepaths.get("meta_data"), encoding='utf8')) as mtfile: meta = mtfile.read() with (open(filepaths.get("built_script"), encoding='utf8')) as scriptfile: script = scriptfile.read() with (open(filepaths.get("dest_script"), "w+", encoding='utf8')) as scriptfile: scriptfile.write(meta+'\n'+script) if input("Do you wanna install it? ") in 'Yy': open_url('file:{}'.format(pathtourl(path.abspath(filepaths.get("redirect_page"))))) else: log_info("Unable to find WRD+ files.")
def __paper_selected(self, next_row, unused1, unused2, unused3): open_url(self._papers_displayed[next_row]['url'])
def _panelReferencePathClicked(self, reference_path): module, class_name = import_module_from_hive_path(reference_path) open_url(module.__file__)
def setup(self): """Setup Texty""" # Setup the main window self.root = tk.Tk() self.root.title('Texty | New File') # Setup the theme for the main window self.root_theme = ttk.Style(self.root) self.root_theme.theme_use('clam') Texty.root_theme = 'clam' # Setup menubar self.menubar = tk.Menu(self.root) ### Texty menu self.Texty_menu = tk.Menu(self.menubar) self.Texty_menu.add_command(label="About", command=lambda: About_Texty()) self.Texty_menu.add_command(label="Settings", command=lambda: self._Texty_settings()) self.Texty_menu.add_command(label="Check for updates", command=lambda: self._check_for_updates()) self.Texty_menu.add_command(label="Quit", command=lambda: self._quit()) ### File menu self.file_menu = tk.Menu(self.menubar) self.file_menu.add_command(label="New", command=lambda: Texty()) self.file_menu.add_command(label="Save", command=lambda: self._save()) self.file_menu.add_command(label="Open", command=lambda: self._open()) ### Edit menu self.edit_menu = tk.Menu(self.menubar) ### Mode menu self.mode_menu = tk.Menu(self.menubar) ### Help menu self.help_menu = tk.Menu(self.menubar) self.help_menu.add_command( label="What's new in 1.0.0", command=lambda: open_url( "https://github.com/Jackkillian/JK-Texty/blob/master/Newest-Version/What's%20New.md" )) self.help_menu.add_command( label="Texty Help", command=lambda: open_url( 'https://github.com/Jackkillian/JK-Texty/wiki')) ### Rest of menubar self.menubar.add_cascade(label='Texty', menu=self.Texty_menu) self.menubar.add_cascade(label="File", menu=self.file_menu) self.menubar.add_cascade(label="Edit", menu=self.edit_menu) self.menubar.add_cascade(label="Mode", menu=self.mode_menu) self.menubar.add_cascade(label="Help", menu=self.help_menu) self.root.config(menu=self.menubar) # Define needed variables self.Texty_version = '1.0.0' self.Texty_author = 'Jackkillian, a.k.a. Jack Freund' self.Texty_license = 'MIT License' self.Texty_website = 'https://sites.google.com/view/jk-texty-website/home' self.Texty_os = 'Source Code' self.toolbar_status = 'same' self.open_filetypes = (('All Files', '.*'), ('AppleScript', '.scpt'), ('C', '.c'), ('C++', '.cc'), ('HTML', '.html'), ('JK Dashboard Extension', '.jkbdext'), ('JK PyApp', '.py'), ('JavaScript', '.js'), ('Markdown', '.md'), ('Python', '.py'), ('Python GUI App', '.py'), ('Plain Text', '.txt'), ('Rich Text', '.rtf'), ('Ruby', '.rb')) self.save_filetypes = (('AppleScript', '.scpt'), ('C', '.c'), ('C++', '.cc'), ('HTML', '.html'), ('JK Dashboard Extension', '.jkbdext'), ('JK PyApp', '.py'), ('JavaScript', '.js'), ('Markdown', '.md'), ('Python', '.py'), ('Python GUI App', '.py'), ('Plain Text', '.txt'), ('Rich Text', '.rtf'), ('Ruby', '.rb')) self.mode_list = [ 'AppleScript', 'C', 'C++', 'HTML', 'JavaScript', 'JK Dashboard Extension', 'JK PyApp', 'Markdown', 'Python', 'Python GUI App', 'Plain Text', 'Rich Text', 'Ruby' ]
if (github_data is not None): x = simple_ver.compare(github_data.tag_name, index_data["version"]) if x == 0: print("Github version is equal to your version") elif x == 1: print("New Update Available!") print("Current version -> Github version") print(index_data['version'].ljust(15), '->', github_data.tag_name) print(f"URL: {github_data.url}") choice = input( "Would you like to open this in the browser? (y/n): " ).lower().strip(" ") if choice.startswith("y"): from webbrowser import open as open_url open_url(github_data.url, new=2) choice = input( "Did you update the program? (y/n): ").lower().strip(" ") if choice.startswith("y"): if index.update(args.name.lower(), github_data.tag_name): print("Successfully updated!") else: print( "Error in updating the entry in the index! ~ KeyError" ) else: print(f'Error: Program "{args.name}" could not be found in the index.') elif args.cmd == "list": index_data = index.get_all() for i in index_data.keys(): print(i, "=>")
def run(self): instagramlink = "https://www.instagram.com/prog.rammingislove/" githublink = "https://github.com/swaraj344" linkedin = "https://www.linkedin.com/in/swaraj-kumar-b63376171/" hearticon = self.icon_widget("./icon/heart.png",28) settingicon = self.icon_widget("./icon/settingicon.png",40) connectedicon =self.icon_widget("./icon/connected.png",30) notconnected = self.icon_widget("./icon/notconnected.png",30) instagramicon = self.icon_widget("./icon/instagram.png",24) githubicon = self.icon_widget("./icon/github.png",24) linkedinicon = self.icon_widget("./icon/linkedin.png",24) self.root.title("Youtube Video Downloader") self.root.iconbitmap("./icon/icon.ico") self.root.resizable(False,True) self.root.configure(background=self.Theme2["color2"],) self.tb = Entry(self.root,font="bell 12 italic",bg=self.Theme1["color1"]) self.tb.place(x=100,y=50,height=40,width=450) pastebtn = Button(self.root,text="Paste Link",command=self.pasteBtnClicked , font="bell 10 bold",borderwidth=0,bg=self.Theme2["color3"],foreground="white") pastebtn.place(x=340,y=100,width = 100,height=30) dlbtn = Button(self.root,text="Download",command =self.dlBtnClicked, font="bell 10 bold",borderwidth=2,relief="flat",bg=self.Theme1["color3"],foreground="white") dlbtn.place(x=450,y=100,width = 100,height=30) self.msglabel = Label(self.root,font="bold 14",bg=self.Theme2["color2"],fg="green") Button(self.root,text="hded",image = settingicon,borderwidth=0,command=self.SettingWindow,bg=self.Theme2["color2"]).place(x=550,y=540) self.invalid_message = Label(self.root,text="Invalid Link Please Check Your Link",fg="red",bg=self.Theme2['color2'],font="bell 10 bold") Label(self.root,text ="Made With By Swaraj Kumar",justify="center",bg=self.Theme2["color2"],font ="bell 9 bold").place(x=198,y=560 ) Label(self.root,image = hearticon ,bg=self.Theme2["color2"]).place(x=260 ,y=556) internettext = Label(self.root,bg = self.Theme2['color2']) internettext.place(x=520,y=14) interneticon = Label(self.root ,bg=self.Theme2["color2"]) interneticon.place(x=480,y=7) Button(self.root,image=instagramicon,bg =self.Theme2['color2'],borderwidth = 0,command=lambda : open_url(instagramlink)).place(x=5,y=562) Button(self.root,image=githubicon,bg =self.Theme2['color2'],borderwidth = 0,command=lambda : open_url(githublink)).place(x=35,y=562) Button(self.root,image=linkedinicon,bg =self.Theme2['color2'],borderwidth = 0,command=lambda : open_url(linkedin)).place(x=65,y=562) if self.Isconnect(): interneticon.config(image=connectedicon) internettext.config(text = "Connected",fg = 'green') else: interneticon.config(image = notconnected) internettext.config(text = "Not Connected",fg = 'Red') self.root.mainloop()
def couple(transformation, open): cloudinary._config.cloud_name = "demo" res = cloudinary_url('couple', raw_transformation=transformation)[0] print(res) if open: open_url(res)
def on_current_tab(self, *args): if args[1].text == _("Лицензия"): self.rst.text = open(SCRIPTDIR + "/docs/license.rst").read() elif args[1].text == _("Помочь нам"): open_url("https://github.com/SysRq-Tech/ScadsStats")
def search(query, with_field, sort_by, aggregate, max_results, next_cursor, auto_paginate, force, filter_fields, json, csv, doc): if doc: open_url("https://cloudinary.com/documentation/search_api") exit(0) base_exp = cloudinary.Search().expression(" ".join(query)) if auto_paginate: max_results = 500 if with_field: for i in with_field: base_exp = base_exp.with_field(i) if sort_by: base_exp = base_exp.sort_by(*sort_by) if aggregate: base_exp = base_exp.aggregate(aggregate) base_exp = base_exp.max_results(max_results) exp = base_exp if next_cursor: exp = exp.next_cursor(next_cursor) res = exp.execute() all_results = res if auto_paginate and 'next_cursor' in res.keys(): if not force: r = input("{} total results. {} Admin API rate limit remaining.\n \ Running this program will use {} Admin API calls. Continue? (Y/N) ".format( res['total_count'], res.__dict__['rate_limit_remaining'] + 1, res['total_count']//500 + 1)) if r.lower() != 'y': print("Exiting. Please run again without -A.") exit(0) else: print("Continuing. You may use the -F flag to force auto_pagination.") while True: if 'next_cursor' not in res.keys(): break exp = base_exp.next_cursor(res['next_cursor']) res = exp.execute() all_results['resources'] += res['resources'] del all_results['time'] return_fields = [] if filter_fields: for f in list(filter_fields): if "," in f: return_fields += f.split(",") else: return_fields.append(f) return_fields = tuple(return_fields) + with_field all_results['resources'] = list(map(lambda x: {k: x[k] if k in x.keys() else None for k in return_fields}, all_results['resources'])) log(all_results) if json: write_out(all_results['resources'], json) if csv: all_results = all_results['resources'] f = open('{}.csv'.format(csv), 'w') if return_fields == []: possible_keys = reduce(lambda x, y: set(y.keys()) | x, all_results, set()) return_fields = list(possible_keys) writer = DictWriter(f, fieldnames=list(return_fields)) writer.writeheader() writer.writerows(all_results) f.close() print('Saved search to \'{}.csv\''.format(csv))
def initialize(voice_command, sentences): open_url("http://127.0.0.1/action/[ADD REMINDER]") return True, "J'ai ouvert la page de configuration de tes alarmes et réveils sur ton navigateur !"
def on_current_tab(self, *args): if args[1].text == _("Лицензия"): self.rst.text = open(SCRIPTDIR + "/docs/license.rst").read() elif args[1].text == _("Помочь нам"): open_url("https://github.com/SysRq-Tech/ScadsStats")