Bidirectional file transfer with Pythonista 3

Introduction

I bought Pythonista 3 for 1200 yen to program on the train. I immediately installed Pythonista 3 on my iPad Air 2 and iPod touch. I don't know how to import the existing script on the host PC into Pythonista, so I investigated the bidirectional file transfer method.

Installing StaSh

See https://github.com/ywangd/stash. -First, execute the following one-line script.

python


import requests as r; exec(r.get('http://bit.ly/get-stash').text)

If the installation is successful, the following will be displayed.

python


Installation completed.
Please Restart Pythonista and run launch_stash.py under the Home directory to start StaSh.

-Restart Pythonista3 as instructed (*) and then execute the launch_stash.py script. The screen changes to a UNIX console-like screen with a prompt.

python


StaSh v0.6.18
Tip: You can invoke almost any Python scripts, including UI and Scene, directly from StaSh
[~/Documents]$ 

SSH on StaSh The prompt of StaSh is stash, the remote host is host, and the user name on host is user. ・ First, create an SSH key. The default is 1024bit RSA, so set it to 2048bit.

python


stash$ ssh-keygen -t rsa -b 2048

-Transfer the public key to the host with scp. The target path cannot be omitted.

python


stash$ scp ~/.ssh/id_rsa.pub user@host:~/

-Register the public key on the host side.

python


host$ cat id_rsa.pub >> .ssh/authorized_keys

-Ssh connection test. The first run will install pyte.

python


stash$ ssh user@host

SCP on StaSh The main subject of this article. If SSH public key authentication is set above, you can do it easily. ・ Device → Host PC

python


stash$ scp file.py user@host:~/

・ Host PC → Device

python


stash$ scp user@host:~/test.py .

Git on StaSh via HTTP -Clone: Note that if you do not specify a local directory, the file will be expanded directly underneath.

python


stash$ git clone https://github.com/username/repositry.git mydir

The first time you start it, you will be prompted to install dulwich.

python


dulwich was not found. Will attempt to download.
Neet to download dulwich. OK to download [y/n]? y

-Add: Dot "." Cannot be used. Specify the file.

python


stash$ git add file.py

-Status: STAGED and UNSTAGED are displayed.

python


stash$ git status
STAGED
modify['file.py']
UNSTAGED LOCAL MODS
[]

・ Commit: You will be prompted to register your name and email address for the first time.

python


stash$ git commit "comment"
Author Name: MyName
Save this setting? [y/n]y
Author Email: user@domain
Save this setting? [y/n]y

-Push: You will be asked for your GitHub username and password.

python


stash$ git push
Attempting to push to: https://github.com/username/repositry.git, branch: refs/heads/master
Enter username: username
Enter password: password
Push to https://username:[email protected]/username/repositry.git successful.
success!

Git on StaSh via SSH ・ Register public key on GitHub Copy public key to clipboard

python


stash$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAA ...(abridgement)...
 ...(abridgement)... KIQ==

Press and hold Select → select a range from ssh-rsa to == → Copy Log in to GitHub with your browser and register your public key Settings → SSH and GPG keys on the left menu → New SSH key button    Title: iPad Air 2 Key: (Press and hold to paste) Press the Add SSH key button.

After that, it is almost the same as via HTTP (password is not asked :-).

-Clone: Note that if you do not specify a local directory, the file will be expanded directly underneath.

python


stash$ git clone [email protected]:username/repositry.git mydir

This time it is not the first startup, so there is no installation of dulwich.

-Add: Dot "." Cannot be used. Specify the file.

python


stash$ git add file.py

-Status: STAGED and UNSTAGED are displayed.

python


stash$ git status
STAGED
modify['file.py']
UNSTAGED LOCAL MODS
[]

・ Commit: This time, my name and email address are already registered, so I can't ask.

python


stash$ git commit "comment"

・ Push: This time I was able to do it without being asked for my password!

python


stash$ git push
Attempting to push to: [email protected]:username/repositry.git, branch: refs/heads/master
Push to [email protected]:username/repositry.git successful.
success!

Git on StaSh via SSH (GitLab)

I also wanted to create a free and private repository, so I decided to use GitLab as well. This is the recommended code for the embarrassing scribbled state.

・ Registration of public key to GitLab Copy public key to clipboard

python


stash$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAA ...(abridgement)...
 ...(abridgement)... KIQ==

Press and hold Select → select a range from ssh-rsa to == → Copy Log in to GitLab with your browser and register your public key Settings → SSH Keys in the top menu Key: (Press and hold to paste)    Title: iPad Air 2 Press the Add key button.

After that, it is exactly the same as GitHub, so it is omitted.

that's all

Recommended Posts

Bidirectional file transfer with Pythonista 3
Fast file transfer with fabric
Introducing Paramiko + scp ~ SSH connection ~ File transfer with SCP
File operations with open — "../"
File upload with django
Draw netCDF file with python
Transfer files with teraterm [Note]
File upload with Flask + jQuery
Download csv file with python
Create xlsx file with XlsxWriter
Extract the xz file with python
Get video file information with ffmpeg-python
Create screen scroll with Pythonista + scene
[Python] Write to csv file with Python
[Automation with python! ] Part 1: Setting file
Follow the file hierarchy with fts
Build a deb file with Docker
Output to csv file with Python
Serve static files with X-Send File
Create an Excel file with Python3
Getting Started with Julia for Pythonista
Output cell to file with Colaboratory
Play with Pythonista UI implementation [Action implementation]
Download the file deployed with appcfg.py
3D drawing with SceneKit in Pythonista
Use camera calibration file with OpenCvSharp4
[Automation with python! ] Part 2: File operation
Open the file with the default app
Create a file uploader with Django