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.
Sharing Code on GitHub
-
Thanks, didn't notice that. Here's a quick workaround that strips non-ASCII characters from the downloaded gist:
https://gist.github.com/4076735
I plan to improve theeditor
module's unicode support in a future update.Those Hue light bulbs look awesome!
-
Finally understood the gist(pull) script, works , happy Peter
-
I combined meu's script for pulling from/committing to gists with C0deH4cker's version of the gist downloading script, so that newly downloaded gists automatically have their IDs set, for future pulling/committing.
It's posted at:
https://gist.github.com/4145515Details on using it are largely the same as it was for the two scripts it's based on, however some filenames are changed to make it look nicer. See the comment at the top of the source file for more details. (To use this script's version of Download Gist.py, you should delete any existing file with that exact name before running my script, which will then set up the replacement.)
-
so how do you get any of these scripts initially pasted into pythonista in the first place? When I view them in safari from the iPhone, I'm not seeing any way to copy the contents to the clipboard. The "copy" command just copies the URL to the page.
-
please disregard the above - figured it out :) I needed to tap and HOLD longer to get into the select mode. duh!
-
Starting with Westacular's Gist, I did a rework of gistcheck.
https://gist.github.com/4702275
Changes:
- General code refactor including switching to requests and shelve module to make handling of the api and gist_id database easier.
- Renamed action scripts to start with "Gist" for easier grouping.
- New ability to create Gist. Calling "Gist Commit" on a file with no Gist ID set will create a new Gist and set the gist_id on the file correctly.
- Added some URL patterns to allow more forms of URLs to be passed in for stripping the Gist ID.
Thanks for all of the previous work, I've been using gistcheck to keep my iphone and ipad pythonista installs synced up. I'm considering adding a script to Sync particular gists to make keeping multiple files update date easier.
-
Hi,
I'm havign a problem getting this to work. I've grabbed spencerogden's gist and run it as described. This gives me the four scripts.
I then tried to create a new file and commit it (as a new gist). When I try to do so it fails at the authorisation phase with the error:
"An error occurred while running the action 'Gist Commit': KeyError:'token'"
When I look at the return from the call to auth() I see:
{u'message': u'Not Found'}
which explains why I get the key error, but doesn't explain why I would get that return.
I have tried random credentials and this gives a different error (sensibly related to bad credentials)
I noticed one possible issue in the auth() function, I think there may be a problem with the call to api_url.replace
It replaces 'gist' with 'authorizations' which, given the original url will make the end of the subsequent url:
/authorizationss/
with an extra 's'
However, correcting this makes no difference.
What am I missing?
Thanks
Dave
-
Dave, that script uses an outdated authentification method. Use Westacular's script instead (worked for me).
-
Thanks,
I grabbed spencerogden's because I wanted the ability to create a new gist. I've therefore done a simple hack and used Westacular's auth() function in spencerogdon's version. I haven't done extensive testing, but it seems to work fine.
It's available here:
https://gist.github.com/5212628
Cheers
Dave
-
@davenicholls: thanks to you and all the previous authors of this script. I've started using your version and it is very useful. I have one comment and one question:
Comment: I think the script must be named as "gistcheck" or the edit menu actions won't work - they give an error message that module gistcheck can't be found. This might be self-evident to an experienced Pythonista user but caused me some head-scratching. Perhaps you could add a sentence to the script to instruct users?
Question: I've noticed that all the scripts referenced in this thread are public and anonymous, so the URL does not include the userid, and the gist id is a five-digit number. Private gist ids seem to be much longer alphanumeric strings. For personal programming projects, is it better to use the public option to keep the readable ids?
-
@johnbenallan
You're right, the four scripts all reference the original one so it must be called gistcheck.py. I picked this up from an earlier comment, but I have now added it as a comment to my fork of the original.
I followed the convention of this thread and posted the shorter, anonymous, gist link although it does end up being redirected to my account so it doesn't remain anonymous.
On my iPad I use a slightly modified version of the script, the lines:
if message is not None: payload['description'] = message for f, c in files.items(): payload['files'][os.path.basename(f)] = {"content":c}
are replaced by
if message is not None: payload['description'] = message payload['public'] = False for f, c in files.items(): payload['files'][os.path.basename(f)] = {"content":c}'
Which creates a private gist.
Dave
-
@wbwelcomeback It's a known bug, sorry about that. You can work around it for now by putting an additional script in the menu that comes before it (they're sorted alphabetically, and the first one currently doesn't work on the iPhone).
-
And btw, it's not possible to include these features as part of the app, it wouldn't pass Apple's review (downloading code in any way is a no-no).
-
I have the same problem of LOT17111, " The Gist could not be downloaded..."
-
I've updated the script so that it should work with the new URL pattern now.
-
Please can someone update these scripts.
I know you can use them if you remove the username in the URL , but I would like to be able
to download directly via Browser using the JavaScript bookmarklet.
(I'm totally new here , and have no idea how to go about trying to
modify the script to strip out the Username in the URL)
Thanks. -
The revised omz script to download a new action from a gist URL works for me.
Trying out the more complex ones for committing changes gives errors though:An error occurred while running the action 'Gist Commit': TypeError: 'instancemethod' object has no attribute ' __getitem__'
After that I also sometimes get error messages about set() while entering commands directly into the console, but not consistently it seems
Is this somehow a result of upgrades in v 1.4?
I hadn't tried running these myself in the previous versions
Thanks -
Thanx everyone in this thread. I was searching for this feature.
Downloaded it yesterday but got the same results as @blether.I've made some changes to checklist.py and now it works for me. I've Forked it from davenicholls.
https://gist.github.com/gdcs68/9031843Changes made to make it work.
Request.post(...).json seems to be the problem for me.
Changed it to regular post. And returned json.Loads(r.content).old code
r = requests.post(api_url + gist, data=json.dumps(payload),headers=headers).json return r
new code
r = requests.post(api_url + gist, data=json.dumps(payload),headers=headers) return json.loads(r.content)
This fixed the problem.
Added some minor changes.
Download script misses import sys.
When commited or forked an script. It now shows an message that it was sucesful posted. I found it annoying the old approach. No news is good news.I hope this post helps anyone else.
I have made the changes, but python is still very new to me. So if I did something don't hold this against me:-) -
Lately, I have been thinking that we as a community need to shift from gists over to real GitHub repos. Finding the best version of gistcheck.py requires reading a lot of forum posts and then some experimentation. Gists are fine for short snippets of code but not really the right tool for collaborative development of complex utilities.
A move to repos would allow multiple members of the Pythonista Forum to contribute to a single version of utilities such as: New from Gist, gistcheck, Dropbox Sync, dropboxlogin, pipista, Shellista, Hydrogen, and others. Multiple members of this community find these utilities useful so we would be better off focusing our collaborative development efforts on a single uber-version of each in a GitHub repo. Instead, we are currently creating separate gists that have diverging feature sets and bug fixes with no clear strategy for merging improvements into a common code base which is stored in a well known location.
Is it just me or do other members of the Pythonisa Forum believe that we should to start using repos instead of gists to improve our collaboration on broadly useful Pythonista code? Also, would it be possible to create the required utilities like New from repo or repocheck?
-
I don't know that switching to full repo's solves the problem - you'll still end up with lots of forks, and keeping track of which is the latest and greatest is still going to be a problem. I think the issue is that in a lot of cases these scripts arose out of having an itch to scratch, they're not created as long-haul projects. So, once you've scratched your itch, you're not really interested in the maintenance. I know that was my case with gistcheck.
I think that the real solution is finding someone who wants to manage the maintenance of these scripts. Once you have that, then your problem is largely solved - regardless of whether the scripts live in a gist or a full repo. With an active custodian, there could simply be a sticky thread in the forum with a link to the "official" version (which is maintained) and some bootstrap code to help you pull that down.
That being said, it is confusing with all the variants out there, and it would be awesome if some one wanted to step up and maintain these resources.
Just my $.02.