-
jrh147
I have a script that works great when run from within Pythonista. It calls another script by passing three arguments to it:
final = kraken(response['kraked_url'], path, name)
And this is what kraken() looks like:
def kraken(image_link,path,name):
However, when I run it as an iOS extension (which is what I really want to do), it ends up giving me this error:
TypeError: kraken() takes exactly 2 arguments (3 given)
What can I do to fix this?
-
jrh147
Completely new to UI Buttons and what not. I went through and created an interface with a couple buttons and ALL I want to be able to do is to grab the value of the button pushed so I can use it for a file path...
This seems super easy but I can't find anything anywhere that simply describes how to do it. All I can do is change the title of it to "Hello"! LOL
Thank you for any help...
-
jrh147
I'm trying to do the same here but keep running into a 401 error.
I followed the above advice, and run the dropboxlogin.py script to test it out and I just get the error. I found this on Linking Dropbox and Pythonista but the instructions seemed to have change for Dropbox.
I created the app, generated a user token, set it to full Dropbox and then changed the dropboxlogin script to show the app key, the app secret and dropbox for access. That page says you can run the script to test it out but I get a 401 error.
I try and run the script above, the one where you change the filename and again a 401 error. I really want to be able to do this, to read in data from a CSV on Dropbox, but can't seem to find clear instructions on how to get started. Thanks in advance.
-
jrh147
I need to encode images in base64 for the purposes of passing them through an x-callback-url. I have this code but it's not working:
#coding: utf-8 import workflow import clipboard import photos import base64 source_selection = workflow.get_variable('source') if source_selection == 'photo': image_selection = photos.pick_image() else: image_selection = clipboard.get_image() if not image_selection: console.alert('No Image', 'Clipboard does not contain an image') w, h = image_selection.size encoded = base64.b64encode(str(image_selection) workflow.set_variable('encodedImage', str(encoded)) workflow.set_variable('origSize', str(w))
Any ideas?
-
jrh147
Oh nice. Thanks! First weekend using Python (if you couldn't tell)
And I spoke too soon. It worked fine if my text only had YAML front matter. If it has anything after the second '---' I get the "Error Scanner while scanning a block scalar ... " Error
I think this is because it expects the entire thing to be YAML. Anyway I can stop scanning up to the second ---.
-
jrh147
That worked great. For anyone following along this is what I ended up with. It checks to see whether or not the key 'link' exists before adding it to the clipboard as well. Thanks!
#coding: utf-8 import yaml import editor import clipboard m = yaml.load(editor.get_text().replace('-', '')) tweet = m['title'] if "link" in m: tweet = tweet + ' ' + m['link'] clipboard.set(tweet)
-
jrh147
I have a simple Markdown file with YAML header that looks something like this:
--- title: "Mary had a little lamb" link: http://google.com ---
I want to extract some of the YAML data to use later in a workflow. So far I have this but it just gives me errors. Ideally once I extract the title key I would also like to strip the quotation marks but not sure how to do that yet either. Maybe there is an easier way?
#coding: utf-8 import console import yaml import editor from StringIO import StringIO text = StringIO(editor.get_text()) doc = list(yaml.load_all(text)) tweet_link = doc["link"] tweet_title = doc["title"] console.hud_alert(tweet_link)