def paste_tapped(sender): # Get the root view: v = sender.superview if webbrowser.can_open(clipboard.get()): v['urlfield'].text = clipboard.get() else: console.hud_alert('Invalid URL')
def output(self): projects = '\n\n'.join(['\n'.join([str(task) for task in proj]) for proj in self.projects]) try: import webbrowser if webbrowser.can_open('drafts://'): from urllib import quote webbrowser.open('drafts://x-callback-url/create?text=%s&action=Update%20TaskPaper' % quote(projects)) else: print projects except: try: file = open(self.filePath,'w') projects = file.write(projects) file.close() except: print projects
def main(): # Initialize variables quoted_output = '' output = '' # Allow to run script stand alone try: arg = sys.argv[1] except IndexError: arg = '' print('\nThis script is now gathering your current GPS coordinates, allowing you to text your location and current weather.\n') # Start getting the location location.start_updates() # Allow for 4 loops to improve gps accuracy, if desired for i in range(4): time.sleep(5) my_loc = location.get_location() acc = my_loc['horizontal_accuracy'] # First run if i == 0: best_loc = my_loc best_acc = my_loc['horizontal_accuracy'] # Setup alert box title = 'Accuracy: {} meters.'.format(acc) msg = "Take more time to try to improve accuracy?" butt1 = "Good enough." butt2 = "Try harder (~25 secs)." # Allow a cancel try: answer = console.alert(title, msg, butt1, butt2) except: console.clear() # Call procedure if script called from another app if arg: do_args(arg, quoted_output, output) else: sys.exit('Cancelled') # If initial accuracy is good enough, give user the chance to break if answer == 1: break # If initial accuracy is not good enough, loop 4 more times and try to improve. elif answer == 2: pass if acc < best_acc: best_loc = my_loc best_acc = my_loc['horizontal_accuracy'] print('Best accuracy is now {} meters.'.format(best_acc)) location.stop_updates() lat = best_loc['latitude'] lon = best_loc['longitude'] # Setup alert box title = 'Select Type of GPS Data To Send:' butt1 = "Address" butt2 = "Coordinates" # Allow a cancel try: ans = console.alert(title,'', butt1, butt2) except: console.clear() # Call procedure if script called from another app if arg: do_args(arg, quoted_output, output) else: sys.exit('Cancelled') # Set up for Markdown if called from apps bold = '**' if arg else '' w_data = get_weather(lat, lon, bold) if ans == 1: data_type = 'address and weather were' a = location.reverse_geocode({'latitude': lat,'longitude': lon}) b = '{0}{Street}, {City} {State} {ZIP}{0}, {Country}'.format(bold, **a[0]) datestamp = datetime.datetime.fromtimestamp(best_loc['timestamp']) d = datestamp.strftime('%A, %m-%d-%Y @ %I:%M:%S %p') output = 'My location as of {} is {}, with an accuracy of about {} meters.'.format(d, b, best_acc) elif ans == 2: data_type = 'coordinates and weather were' output = 'Click on http://maps.apple.com/?q={},{} for a map to my current location.'.format(lat, lon) output = output + w_data quoted_output = urllib.quote(output, safe = '') # Call procedure if script called from another app if arg: do_args(arg, quoted_output, output) # Code below is excuted if script called as stand alone from Pythonista... # Check if Launch Center Pro is installed... if webbrowser.can_open('launch://'): # Setup alert box title = 'Send Your GPS & Weather Data To:' butt1 = "Clipboard" butt2 = "SMS Msg" butt3 = "Email" # Allow a cancel try: ans = console.alert(title, '', butt1, butt2, butt3) except: console.clear() sys.exit('Cancelled') if ans == 1: clipboard.set('') clipboard.set(output + w_data) console.clear() print('Your GPS {} copied to the clipboard.'.format(data_type)) elif ans == 2: cmd = 'launch://messaging?body={}'.format(quoted_output) webbrowser.open(cmd) console.clear() elif ans == 3: cmd = 'launch://email?body={}'.format(quoted_output) webbrowser.open(cmd) console.clear() else: # Output to clipboard only clipboard.set(output) console.clear() print('Your GPS {} copied to the clipboard.'.format(data_type)) sys.exit('Finished!!')
v.close() #Download Button Enabled sender.enabled = True webbrowser.open('workflow://run-workflow?name=DownTube&input=' + audio + titulo) def slider_action(sender): # Get the root view: v = sender.superview # Update Quality if sender.name == 'quality': if v['quality'].value <= 0.33: v['qualityopt'].text = 'Low' elif v['quality'].value > 0.33 and v['quality'].value <= 0.66: v['qualityopt'].text = 'Medium' elif v['quality'].value > 0.66: v['qualityopt'].text = 'Best' v = ui.load_view('YoutubeNow2') urlfield = v['urlfield'] if webbrowser.can_open(clipboard.get()): urlfield.text = clipboard.get() if ui.get_screen_size()[1] >= 768: # iPad v.present('popover') else: # iPhone v.present(orientations=['portrait'])
pythonista://ListToFantastical2?action=run&argv=[[draft]]&argv=drafts4 LCP: pythonista://{{ListToFantastical2}}?action=run&argv=[prompt-list:Enter Todos, Reminders, Events:]&argv=launch Credit Due: list2Fantastical.py https://gist.github.com/pslobo/25af95742e1480210e2e Thanks to @pslobo for his contribution to GitHub Thanks to @cclauss for code tightening and cleanup ''' import sys import urllib2 import webbrowser # Fast fail if Fantastical2 is not installed if not webbrowser.can_open('fantastical2://'): sys.exit('Error: Fantastical is not installed') ''' The first arg is a comma seperated list of items received from user input prompt in LCP or comma separated text in 1Writer, or Drafts. The second arg is the caller app. ''' try: _, tasks, caller = sys.argv[:3] except ValueError: sys.exit('Error: Command line args are missing.') # Initialize the x-callback-url url = ''
pythonista://ListToFantastical2?action=run&argv=[[draft]]&argv=drafts4 LCP: pythonista://{{ListToFantastical2}}?action=run&argv=[prompt-list:Enter Todos, Reminders, Events:]&argv=launch Credit Due: list2Fantastical.py https://gist.github.com/pslobo/25af95742e1480210e2e Thanks to @pslobo for his contribution to GitHub Thanks to @cclauss for code tightening and cleanup ''' import sys import urllib2 import webbrowser # Fast fail if Fantastical2 is not installed if not webbrowser.can_open('fantastical2://'): sys.exit('Error: Fantastical is not installed') ''' The first arg is a comma seperated list of items received from user input prompt in LCP or comma separated text in 1Writer, or Drafts. The second arg is the caller app. ''' try: _, tasks, caller = sys.argv[:3] except ValueError: sys.exit('Error: Command line args are missing.') # Initialize the x-callback-url url = '' '''
if v['swexit'].value: v.close() #Download Button Enabled sender.enabled = True webbrowser.open('workflow://run-workflow?name=DownTube&input='+audio+titulo) def slider_action(sender): # Get the root view: v = sender.superview # Update Quality if sender.name == 'quality': if v['quality'].value <= 0.33: v['qualityopt'].text = 'Low' elif v['quality'].value > 0.33 and v['quality'].value <= 0.66: v['qualityopt'].text = 'Medium' elif v['quality'].value > 0.66: v['qualityopt'].text = 'Best' v = ui.load_view('YoutubeNow2') urlfield = v['urlfield'] if webbrowser.can_open(clipboard.get()): urlfield.text = clipboard.get() if ui.get_screen_size()[1] >= 768: # iPad v.present('popover') else: # iPhone v.present(orientations=['portrait'])
def main(): # Initialize variables quoted_output = '' output = '' # Allow to run script stand alone try: arg = sys.argv[1] except IndexError: arg = '' print( '\nThis script is now gathering your current GPS coordinates, allowing you to text your location and current weather.\n' ) # Start getting the location location.start_updates() # Allow for 4 loops to improve gps accuracy, if desired for i in range(4): time.sleep(5) my_loc = location.get_location() acc = my_loc['horizontal_accuracy'] # First run if i == 0: best_loc = my_loc best_acc = my_loc['horizontal_accuracy'] # Setup alert box title = 'Accuracy: {} meters.'.format(acc) msg = "Take more time to try to improve accuracy?" butt1 = "Good enough." butt2 = "Try harder (~25 secs)." # Allow a cancel try: answer = console.alert(title, msg, butt1, butt2) except: console.clear() # Call procedure if script called from another app if arg: do_args(arg, quoted_output, output) else: sys.exit('Cancelled') # If initial accuracy is good enough, give user the chance to break if answer == 1: break # If initial accuracy is not good enough, loop 4 more times and try to improve. elif answer == 2: pass if acc < best_acc: best_loc = my_loc best_acc = my_loc['horizontal_accuracy'] print('Best accuracy is now {} meters.'.format(best_acc)) location.stop_updates() lat = best_loc['latitude'] lon = best_loc['longitude'] # Setup alert box title = 'Select Type of GPS Data To Send:' butt1 = "Address" butt2 = "Coordinates" # Allow a cancel try: ans = console.alert(title, '', butt1, butt2) except: console.clear() # Call procedure if script called from another app if arg: do_args(arg, quoted_output, output) else: sys.exit('Cancelled') # Set up for Markdown if called from apps bold = '**' if arg else '' w_data = get_weather(lat, lon, bold) if ans == 1: data_type = 'address and weather were' a = location.reverse_geocode({'latitude': lat, 'longitude': lon}) b = '{0}{Street}, {City} {State} {ZIP}{0}, {Country}'.format( bold, **a[0]) datestamp = datetime.datetime.fromtimestamp(best_loc['timestamp']) d = datestamp.strftime('%A, %m-%d-%Y @ %I:%M:%S %p') output = 'My location as of {} is {}, with an accuracy of about {} meters.'.format( d, b, best_acc) elif ans == 2: data_type = 'coordinates and weather were' output = 'Click on http://maps.apple.com/?q={},{} for a map to my current location.'.format( lat, lon) output = output + w_data quoted_output = urllib.quote(output, safe='') # Call procedure if script called from another app if arg: do_args(arg, quoted_output, output) # Code below is excuted if script called as stand alone from Pythonista... # Check if Launch Center Pro is installed... if webbrowser.can_open('launch://'): # Setup alert box title = 'Send Your GPS & Weather Data To:' butt1 = "Clipboard" butt2 = "SMS Msg" butt3 = "Email" # Allow a cancel try: ans = console.alert(title, '', butt1, butt2, butt3) except: console.clear() sys.exit('Cancelled') if ans == 1: clipboard.set('') clipboard.set(output + w_data) console.clear() print('Your GPS {} copied to the clipboard.'.format(data_type)) elif ans == 2: cmd = 'launch://messaging?body={}'.format(quoted_output) webbrowser.open(cmd) console.clear() elif ans == 3: cmd = 'launch://email?body={}'.format(quoted_output) webbrowser.open(cmd) console.clear() else: # Output to clipboard only clipboard.set(output) console.clear() print('Your GPS {} copied to the clipboard.'.format(data_type)) sys.exit('Finished!!')
book = sys.argv[1] verse = sys.argv[2] third = sys.argv[3] passage = book + ' ' + verse + ' ' + third''' passage = clipboard.get() bibletext = bible.doPassageQuery(passage) fulltext = '**' + passage + '**' + '\n' + bibletext url = 'drafts4://x-callback-url/create?text=' + urllib.quote(fulltext) # check to see that drafts is installed. probably not necessary, but... if webbrowser.can_open('drafts4://') == True: webbrowser.open(url) '''this is Eric Pramono's code for LCP actions. encodedscheme = urllib.quote(urlscheme) if (mode == 1): url = 'dayone://post?entry=' + urllib.quote(result) elif (mode == 2): url = 'onewriter://x-callback-url/append?path=Documents&name=Sermon%20Notes.md&type=local&text=%0A' + urllib.quote('_' + result + '_\n') elif (mode == 3): url = 'launch://x-callback-url/messaging?body=' + urllib.quote(ov + '\n\n' + urlscheme) + '&x-success=' + encodedscheme else: url = 'launch://x-callback-url/messaging?body=' + urllib.quote(book + ' ' + cv + '\n\nLink: ' + urlscheme) + '&x-success=' + encodedscheme webbrowser.open(url)'''
It also has optional support for LaunchCenterPro if it is installed. Source code at: https://github.com/HyShai/url-cleaner''' import clipboard, console, re, requests, sys, urllib, webbrowser def url_lengthen(url): # recursively lengthen the url try: new_url = requests.head(url).headers.get('location') except ValueError: return None return url_lengthen(new_url) if new_url else url url = url_lengthen(sys.argv[1] if len(sys.argv) > 1 else clipboard.get()) if not url: print(welcome_msg) sys.exit() #strip analytics garbage url = re.sub(r'(?<=\&|\?)utm\w+=[^\&]+(\&)?','',url) if webbrowser.can_open('launch://'): params = urllib.quote('[prompt:Set Clipboard=%s]' % url) launch = 'launch://clipboard?text=%s' % params webbrowser.open(launch) else: print('Copying '), console.write_link(url, url) print('to the clipboard') clipboard.set(url)
bible = ESVSession(key) reference = clipboard.get( ) # the Drafts action sets the draft to the clipboard. I did this because it's easy and I'm not good at Python. If you have a better way, let me know! reference = reference.encode( ) # make the Unicode text a String - otherwise 'splitlines' throws a fit. reference = reference.title() # make those lowercase characters upper case lines = str.splitlines( reference) # this is a working version to count the number of lines for i, v in enumerate(reference): totallines = i # end of section fulltext = [] # Make list to spit multiple passages into passages = lines for reference in passages: bibletext = '**' + reference + '**' + bible.doPassageQuery( reference) # This gives you a markdown-style bold text. fulltext.append(bibletext) fulltext = '\n\n'.join(fulltext) # Converts list to string url = 'drafts4://x-callback-url/create?text=' + urllib.quote(fulltext) if webbrowser.can_open( 'drafts4://') == True: # Check to see that Drafts is installed. webbrowser.open(url)