• Tizzy

    I hadn't used stash in a while as well, trying to launch it made this:

    Traceback (most recent call last):
      File "/private/var/mobile/Containers/Shared/AppGroup/FC7E6E85-01F7-47E5-861F-A7ACA8D91116/Pythonista3/Documents/launch_stash.py", line 28, in <module>
        from stash import stash
      File "/private/var/mobile/Containers/Shared/AppGroup/FC7E6E85-01F7-47E5-861F-A7ACA8D91116/Pythonista3/Documents/site-packages/stash/stash.py", line 20, in <module>
        from system.shcommon import IN_PYTHONISTA, ON_IPAD
      File "/private/var/mobile/Containers/Shared/AppGroup/FC7E6E85-01F7-47E5-861F-A7ACA8D91116/Pythonista3/Documents/site-packages/stash/system/shcommon.py", line 29, in <module>
        'Frameworks/PythonistaKit.framework/PythonistaKit')
      File "/var/containers/Bundle/Application/32DB935B-D704-4D48-BBE9-99A076A0D0AB/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/ctypes/__init__.py", line 364, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: dlopen(/var/containers/Bundle/Application/32DB935B-D704-4D48-BBE9-99A076A0D0AB/Pythonista3.app/Frameworks/PythonistaKit.framework/PythonistaKit, 6): image not found
    

    Pythonista 301012 beta.

    posted in Pythonista read more
  • Tizzy

    @aronchi one more thing. You can add this script to your app extension for Pythonista. If you have a raw text file hosted via a server, if you go to it in safari and run this extension on it, it will ask you to name the file and then download that text. I think you might need to manually create a "Downloads" folder in documents.

    Disclaimer - I don't remember where I got this file. It might have been @ccc or @Webmaster4o or maybe @TutorialDoctor ...sorry!

    
    # coding: utf-8
    
    import requests
    import appex
    from console import alert, input_alert
    import os.path
    import os
    
    def main():
        if not appex.is_running_extension():
            alert("Error", "This script is intended to be run from the sharing extension.", "Exit", hide_cancel_button=True)
            return
        
        url = appex.get_url()
        if not url:
            alert("ERROR", "No input URL found.  Execute this script from the sharing extension.", "Quit", hide_cancel_button=True) 
            return
        
        root_path = "../../Documents/Downloads/"
        
        while True:
            filename = input_alert("Download File", "You have chosen to download file at URL:\n " + url + "\n\nEnter filename to save locally.  Press Cancel to abort.")
            filename = root_path+filename
            if os.path.exists(filename):
                if os.path.isfile(filename):
                    confirm = alert("Warning", "File %s exists.  Overwrite?" % filename, "Overwrite", "Change Filename", hide_cancel_button=True)
                    if confirm == 1:
                        os.remove(filename)
                        break
                else:
                    alert("Critical Error.", "Path exists but is not a file.  Exiting.", "Exit", hide_cancel_button=True)
                    return
            else:
                break
    
        r = requests.get(url)
        if r.status_code != 200:
            alert("Invalid HTTP Response: %d, Exiting." %r.status_code, "Exit", hide_cancel_button=True)
            return
        
        confirm = alert("Confirm Download", "Text length: %d, Press OK to Save, Cancel to Quit" %len(r.text), "Save", "Cancel", hide_cancel_button=True)
        if confirm == 1:
            outfile = open(filename, "w")
            for line in r.text:
                outfile.write(line)
            outfile.close()
            alert("Success", "File Saved.", "Exit", hide_cancel_button=True)
        r.close()
        return
        
    
    if __name__ == '__main__':
        main()
    
    

    posted in Pythonista read more
  • Tizzy

    Where are your 3 files stored?

    posted in Pythonista read more
  • Tizzy

    Hi. There's a couple ways you can do this.

    1.) Manually: Use Dropbox/some other tool to get the scripts on your iPad in any form. Copy the contents of each script, create a new script in Pythonista, name it as you'd like, and then paste the contents.

    2.) DropBox sync: Use the dropboxsync.py script found elsewhere on this forum. You need to setup a Dropbox developer account and get a token. (I've been using the same version of that script that isn't perfect and has some problems with case, if anybody else knows what the latest greatest version of that script is please chime in)

    3.) git / github : If you're familiar with using git/ github, you can create a repo in github. Then, install Stash (https://github.com/ywangd/stash), launch it, choose the directory and clone there using standard git commands.

    Let us know if you have any questions.

    posted in Pythonista read more
  • Tizzy

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

    posted in Pythonista read more
  • Tizzy

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

    Sorry.

    posted in Pythonista read more
  • Tizzy

    At some point I started getting insecure platform warnings when requests was upgraded in Pythonista many many builds ago.

    posted in Pythonista read more
  • Tizzy

    import rauth does not work in beta 300015. I believe it worked in the previous build, although I'm not sure. It definitely does work in Pythonista 2.

    ImportError: No module named 'rauth'

    posted in Pythonista read more
  • Tizzy

    Thanks @omz @jonb @dgelessus that did the trick...

    Something to note: running through the levels in 0.1 increments, it appears the only actual discrete levels are 1.0,0.9,0.8, and 0.4, unless there are finer increments between 0.4 and 1.0 ....

    from objc_util import ObjCClass
    import time
    
    def toggle_flashlight():
        AVCaptureDevice = ObjCClass('AVCaptureDevice')
        device = AVCaptureDevice.defaultDeviceWithMediaType_('vide')
        if not device.hasTorch():
            raise RuntimeError('Device has no flashlight')
        mode = device.torchMode()
        device.lockForConfiguration_(None)
        if device.torchMode()>0:
            device.setTorchMode_((mode + 1) % 2)
        else:
            a =[1.0,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1]
            
            for each in a:
                
                device.setTorchModeOnWithLevel_error_(each, None)
                print('level '+str(each))
                time.sleep(.6)
            
            #device.setTorchModeOnWithLevel_error_(0.88, None)
            
            
        device.unlockForConfiguration()
        #device.setTorchModeOnWithLevel_error_(0.2, None)
    
    
    
    if __name__ == '__main__':
        toggle_flashlight()```

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!