• kaan191

    This worked for my http calls using the requests library

    However, I have an asynchronous program making requests with the aiohttp library. These still throw the SSL Certificate errors...

    Cannot connect to host ****** ssl:default [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)]
    

    I'm not sure it has to do with iOS 15... my phone isn't upgraded yet and it's throwing the same errors. Most likely to do with this: https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/

    >>> aiohttp.__version__
    '3.7.4.post0'
    >>> requests.__version__
    '2.26.0'
    >>> certifi.__version__
    '2021.05.30'
    

    posted in Pythonista read more
  • kaan191

    Did you mean .readlines()?

    Maybe show us your script

    posted in Pythonista read more
  • kaan191

    I'm sure I wouldn't be alone in willing to pay for a subscription (like Working Copy) or regular one-off payments for standard library upgrades...

    posted in Pythonista read more
  • kaan191

    @JonB it's very very slow

    To the point it's not practical for projects with big dependencies.

    So far, combo of Raspberry Pi, Blink Shell is best iPad-based platform for me; editing on Pythonista and using Working Copy where possible.

    posted in Pythonista read more
  • kaan191

    @ccc use the alpine package manager

    apk add python3

    Other useful packages

    apk add py3-virtualenv
    apk add py3-pip
    apk add vim

    Don't forget to run apk update before any installs.


    I've just started exploring iSH and I'm super impressed with the project.

    What you gain is extreme flexibility. What you lose out on - that you had with Pythonista - was a supreme UI experience.

    posted in Pythonista read more
  • kaan191

    Hi everyone,

    I love everything about Pythonista on my iPad - it's where I'm most productive; so much so that I dread having to spin up the PC to run or test a piece of code where the dependencies won't work with Pythonista.

    Using an SSH app (blink) and a virtual private server to an Ubuntu instance (digital Ocean) is turning out to be a decent halfway house, using the Vim text editor, and tmux to keep long programs running on the cloud.

    Not sure if anyone else does this.

    And if so, curious if anyone has ventured as far as to customise their vimrc file to resemble the Pythonista environment (key bindings, auto complete, file browser, etc?).

    Cheers!

    posted in Pythonista read more
  • kaan191

    Slight adjustment to above script so that all files in project directory are found. Note: requires hard-coding the directory that holds project directories. Standard Pythonista projects sit in the Documents directory. Working Copy projects sit in a directory called Repositories. Etc. Etc.

    import console
    import editor
    import os
    import pathlib
    import ui
    
    # "parent" directories that contain project roots
    ROOTS = ['Documents', 'Repositories']
    
    def get_project_root(path):
        '''Determines the root of the project, returns PosixPath()
        '''
        if path.parent.name in ROOTS:
            return path
        else:
            return get_project_root(path.parent)
    
    def find_files(path):
        '''Recurses through project tree, returns PosixPath() list of all files
        '''
        file_paths = []
        for item in os.listdir(path):
            item_path = pathlib.Path(os.path.join(path, item))
            if item_path.is_file():
                file_paths.append(item_path)
            elif item_path.is_dir() and '.git' not in item_path.name:
                file_paths.extend(find_files(item_path))
        
        return file_paths
                
                
    def main():
        t = console.input_alert('text to search',hide_cancel_button=True)
        if t == '':
            return
        t = t.lower()
        path = pathlib.Path(editor.get_path())
        
        project_root = get_project_root(path)
        files_list = find_files(project_root)
        
        for file in files_list:
            if os.path.splitext(file)[-1].lower() in (".py", ".txt"):
                with open(os.path.join(path, file), mode='rt', encoding='utf-8') as fil:
                    content = fil.read().lower()
                lines = content.split('\n')
                first = True
                for i, line in enumerate(lines, 1):
                    if line.find(t) >= 0:
                        if first:
                            first = False
                            print(
                                '\n%%%Found in ' + 
                                file.as_posix().split(
                                    project_root.parent.as_posix() + '/'
                                )[-1] +':'
                            )
                        print('l.'+str(i)+':',line.strip())
            
    if __name__ == '__main__':
        main() 
    

    posted in Pythonista read more
  • kaan191

    Brilliant @mikael thanks so much for sharing.

    I'll dig into this and post back if I run into trouble.

    posted in Pythonista read more
  • kaan191

    Hello,

    First post here. But have been quietly admiring all the contributions from some of the heroes of this forum. (@mikael, having particularly a lot of fun with your JSWrapper for webviews! I scrape a lot...).

    Anyway, I'm not trying to bring this topic back to life, rather, I'm curious if you @mikael have any example scripts of how you communicated with a remote Raspberry Pi server?

    I've just bought a Pi 4 (for my kid, but also for me really) and haven't managed to spend much time with it yet.

    The use case I'm trying to explore is whether I can send commands (via Pythonista or some other way) to get scripts to run on a remote Pi device. I have Blink Shell (also a nice app) but as I understand it the session closes when the app closes or is too long in the background, and I need it to keep running.

    Warning: I'm very much an amateur in all these matters so forgive me if what I'm asking / saying seems dumb.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!