Jump to content

Recommended Posts

Mine is broken, too (all but 'com' should yield results with me). I cannot dig into it myself at the moment, gotta leave. Will do it tonight, if the problem is still there, then.

~/Archive/ssh$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from alfredssh import complete
>>> complete('com')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "alfredssh.py", line 122, in complete
    hosts.update(fetch_ssh_config('~/.ssh/config'))
  File "alfredssh.py", line 23, in update
    (hosts, source) = _list
TypeError: 'NoneType' object is not iterable
>>> complete('mac')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "alfredssh.py", line 122, in complete
    hosts.update(fetch_ssh_config('~/.ssh/config'))
  File "alfredssh.py", line 23, in update
    (hosts, source) = _list
TypeError: 'NoneType' object is not iterable
>>> complete('net')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "alfredssh.py", line 122, in complete
    hosts.update(fetch_ssh_config('~/.ssh/config'))
  File "alfredssh.py", line 23, in update
    (hosts, source) = _list
TypeError: 'NoneType' object is not iterable

 

Share this post


Link to post

I think I've fixed the problem. I was assuming that you had both ~/.ssh/config and ~/.ssh/known_hosts. The workflow barfed if either was missing; now it doesn't.

Share this post


Link to post

Fixed it. You weren't testing for non-existing files (I don't have an ssh_config). Couldn't resist to clean up your Linter warnings. Hope I didn't break anything. Thanks for your contribution to python-alfred!

 

http://d.pr/f/jBYw

 

Thanks, nikipore. I'd already fixed the issue via another means, but your fix is cleaner. I've integrated your tweaks, and download links/GitHub are updated.

Share this post


Link to post

Hiya.. I've got a fairly horrible .ssh/config, and no ssh_config... but it no work for me... ah, seems to be an extra 'z' on line 70:

 

 

    return (results, alias)z
 
Removing that improved things.

Share this post


Link to post

Hiya.. I've got a fairly horrible .ssh/config, and no ssh_config... but it no work for me... ah, seems to be an extra 'z' on line 70:

 

 

    return (results, alias)z
 
Removing that improved things.

 

Oops. Not sure how that one slipped through. Download and source now fixed.

Share this post


Link to post

I'm trying to use this with iTerm and zsh.

 

I've set iTerm to be the default ssh:// handler, but for some reason all it's doing is opening a new terminal tab.

 

Anyone have any ideas?

Share this post


Link to post

I'm trying to use this with iTerm and zsh.

 

I've set iTerm to be the default ssh:// handler, but for some reason all it's doing is opening a new terminal tab.

 

Anyone have any ideas?

 

