Jump to content

nikipore

Member
  • Posts

    40
  • Joined

  • Last visited

Posts posted by nikipore

  1. Now I started two Python interpreters. Their process name is something like this (these are MacPort Python 2.6 interpreteres, just in case you wonder):

     

     8980 ttys001    0:00.02 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python

     

    And it doesn't work. I haven't looked into your code, but since youre identifying all processes correctly, why don't you pass all process IDs to the arg and put the row-specific pid in the first position? Then the scripts should pretty much look the same, except that one loops over all pids, and the other only picks the first one. No issues with weird names whatsoever.

  2. Ok, merging sounds cool.

     

    I also believe that it makes more sense to migrate towards the cleaner API (which you seem to agree is alfred-python). Whenever you want to merge something into alfred-python yourself, please fork and make a pull request. If you wish I can also grant you write access (unless I'm unable to work out how that works 8-). Any non-Pythonic "mess" you produce will be cleaned up by me, I'm rather anal about that :-)

     

    As I said, the Keychain and Spotlight APIs are great, but not directly related to Alfred (or is it?) and IMHO therefore (following the single responsibility principle) should go to repositories of its own. We certainly may refer to these repositories in the alfred-python README to ease usage for developers. Recipes or links to workflow projects using the API would also be cool.

     

    If there is Alfred related stuff you want me to pull, just go ahead and tell me. Some things I already pulled myself, e.g., the prepending of uid's with the bundleid. (Although I'm not sure whether that's really necessary or Alfred has separate uid spaces per workflow @David: can you clarify that?)

     

    @David (if you read this): It would be great if you opened a sticky post about existing Alfred APIs in order to increase leverage.

     

  3. I had trouble wth some folders until I realized there were in fact symbolic links. Is your Desktop folder a folder or a symbolic link? If the latter is true, dragging a symlink to the file action should cure the problem.

     

    @David: Can you add the file type public.symlink to the file action? I haven't notices any problems so far.

  4. I've independently whipped up my own Python API (https://github.com/nikipore/alfred-python) before I was aware of yours. For not knowing Python, you did a great job (even if you knew Python better, that's pretty awesome work). Some suggestions though from someone who makes a living as a Pythonista:

    • The Feedback.py module alone has over 200 lines (compared to the <90 lines of alfred.py which deliver the full core API functionality). What's the added value of Feedback class over Item? The pythonic way is to just pass an iterable of Items to the result XML compiler and leave the organisation of Items to the user. For most usages, a simple generator or dict should suffice.
    • Your Item attribute getters and setters are very unconventional. Have you had a look at the Python property (a built-in concept for getters and setters)?
    • from ... import * is a bit of a Java thing and considered evil in Python because you lose control over your namespace.
    • Split out the non-core stuff into separate packages. The Keychain API is awesome and probably worth to become a 1st class PyPI member. (Meaning: you might wish to publish that as a PyPI package, cf. http://pythonhosted.org/an_example_pypi_project/index.html). It looks like a no-nonsense super-lightweight alternative to https://pypi.python.org/pypi/keyring. The same applies to the Spotlight search.
    • modules and packages should always be lowercase: Keychain.py -> keychain.py etc. Your main package doesn't have a name at all! (only implicitly via the GitHub project name PyAI).
    • Have a look at encodings! I haven't tested any of your workflows using PyAI, but I guess Umlauts and their kin will not faithfully arrive (in David's PHP API, they don't either). The trick is to normalize using unicodedata.normalize('NFC', s.decode('utf-8'))
    • Many functions do not really add value over direct access to the Python stdlib. E.g., the json.dumps/loads and plistlib stuff would be better off if you extracted the common path logic and leave the call of the stdlib functions (like json.dumps()) to the user.

    I'm not saying all that because I'm a know-it-all but rather because I think there should be just one Alfred API, and it should be very lightweight and concise and restrict itself to the single responsibility of communicating with Alfred and the workflow environment (access to standard paths etc.). When you've trimmed some fat (150 lines for the core functionality should be plenty), I'll happily migrate over to PyAI (if it then has a Pythonic name :-) If you're interested in sharing/merging with python-alfred, that's also cool.

  5. Cool! I've got a suggestion: When you're a heavy SSH user, it may become difficult to tell local Terminal windows and the various remote Terminal windows apart because they all have the same color theme. Plus, one sometimes wants to tunnel a port or three, or the target port isn't 22. For that reason, I establish my SSH sessions via .terminal files which I can also find via Alfred. These are basically .plist files with another file extension (this one I use to tunnel VNC access):

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>BackgroundColor</key>
    	<data>
    	YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
    	AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
    	RjAgMCAwANIQERITWiRjbGFzc25hbWVYJGNsYXNzZXNXTlNDb2xvcqISFFhOU09iamVj
    	dF8QD05TS2V5ZWRBcmNoaXZlctEXGFRyb290gAEIERojLTI3O0FIT1xiZGZtcn2GjpGa
    	rK+0AAAAAAAAAQEAAAAAAAAAGQAAAAAAAAAAAAAAAAAAALY=
    	</data>
    	<key>CommandString</key>
            <string>ssh me@somewhere.net -L5900:localhost:5900</string> 
    	<key>CursorBlink</key>
    	<true/>
    	<key>CursorColor</key>
    	<data>
    	YnBsaXN0MDDUAQIDBAUGICFYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
    	AAGGoKYHCBMUFRpVJG51bGzVCQoLDA0ODxAREl1OU0NhdGFsb2dOYW1lViRjbGFzc1tO
    	U0NvbG9yTmFtZVxOU0NvbG9yU3BhY2VXTlNDb2xvcoACgAWAAxAGgARWU3lzdGVtXxAY
    	ZGlzYWJsZWRDb250cm9sVGV4dENvbG9y0woMFg8YGVdOU1doaXRlgAUQA00wLjMzMzMz
    	MzMzMzMA0hscHR5aJGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yoh0fWE5TT2JqZWN0
    	XxAPTlNLZXllZEFyY2hpdmVy0SIjVHJvb3SAAQAIABEAGgAjAC0AMgA3AD4ARABPAF0A
    	ZABwAH0AhQCHAIkAiwCNAI8AlgCxALgAwADCAMQA0gDXAOIA6wDzAPYA/wERARQBGQAA
    	AAAAAAIBAAAAAAAAACQAAAAAAAAAAAAAAAAAAAEb
    	</data>
    	<key>CursorType</key>
    	<integer>1</integer>
    	<key>Font</key>
    	<data>
    	YnBsaXN0MDDUAQIDBAUGGBlYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
    	AAGGoKQHCBESVSRudWxs1AkKCwwNDg8QViRjbGFzc1ZOU05hbWVWTlNTaXplWE5TZkZs
    	YWdzgAOAAiNAKAAAAAAAABAQXU1lbmxvLVJlZ3VsYXLSExQVFlokY2xhc3NuYW1lWCRj
    	bGFzc2VzVk5TRm9udKIVF1hOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEaG1Ryb290
    	gAEIERojLTI3PEJLUllgaWttdniGi5afpqmyxMfMAAAAAAAAAQEAAAAAAAAAHAAAAAAA
    	AAAAAAAAAAAAAM4=
    	</data>
    	<key>FontAntialias</key>
    	<true/>
    	<key>FontWidthSpacing</key>
    	<real>1.004032258064516</real>
    	<key>ProfileCurrentVersion</key>
    	<real>2.0099999999999998</real>
    	<key>RunCommandAsShell</key>
    	<true/>
    	<key>SelectionColor</key>
    	<data>
    	YnBsaXN0MDDUAQIDBAUGICFYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
    	AAGGoKYHCBMUFRpVJG51bGzVCQoLDA0ODxAREl1OU0NhdGFsb2dOYW1lViRjbGFzc1tO
    	U0NvbG9yTmFtZVxOU0NvbG9yU3BhY2VXTlNDb2xvcoACgAWAAxAGgARWU3lzdGVtXxAY
    	ZGlzYWJsZWRDb250cm9sVGV4dENvbG9y0woMFg8YGVdOU1doaXRlgAUQA00wLjMzMzMz
    	MzMzMzMA0hscHR5aJGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yoh0fWE5TT2JqZWN0
    	XxAPTlNLZXllZEFyY2hpdmVy0SIjVHJvb3SAAQAIABEAGgAjAC0AMgA3AD4ARABPAF0A
    	ZABwAH0AhQCHAIkAiwCNAI8AlgCxALgAwADCAMQA0gDXAOIA6wDzAPYA/wERARQBGQAA
    	AAAAAAIBAAAAAAAAACQAAAAAAAAAAAAAAAAAAAEb
    	</data>
    	<key>ShowActiveProcessInTitle</key>
    	<false/>
    	<key>ShowCommandKeyInTitle</key>
    	<false/>
    	<key>ShowShellCommandInTitle</key>
    	<false/>
    	<key>ShowTTYNameInTitle</key>
    	<false/>
    	<key>ShowWindowSettingsNameInTitle</key>
    	<true/>
    	<key>TextBoldColor</key>
    	<data>
    	YnBsaXN0MDDUAQIDBAUGICFYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
    	AAGGoKYHCBMUFRpVJG51bGzVCQoLDA0ODxAREl1OU0NhdGFsb2dOYW1lViRjbGFzc1tO
    	U0NvbG9yTmFtZVxOU0NvbG9yU3BhY2VXTlNDb2xvcoACgAWAAxAGgARWU3lzdGVtXxAa
    	Y29udHJvbExpZ2h0SGlnaGxpZ2h0Q29sb3LTCgwWDxgZV05TV2hpdGWABRADQjEA0hsc
    	HR5aJGNsYXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yoh0fWE5TT2JqZWN0XxAPTlNLZXll
    	ZEFyY2hpdmVy0SIjVHJvb3SAAQAIABEAGgAjAC0AMgA3AD4ARABPAF0AZABwAH0AhQCH
    	AIkAiwCNAI8AlgCzALoAwgDEAMYAyQDOANkA4gDqAO0A9gEIAQsBEAAAAAAAAAIBAAAA
    	AAAAACQAAAAAAAAAAAAAAAAAAAES
    	</data>
    	<key>TextColor</key>
    	<data>
    	YnBsaXN0MDDUAQIDBAUGICFYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
    	AAGGoKYHCBMUFRpVJG51bGzVCQoLDA0ODxAREl1OU0NhdGFsb2dOYW1lViRjbGFzc1tO
    	U0NvbG9yTmFtZVxOU0NvbG9yU3BhY2VXTlNDb2xvcoACgAWAAxAGgARWU3lzdGVtWWdy
    	aWRDb2xvctMKDBYPGBlXTlNXaGl0ZYAFEANEMC41ANIbHB0eWiRjbGFzc25hbWVYJGNs
    	YXNzZXNXTlNDb2xvcqIdH1hOU09iamVjdF8QD05TS2V5ZWRBcmNoaXZlctEiI1Ryb290
    	gAEACAARABoAIwAtADIANwA+AEQATwBdAGQAcAB9AIUAhwCJAIsAjQCPAJYAoACnAK8A
    	sQCzALgAvQDIANEA2QDcAOUA9wD6AP8AAAAAAAACAQAAAAAAAAAkAAAAAAAAAAAAAAAA
    	AAABAQ==
    	</data>
    	<key>UseBoldFonts</key>
    	<false/>
    	<key>UseBrightBold</key>
    	<true/>
    	<key>columnCount</key>
    	<integer>140</integer>
    	<key>name</key>
    	<string>Terminal Settings</string>
    	<key>rowCount</key>
    	<integer>40</integer>
    	<key>shellExitAction</key>
    	<integer>0</integer>
    	<key>type</key>
    	<string>Window Settings</string>
    </dict>
    </plist>
    
    

    So what I'm suggesting is the following: Why not put a default.terminal template in the workflow folder having a tag

     

    <key>CommandString</key>
    <string>ssh %(address)s</string>
    

     

    Then write a copy of this file for each user and host to the non-volatile work folder and pass the file name to Alfred? Then, a user has various places to tweak the settings per connection.

     

    I can also implement that if you like.

  6. Hello everybody,

     

    I just got Alfred 2 today and I thought that the time has come to set an end to the scandalous situation that there is no access to Firefox bookmarks (screenshot):

     

    https://github.com/nikipore/alfred-firefoxbookmarks

     

    It's written in very basic Python. If anyone wants to join in, there are a couple of things one might do from here:

    • Quicksearch support
    • display Favicons - EDIT: done
    • better configurability (e.g. the place where places.db resides) - EDIT: done

     

    EDIT: In the meantime, I've mashed up an IMHO quite useful and generic Python module which takes care of the nuts and bolts of the Alfred API (encoding issues, working directories according to the Workflow Best Practices, plist parsing, XML result compilation, ...). If you wish to use or improve it:

     

    https://github.com/nikipore/alfred-python

     

    Cheers

    Jan

×
×
  • Create New...