Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello β I'm @olemoritz on Twitter.
Git or Gist workflow for Pythonista
-
@ywangd , thanks. I was just trying it inside a script. Is it possible for the _stash(cmd) to do its normal output to the Pythonista console also?
-
@Phuket2 Yes you can send output to the builtin console with
_stash('some_command > &3')
. The>
character is a redirect operator in shell and&3
is the pointer to builtin console. Please note you need v0.6 for this to work. If you are on earlier version, please runselfupdate
first and restart Pythonista. -
@ywangd , thanks. I did the selfupdate. I was 0.53
But if I do the following is it valid? I get stopped....
Just trying to understand how I can use itimport os import shutil _git_dir = '.git' _url = 'https://github.com/Phuket2/Pythonista' _cmd_git_clone = 'git clone {} > &3' _cmd_cd = 'cd {}' from stash import stash _stash = stash.StaSh() _stash(_cmd_cd.format(os.curdir)) if os.path.exists(_git_dir): print 'we have a git dir already' shutil.rmtree(_git_dir) cmd = _cmd_git_clone.format(_url) print cmd print _stash(cmd)
-
@Phuket2 The "Stopped ..." message is normal. The callable stash object returns a worker thread that runs the given command. The callable interface make sure it returns after the thread finish its job. So the "Stopped" message simply says the command is executed and now the thread has done its job and stopped.
A few things to note for your script:
- The GitHub repo address must have an ending
.git
, i.e.https://github.com/Phuket2/Pythonista.git
. git clone ...
command generates no output. So this may not be the best command to showcase> &3
.- Your script must run inside the same folder where the repo is to be cloned, i.e. where the
.git
folder resides. Becauseos.curdir
is always a dot, (.
) andcd .
does nothing. If you wanna clone into a sub-directory to where your script locates. You can first_stash('mkdir sub_folder')
to create the folder and then_stash('cd sub_folder')
.
- The GitHub repo address must have an ending
-
@ywangd, thanks. It's very nice. I need to know more but will not bother you now.
But also, I don't feel so stupid now to ask if it's possible to do.Yes the below is simple. But a nice ui powered by stash is super cool.
# coding: utf-8 import os import shutil import editor ''' ONLY TESTING...DESTRUCTIVE ''' this_path , fn = os.path.split(editor.get_path()) _git_dir = '.git' _url = 'https://github.com/Phuket2/Pythonista.git' _cmd_git_clone = 'git clone {} > &3' _cmd_cd = 'cd {} > &3' _clone_dir_name = 'git_clone' _cmd_mkdir = 'mkdir {}' from stash import stash _stash = stash.StaSh() _stash(_cmd_cd.format(this_path)) _stash(_cmd_mkdir.format(_clone_dir_name)) _stash(_cmd_cd.format(_clone_dir_name)) if os.path.exists(_git_dir): print 'we have a git dir already' shutil.rmtree(_git_dir) cmd = _cmd_git_clone.format(_url) print _stash(cmd)
-
-
I finally created the script which delivers the workflow that I have been looking for...
A simple appex script that enables the use of the share sheet to transfer a repo, file, or directory from the Working Copy app into Pythonista.
https://github.com/cclauss/Pythonista-and-Working-Copy
The new Working Copy release also features iOS Handoff support to keep the code on all of your iOS devices in sync. StaSH and Gitista are super cool but they can (yet!) deliver Handoff like Working Copy can!
Issues and pull requests are most welcome!
-
@ccc , thanks a lot. Works flawlessly for me.
-
@ccc It looks nice. Just checking to see that I've understood this... It is a way to check out the files from a git repo into Pythonista. And Working Copy itself can keep the files in sync between iOS devices. But getting changes of the files out of Pythonista is not covered by this solution. Do you copy-paste the changes into Working Copy manually?
How do you use it yourself?
-
So far all that I have is
read_from_working_copy.py
which is one-way: Working Copy --> PythonistaYes, Working Copy could use Handoff to keep its repos on multiple iOS devices in sync with each other
I have not yet figured out how to deliverI am open to ideas and Pull Requests.write_to_working_copy.py
to go the other way: Pythonista --> Working Copy.https://github.com/omz/Pythonista-Issues/issues/98 Would help to close this loop.
-
@Oscar I figured out the "save to Working Copy" piece too... It is actually builtin! At least on a single file basis (e.g. not a whole folder all at once).
- Open the file of interest in the Pythonista editor
- Click the wrench icon at the upper right
- Click the "Share..." button
- Click "Save in Working Copy" button
- Select the repo that you want to save the file into
- Click "Save As..."
- Change the filename if you want to and click "Save As..." again
- Click "Just Save" if you want to bundle multiple files into a single commit --or-- Type your commit message and click "Commit"
Now we have an end to end workflow: GitHub --> Working Copy --> Pythonista --> Working Copy --> GitHub
-
@ccc , do you think it would be possible to go one step closer.
Iterate though all the files in the directory asking the user for each file if they wants to send the file to working copy. Then have the share sheet present itself for each file you want to save, from there you take over and do all the work in the share sheet manually.Then it would be possible to enhance the script to flag files to always ignore, keep a log of files that have been (supposedly) sent back to working copy with info on date and time etc, alert you that a file is new and be beet sent to working copy etc.
I have done next to zero with share sheets, that's why I ask.
I think this would be a fantastic addition, especially if you have a. Number of files in different directories. You can be sure you made a decision about each file.
Anyway....it's fantastic news, it's very exciting. I can start to see the light at the end of the tunnel about the possibility of collaborating with someone via a repo π±π±π±π±
A big thank you @ccc
-
Thx @Phuket2 I added Pythonista-Issues #121 and #98 to try to get us closer to the vision you set out above.
I think that security concerns prevent you from programmatically invoking Share without human intervention.
However, Working Copy does have a very rich x-callback-url vocabulary so I am sure that more complicate things are possible on that side of the divide.
-
@ccc , ok great. Not sure if you have seen this behavior or not.
I copied a repo into wc, then used your script to copy the repo to Pythonista. All good.
Then I added a new file with a commit. Github is not updated. Then I tried an overwrite. All looking good in wc, but Github still not showing the new file. Then same file again, I just did a save from Pythonista to wc, thinking that when I went to wc it would let me know that I was ahead of the repo. But it does not. But all the changes I do from Pythonista are reflected correctly in wc.But ok, then I do a hard restart on wc, and it tells me I am 3 ahead of the repo. Then I can push. The Github repo is updated.
It's not a super big deal. I just tried to explain it here in case others get the same problem. So it's all working, but seems to be some refresh issues in wc.
-
@ywangd said:
A few things to note for your script:
- The GitHub repo address must have an ending
.git
, i.e.https://github.com/Phuket2/Pythonista.git
.
Why is this? Git on desktop doesn't need need thisβ¦
- The GitHub repo address must have an ending
-
@Webmaster4o said:
@ywangd said:
A few things to note for your script:
- The GitHub repo address must have an ending
.git
, i.e.https://github.com/Phuket2/Pythonista.git
.
Why is this? Git on desktop doesn't need need thisβ¦
Because no one has put in a pull request :)
The HTML and ssh protocol do require this, however git for desktop must detect and corrrect this common mistake. - The GitHub repo address must have an ending
-
@ccc, the appex script seems to be broken. I am pretty sure must be due to working copy update. A bunch of file errors. I didn't post them because it's happening on all the repositorys that worked before. I know I haven't changed anything and it doesn't appear the script has changed.
-
@ccc I've not been able to get the script working. This is the end of the traceback:
with open(src, 'rb') as fsrc:
IsADirectoryError: [Errno 21] Is a directory: '/var/mobile/Containers/Shared/AppGroup/379D48B7-C511-4AF4-80DD-2A91B9CD9D2A/File Provider Storage/Pythonista-and-Working-Copy'I'm not an experienced Pythonista user though, so I might have installed the script incorrectly. I added it as a URL extension, is that correct? Do we need to put anything in the Arguments field in the Pythonista extension editor? Could someone describe the correct way to install the script?
-
https://github.com/cclauss/Pythonista-and-Working-Copy Is now working again with the latest version of the Working Copy app. Thanks @Phuket2 and @Utsira for the heads up that it was broken.
-
@ccc , really thanks. Just updated. Working again... But makes life a lot easier. ππππ