Your iTerm ssh: handling Profile needs to specify the Command as ssh $$HOST$$ (prefix ssh with the appropriate path if you've installed a new version through MacPorts/homebrew/fink). zsh shouldn't come into it.

 

See post #8 in this thread.

Share this post


Link to post

Any way to get it to open in a tab in the existing terminal?

 

iTerm2 will do this by default, but I'm not aware of a way to get Terminal.app to do this. iTerm2 also has the advantage that it can be made to set the tab title properly (see post #8).

Share this post


Link to post

Great extension. Works like a charm.

Any chance to make it work with the "-i" argument? To ssh to those servers that need the private key file to access. That would be awesome

 

Use ~/.ssh/config (man ssh_config) to specify the private key to be used without having to type it every time.

 

Robin

Share this post


Link to post

This workflow isn't working for me, and I think it's because my config file is symlinked to Dropbox. When I type in `ssh` and start writing a hostname, it says "please wait" or whathaveyou for a split second before dropping me back to the standard Google prompt. Could the symlink be the issue?

Share this post


Link to post

This workflow isn't working for me, and I think it's because my config file is symlinked to Dropbox. When I type in `ssh` and start writing a hostname, it says "please wait" or whathaveyou for a split second before dropping me back to the standard Google prompt. Could the symlink be the issue?

 

This is odd. Even if you just type "ssh randomhost" it should offer to "Connect to ssh://randomhost (source: input)". That your .ssh/ssh_config is a symlink, or on Dropbox should make no difference whatsoever. Can you provide any more detail?

Share this post


Link to post

This is odd. Even if you just type "ssh randomhost" it should offer to "Connect to ssh://randomhost (source: input)". That your .ssh/ssh_config is a symlink, or on Dropbox should make no difference whatsoever. Can you provide any more detail?

 

Errr, I would, but I don't get any other errors or anything. I downloaded it from Packal, if that makes any difference. Anything in particular I can do to help debug?

Share this post


Link to post

Errr, I would, but I don't get any other errors or anything. I downloaded it from Packal, if that makes any difference. Anything in particular I can do to help debug?

 

Given you're using this workflow, I'll assume you're happy at the command line :-)

Change to the workflow's directory in Alfred preferences (found by right clicking on the Workflow and choosing "Show in Finder", if necessary), and run a query manually:

% (Pythagoras:~/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.E2B2A958-21D2-42ED-B6DF-06AF15C6A201) /usr/bin/python -c 'import alfredssh; print alfredssh.complete("local");'
<items><item arg="local" autocomplete="local" uid="ssh://local"><title>ssh://local</title><subtitle>Connect to ssh://local (source: input)</subtitle><icon>icon.png</icon></item><item arg="localhost" autocomplete="localhost" uid="ssh://localhost"><title>ssh://localhost</title><subtitle>Connect to ssh://localhost (source: /etc/hosts)</subtitle><icon>icon.png</icon></item><item arg="monster.local" autocomplete="monster.local" uid="ssh://monster.local"><title>ssh://monster.local</title><subtitle>Connect to ssh://monster.local (source: ~/.ssh/known_hosts)</subtitle><icon>icon.png</icon></item></items>

The output shows the workflow offering to open ssh://local (from the input provided), ssh://localhost (from /etc/hosts), ssh://monster.local (from ~/.ssh/known_hosts) when triggered with the equivalent of "ssh local" in Alfred.

If the above returns an empty list as opposed to an error or a valid list, then try running the function which parses ~/.ssh/config (which I assume is the config file you say is symlinked):

% (Pythagoras:~/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.E2B2A958-21D2-42ED-B6DF-06AF15C6A201) /usr/bin/python -c 'import alfredssh; print alfredssh.fetch_ssh_config("~/.ssh/config");' 
([u'host.example.com', u'monster'], '~/.ssh/ssh_config')

You should get an entry for every non-wildcard entry in your ~/.ssh/config file (host lines which include any of *, ? or ! are excluded).

NB: yes, there's currently an inconsistency. For some reason I chose to display entries from ~/.ssh/config as coming from ~/.ssh/ssh_config. Fix forthcoming.

Share this post


Link to post
user.workflow.3ACC632C-5489-45C1-92AA-6FC07DC4B472 yossarian$ python -c 'import alfredssh; print alfredssh.complete("local");'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "alfredssh.py", line 137, in complete
    fetch_known_hosts('~/.ssh/known_hosts'),
  File "alfredssh.py", line 83, in fetch_known_hosts
    results.update(line.split()[0].split(','))
IndexError: list index out of range

^^ First command - fwiw, my python version when running that command is 2.7.8. The /usr/bin version is 2.7.5 and gives me the same output.

user.workflow.3ACC632C-5489-45C1-92AA-6FC07DC4B472 yossarian$ python -c 'import alfredssh; print alfredssh.fetch_ssh_config("~/.ssh/config");'
([u'pianosa.sytes.net', u'pianosa.sytes.net/deluge', u'LiquidWeb', u'Pianosa/dreedle', u'DigitalOcean/palermo', u'DigitalOcean/napoli', u'Pianosa/crashplan'], '~/.ssh/ssh_config')

^^ Second command.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...