• Oops. You're completely correct. I forgot I had installed that separately, using StaSh, pip install rauth.

    Sorry.

  • Seems to be because _pythonista_preflight is checking for scripts in the docs folder, but pythonista 2 scripts are not in that folder!

    if (mod_path.startswith('./') or mod_path.startswith(doc_path)): del sys.modules[name]

    Incidentally... I missed this change, perhaps others did as well, as. way to force reload of site packages when developing.
    keep_site_packages = '--reload-site-packages' not in sys.argv[1:]

  • I guess the question I'm trying to understand is - does sheer execution speed actually affect real-world performance of Pythonista apps on iOS? I suppose that this depends on the structure of your code - but I wonder what the effect is if you limit your focus to native iOS UI elements being manipulated in standard ways?

    🌻

  • Syntax-highlighting, probably. A comment is easy - everything between # and end of line gets "comment formatting". With an uncommented dict containing many string and number literals, the syntax highligher has a lot more work to do. Compare a regex for comments (#.*) with one for (double-quoted) string literals ("(?:[^\\"]|\\.)*").

  • For my 2 cents worth, I think we have to conduct ourselves online as if there are back doors etc. not saying they shouldn't keep fighting. But for me, I will always assume someone is wa ting. I have nothing to hide mind you.
    But it blows my mind when I see people using 3rd party keyboards looking into there backing site or any password protected site.
    Also how so may people are oblivious to all the cameras around them. A lot of people assume these cameras are the old crap low res grainy security cameras. And while they may well be, they also maybe state of the art 1080p cameras with thermal,and night vision and very high optical zooms. Meaning it's very easy for them to zoom in on you and your device and see exactly what you are entering. Whilst, they have shown the Touch ID is not the safest thing in the world, I love it because I am not entering passwords in public places,even just my screen lock.
    Anyway, fruadsters are getting more and more tricky.

  • maybe i missed it, but you don't need to load images from a file. you can create a ui.Image from an image context, you can use from_data, etc.

    Take a look at how ListDataSource works in ui.py

    if isinstance(img, basestring): cell.image_view.image = Image.named(img) elif isinstance(img, Image): cell.image_view.image = img

    while the image_view is read only, the image attribute is writable.

  • [SOLVED]

    So the solution was to change the "data = " parameter to "json = " in the request.

    (ALSO FOR THE xCODE TEMPLATE HAD TO UPDATE THE VERSION OF REQUESTS. 2.9.1 seems to be safely working)

    Not working (500 error):

    partnerInfoRequestObject = requests.Request("POST","https://[censored].com/", data = dataToPOST,headers = partnerInfoHeaders)

    Working:

    partnerInfoRequestObject = requests.Request("POST","https://[censored].com/", json = dataToPOST,headers = partnerInfoHeaders)

    As a sidenote, what also half-worked was wrapping my dict in triple quotes for the "data=" parameter - that would give me a 200 response but a different internal server error message. Just changing it to "json=" seemed to do the trick. I was not aware you could just plug a dict in where json was expected.

  • sorry, one more question. if the problem is your main loop, you could kill your main loop's activity before launching the webbrowser; i.e check for a flag at the start if each loop, and make sure you delay long enough that the loop is done, or use a Semaphore, etc.

  • @pacco Checking in, any word on proxies in Pythonista since we brought this up quite a while ago? Any Luck?

  • From looking at the pexpect source code, it seems like the modules resource, pty, tty, and termios are the culprits... these aren't included in Pythonista. While it might be possible to get some of these to work on iOS, pty is pretty much off-limits since it relies on being able to fork sub-processes, which isn't possible due to sandboxing...

  • sorry, i misspoke above. ui.background puts everything on one thread, queued up by the order of background calls. ui.delay does kick off independant threads, though these may still be shared or managed somehow with the ui system, but I am not sure. ui.delay seems like a fine approach for updating a label with current time.

    I would avoid doing anything really time critical using ui.in_background. It is good when you want to ensure the calls are executed in the order they were called, but if you are having some sort of autonomous code that is not triggered by a ui action, a Thread might be better. I think i posted an async_exec decorator somewhere on the forum which is a Thread version of ui.in_background.

    Phuket2 offers good advice about using cancel_delays -- you need a way for the loop to cancel. Checking on_screen may be a good approach, you could also set a stop flag, etc. Cancel_delays is useful when you have longish delays, though in your case, you probably would never be able to catch that 0.001 between calls, so you need something inside crazyCounter() to prevent kicking off the ui.delay. Another heavy handed approach would be to redefine crazyCounter in -- your stop or will_close method, that way you don't incur the overhead of checking a flag inside your crazyCounter(), which I gather you want to run as fast as possible.

  • Thank you CCC, that did the trick.

    Here is an updated function that takes a url and shoots out a UI image.

    import ui import webbrowser import cStringIO import urllib2 from PIL import Image, ImageOps, ImageDraw import io url= "http://vignette2.wikia.nocookie.net/jamesbond/images/3/31/Vesper_Lynd_(Eva_Green)_-_Profile.jpg/revision/latest?cb=20130506215331" def circleMaskViewFromURL(url): url=url #load image from url and show it file=cStringIO.StringIO(urllib2.urlopen(url).read()) img = Image.open(file) #begin mask creation bigsize = (img.size[0] * 3, img.size[1] * 3) mask = Image.new('L', bigsize, 0) draw = ImageDraw.Draw(mask) draw.ellipse((0, 0) + bigsize, fill=255) mask = mask.resize(img.size, Image.ANTIALIAS) img.putalpha(mask) #show final masked image img.show() img=pil2ui(img) return img # pil <=> ui def pil2ui(imgIn): with io.BytesIO() as bIO: imgIn.save(bIO, 'PNG') imgOut = ui.Image.from_data(bIO.getvalue()) del bIO return imgOut imageView1.image=circleMaskViewFromURL(url)
Internal error.

Oops! Looks like something went wrong!