Forum Archive

Bugs with latest beta

Webmaster4o
  1. I don't know if this is intentional, but editor can't be imported by appex scripts..
  2. Only a few photos (the ones from after updating to this beta) show in photos.pick_image

I know this one wasn't in the last beta. I have 1.6 GB of photos:

And only 3 show. The first one is from before the update.

omz

Thanks!

I don't know if this is intentional, but editor can't be imported by appex scripts..

This is intentional. The editor in the extension is pretty basic and not scriptable (I don't really see a reason why you'd want to do that anyway).

Only a few photos (the ones from after updating to this beta) show in photos.pick_image

Very weird. To be honest, I don't have an explanation for this. I've changed absolutely nothing in the photos module in the last couple of months, as far as I'm aware.

fitzlarold

I happened to notice that any module or script I have in 'site-packages' is utterly ignored by the scripts in 'Extension'. Is this also intentional? Or am I experiencing a fluke?

omz

The extension is basically a completely separate app with its own sandbox, and it cannot share data with the main app except through the shared "Extension" folder. The site-packages folder lives in the main app's documents though, so it cannot be accessed from the extension at all... You could probably argue that site-packages should live in the shared folder, and it's mostly for "historical" reasons that it isn't... This might change before release.

fitzlarold

Thank you for your response! It's not really vital for my purposes, I just wanted to make sure that it wasn't just me. I'm really enjoying some of these new features. I feel like I've just barely scratched the surface.

Webmaster4o

How do you reccommend that I fix the photos bug? This has only changed when I updated...

Webmaster4o

And I wanted to use editor in appex to convert your download gist script to a safari app extenion

JonB

webmaster, it would be possible to call pythonista:// from appex to run a script in the main app. that is how the old bookmarklet worked.

omz

@JonB Unfortunately, that is not possible. webbrowser.open() doesn't work in the extension (and as far as I'm aware, it's technically not possible to make it work there).

Webmaster4o

Another application is this script I wrote to duplicate a file in pythonista.

import appex

path = appex.get_url()[7:]

filename = path.split('/')[len(path.split('/'))-1]

newpath = path[:len(path)-len(filename)]+'duplicated-file.py'

file = open(path)
newfile = open(newpath, 'wb')

newfile.write(file.read())

file.close()
newfile.close()

It is designed to be run by selecting a file in pythonista and pressing share. It (theoretically) gets the contents of the shared file, and puts them into a new file in the same directory.

But it doesn't work because it says it doesn't have permission.

JonB

appex scripts cannot access the main app folders. if you want the ability to copy pythonista scripts to appex, your approach would work, but not if you want to copy tem into te same folder.

what you want is a "File Action". check settings for File Actions. This lets you put a custom script in the share sheet of the file browser, and it passes filenames in the sys.argv. then you'd do the same thing, just wthout using appex, and using sys.argv instead of getting the appex url.

ccc

For the mainipulations of filename, str.partition() might be better than str.split().

Webmaster4o

@JonB oh, I see that now, it wasn't in the same place so I assumed it was removed in 1.6

@ccc pretty sure partition splits at the first instance...

omz

I'd generally recommend using os.path.split for file paths, though it only really makes a difference if you write something that's supposed to run on Windows as well (which uses '\' as the path separator).

ccc

Str.partition() goes left-to-right and str.rpartition() goes right-to-left.

Webmaster4o

Ok. Makes sense now.