def main(): text = '万徳' if not text: dialogs.hud_alert('No text selected', 'error') return newText = quote(text, safe=':/') # todo: url = f'quicka2://?text={newText}' #url = f'quicka2://?text=aaa' shortcuts.open_url(url)
def main(): install_path, config_dict, update_status, current_status = init_install_path( CONFIG_DICT['install_root_name']) if update_status: if current_status: console.alert( "Your software is up-to-date with the version associated with this QR code", "OK") #Launch App start_path = current_install_path + '/MainMetre.py' url_scheme = shortcuts.pythonista_url(path=start_path, action='run', args="", argv=[]) shortcuts.open_url(url_scheme) else: console.alert( "MetreiOS Update Scheduled", "MetreiOS software will update the next time you open the app", "OK") else: current_install_path = os.path.abspath( os.path.expanduser('~/Documents/' + CONFIG_DICT['install_root_name'] + '/' + config_dict['git_repo'])) os.makedirs(current_install_path) install_path, url, installed_files, dirfromgit = install_branch( config_dict) start_path = current_install_path + '/shortcut.py' url_scheme = shortcuts.pythonista_url(path=start_path, action='run', args="", argv=[]) print(f"\nURL scheme: {url_scheme}") installed_dir = current_install_path + '/' + installed_files[0] create_url_scheme_and_qr_code(installed_dir, url_scheme, 'shortcut.py') shortcuts.open_url(url_scheme)
def main(): if len(sys.argv) > 1: p_keys = ('module', 'install_dir', 'git_auth', 'git_usr', 'git_repo', 'git_branch', 'start_file', 'is_release') params_dict = dict(zip(p_keys, sys.argv)) print("\nInstalling:") pprint(params_dict) params = SimpleNamespace(**params_dict) install_path, url, installed_files = install_branch(params) start_path = install_path + '/' + installed_files[0].replace( '/', '') + '/' + params.start_file url_scheme = shortcuts.pythonista_url(path=start_path, action='run', args="", argv=[]) print(f"\nURL scheme: {url_scheme}") installed_dir = install_path + '/' + installed_files[0] create_url_scheme_and_qr_code(installed_dir, url_scheme, params.start_file) else: params = SimpleNamespace(**CONFIG_DICT) print("\nInstalling:") pprint(CONFIG_DICT) install_path, url, installed_files = install_branch(params) start_path = install_path + '/' + installed_files[0].replace( '/', '') + '/' + params.start_file url_scheme = shortcuts.pythonista_url(path=start_path, action='run', args="", argv=[]) print(f"\nURL scheme: {url_scheme}") installed_dir = install_path + '/' + installed_files[0] create_url_scheme_and_qr_code(installed_dir, url_scheme, params.start_file) shortcuts.open_url(url_scheme)
def main(): console.clear() install_path, update_status, config_dict = init_install_path( CONFIG_DICT['install_root_name']) current_install_path = os.path.abspath( os.path.expanduser('~/Documents/' + CONFIG_DICT['install_root_name'] + '/' + config_dict['git_repo'])) if os.path.exists(current_install_path): # Code to launch app print("Launching MetreiOS app...one moment please") start_path = current_install_path + '/' + config_dict['start_file'] url_scheme = shortcuts.pythonista_url(path=start_path, action='run', args="", argv=[]) shortcuts.open_url(url_scheme) else: os.makedirs(current_install_path) # Code to do install (for both Case 1 and Case 2) # Contains exceptions to handle previous versions install_path, url, installed_files, dirfromgit = install_branch( config_dict) # Case 1: Updating the app if update_status: start_path = current_install_path + '/' + config_dict['start_file'] print(start_path) url_scheme = shortcuts.pythonista_url(path=start_path, action='run', args="", argv=[]) console.clear() print("Updating MetreiOS app...one moment please") installed_dir = current_install_path + '/' + installed_files[0] create_url_scheme_and_qr_code(installed_dir, url_scheme, config_dict['start_file']) console.clear() print("Update complete...Launching App") shortcuts.open_url(url_scheme) # Case 2: Installing app for the first time (update_status is false). Need to first run shortcut else: console.clear() print("Download in progress") start_path = current_install_path + '/shortcut.py' url_scheme = shortcuts.pythonista_url(path=start_path, action='run', args="", argv=[]) # print(f"\nURL scheme: {url_scheme}") installed_dir = current_install_path + '/' + installed_files[0] create_url_scheme_and_qr_code(installed_dir, url_scheme, 'shortcut.py') console.clear() print("Download complete---launching setup") shortcuts.open_url(url_scheme)
#https://raw.githubusercontent.com/jdaniellhebert/Pythonista_Install_from_Github/main/install_from_github.py RAW_CODE = 'install_from_github.py' SHORTCUTS_URL = '' console.clear() config_dict = json.load(open('install_config.json')) c = SimpleNamespace(**config_dict) params_url = f"https://raw.githubusercontent.com/ni-metre/Update_Pythonista_App/main/install_config.json" code_url = f"'https://raw.githubusercontent.com/{c.git_usr}/{c.git_repo}/{c.git_branch}/{RAW_CODE}'" glbls = {} lcls = {'p_url': params_url} exec_code = f"import requests as r; exec(r.get({code_url}).content)".replace( ' ', '%20') # requests needs spaces represented by %20 url_scheme = f"pythonista://?exec={exec_code}" print(f"\nURL scheme: {url_scheme}") url_file = 'install_installer.url' open(url_file, "w").write(url_scheme) print(f"\nURL Scheme saved as: {url_file}") img = qrcode.make(url_scheme) img.show() qrcode_file = 'install_installer.jpg' img.save(qrcode_file) print(f"\nQR Code saved as: {qrcode_file}") shortcuts.open_url(url_scheme)
def button_action(self, sender): import shortcuts shortcuts.open_url(sender.name)