Jump to content

phyllisstein

Member
  • Posts

    366
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by phyllisstein

  1. wordlist.csv is indeed in the workflow folder. Its actually up and running now - but I'm still not sure the way I am passing parameters to the python script is the best way. Right now, the workflow runs this command using bash:

    ./randomGen.py {query}
    

    I can pass it two arguments from Alfred this way, which are interpreted as argv[1] and argv[2] by the python sys module. I am jerry-rigging default parameters using try/except, which is functional but seems clunky. Additionally, it means that I can't give the second Alfred argument unless I also give the first (otherwise it will be argv[1] instead of argv[2]).

     

    #!/usr/bin/env python 
    
    import urllib2
    import sys
    
    try:
    	dictionary = str(sys.argv[2]).lower() + '.txt'
    except:
    	dictionary = 'british.txt'
    
    with open(dictionary, 'r') as handle:
    	wordlist = handle.readlines()
    	for x in range(0,len(wordlist)):
    		wordlist[x] = wordlist[x].strip()
    
    def generate_password(length = 4):
    	maximum = len(wordlist)
    	random_request = "http://www.random.org/integers/?num=" + str(length + 1) + "&min=0&max=" + str(maximum) + "&col=1&base=10&format=plain&rnd=new"
    	random_page = urllib2.urlopen(random_request)
    	random_integers = random_page.readlines()
    
    	for x in range(0, length):
    		random_integers[x] = int(random_integers[x].rstrip('\n'))
    
    	i = 0
    	password = []
    	while i < length:
    		new_word = wordlist[random_integers[i]]
    		password.append(new_word)
    		i = i + 1
    
    	password.append(random_integers[i][:2])
    	
    	password = '-'.join(password)
    	return(password)
    
    try:
    	query = int(sys.argv[1])
    	print(generate_password(query))
    except:
    	print(generate_password())
    

    How do y'all who use python with Alfred deal with parameters?

     

    Generally speaking, I think it's best to do a series of conditional checks for the length of argv. So your code could be rewritten to look something like this:

    import urllib2
    import sys
    
    args = sys.argv
    
    def generate_password(length = 4, dictionary = "british"):
        dict_file = dictionary.lower() + ".txt"
        with open(dict_file) as f:
            orig_list = f.readlines()
            wordlist = []
            for word in orig_list:
                wordlist.append(word.strip())
    
        maximum = len(wordlist)
        # etc.
        return password
    
    if len(args) == 1: #sys.argv[0] is always your script's name
        print generate_password()
    if len(args) == 2:
        query = int(args[1])
        print generate_password(length=query)
    if len(args) == 3:
        query = int(args[1])
        dictionary = str(args[2])
        print generate_password(length=query, dictionary=dictionary)
    

    Because—at least according to my quick experimenting—all the objects in sys.argv are type str, even if they can be cast to or treated as numbers, it'd be hard to test for whether the user entered just a dictionary name. You could do it by not adding .txt automatically, and then checking to see if .txt was in the argument's string:

    import sys
    
    
    args = sys.argv
    
    if len(args) == 2 and ".txt" in args[1]:
        print generate_password(dictionary=args[1])
    elif len(args) == 2:
        print generate_password(length=args[1])
    elif len(args) == 3:
        # etc.
    
  2. Hey everybody! So I've just made some changes to this workflow. In particular, you can now create filenames with spaces in them (slight oversight), and you can now delete files by entering their names and pressing Control+Return. Control+Return will still forget saved names and paths if you invoke the "Add File" or "Add Path" options, enter the filename or path again, and then press the key combination. Holding Command while pressing Return will still open the file after its creation. You can grab the update through Alleyoop, or at http://alfred.daniel.sh/Workflows/CreateNewFile.alfredworkflow

     

    Enjoy!

  3.  

    For the people that are having trouble pairing, I have two questions:

     

    1. Is iTunes running when you try to pair? (it should be)
    2. Do you have sharing enabled in iTunes?

     

    Oh, how foolish of me! Sharing was disabled. It looks to be working beautifully now—thanks a billion!

  4. Yea that's what I figured. Easy way is to actually just bundle the .py file to not make them install it but of course that increases the module size slightly ;)

     

    Well, since both six and biplist were small and easy to tweak so as to be imported with alp, and since it seemed like it could come up again, I decided to go ahead and do it.

     

    Meaning, as a general announcement, that alp now supports reading binary plists—no changes to implementation necessary.

     

    I added a link, @soulesschild, to your github profile in the code; let me know if I can be more direct with crediting you for the change in any way.

  5. Try this,

    1. Open Alfred's preferences and go to the Workflows pane
    2. Right click on the Up Next workflow and then click "Show in Finder"
    3. Open Terminal in /Applications/Utilities
    4. In Terminal, type "cd " (note the space at the end) and then drag the little blue folder icon from the top on the finder window into the terminal window and hit enter
    5. Now in Terminal, type "ruby pair.rb " followed by a 4-digit number pin and hit enter
    6. Paste the results here

     

     

    I'll look into this right away!

     

    Hey there!

     

    This is utterly brilliant, and I'm excited to start using it! Unfortunately, I'm having some trouble: I can't get iTunes to react, even using the Terminal command, which just runs without any output. I tried disabling Norton's firewall and LittleSnitch, but I never even got notice from them that a service was starting on your port. If it helps, ruby -v turns up ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]; I recently updated it with MacPorts, which I worry might be the source of the problem.

  6. Hi there,

    I'm honestly not sure, but I suspect that there's something wrong with the plist such that it's generating invalid XML. My guess, but it's only a guess, is that there's a UTF-8 character in the property list. You may have to use the codecs module to open the file, read it into memory, and then pass it to plistlib.readPlistFromString() by hand. I'll rewrite the alp code so that it does this—it's probably wise anyway—but give that a shot in the meantime and see if it does you any good.

     

    ETA: I've just pushed a change to Github that may help, but I'm not positive. Give it a shot and see how it works. If you'd be willing to e-mail me the plist file (d at daniel dot sh), that'd be great too.

  7.  

    In my case, it contains:

     

     

    Traceback (most recent call last):
      File "feedback.py", line 111, in <module>
        tag_feedback()
      File "feedback.py", line 49, in tag_feedback
        subtitle="Tag the Finder selection with '{0}'".format(tag),
    UnicodeEncodeError: 'ascii' codec can't encode character u'\u0308' in position 10: ordinal not in range(128)

     

    Alright, I've just uploaded a new version to http://alfred.daniel.sh/Workflows/OpenMetaTags.alfredworkflow that will hopefully correct the problem. If not, let me know.

  8. Hey this is pretty cool.  Do you think it would be possible to add an actual File Action to tag selected files?  Thanks for making this!

     

    I'll give it some thought, but I don't think so; all the internal searching is done by tag, not by file.

     

     

    Thanks for doing this. However, for some reason, after typing "tag" and seeing "Gathering tags..." no tag list is displayed. :(  (I know there are many OpenMeta tags in use since Tags or Yep are working fine.) Any idea why this is happening?

     

    I'm on 10.8.3. Alfred 2.0.3.

     

     

    I am having the same issue reported by mjv above. Also on 10.8.3 and Alfred 2.0.3.

     

    This is a great idea for a workflow. Thanks to author for his efforts.

     

    Could you check the workflow's folder for a file called "feedback.log" and let me know what it contains? Thanks.

  9. Thanks, it's working great now.

     

    The only last thing (very minor), I wonder why when I search for something like "fozzy", the results don't seem to match what the iTunes store shows: http://imgur.com/wjMSIIT.png

     

    Thanks again! This script is awesome!  :)

    Yeah; I have no doubt that the search API Apple exposes works differently from the search in iTunes itself. Among other things, the API requires that I make two requests for a basic keyword search: one for "items," and one for "artists," and so artist results will always be the second-place set, even when they're more relevant. It also just has a more general habit of returning crummier, less relevant results that I can't really account for: I've been over and over the API docs looking for a different way to ask it the question I want to ask without any luck. Consequently, this is the workflow of mine I use least often. *shrug*

  10. Hi, thank you for the quick response. Is it checking a dropbox location when is it timing out? There are sometimes some connection issues to dropbox from China so perhaps that is causing the problem. Although I cant seem to access your site either for the new version without my VPN so that could be it too. Thank you for the new version though.

     

    It was actually the update-check for Alleyoop itself that was timing out, and so it's indeed my site. I believe that some of the workflows are hosted on Dropbox; a number are on Github; some are on personal sites.

  11. thanks for this looks great, but does not work for me. i know i have some workflows that support it because i downloaded some just today that have alleyoop support but when i run oop? it does not list any workflows it just says "checking installed workflows" and doesnt actually list anything. any ideas? thank you.

    It would be helpful if you could post the contents of "all.log" from the workflow's folder here so that I can get a better idea of what's going on.

  12. Thanks! But now I'm getting no results in Alfred for 'app' and 'iph'.

    I made a couple of changes to get it running again; try http://alfred.daniel.sh/Workflows/iTunesStore.alfredworkflow

     

    International users will be pleased to know that they can now set the country whose iTunes/App Store is searched by modifying the file ~/Library/Application Support/Alfred 2/Workflow Data/com.danielsh.its/settings.json and including a key--value pair like this:

     

    {
        "country": "NL"
    }
    

     

     

    Aw man :-( Is there a way to download the older version which still had the old functionality? Or where is this functionality in the python script so I can modify myself? (and set the script to r/o to prevent future updates).

    I've uploaded the old version to http://alfred.daniel.sh/Workflows/iTunesStore (Old).alfredworkflow, but I don't plan to support it or update it any further; it won't have feature parity and I can't drive myself nuts keeping two versions up-to-date.

  13. Excellent work!!!!!! No rush at all, take your time!!! 'app' works perfectly for me, but just a couple issues with 'it's & 'iph':

     

    • 'its' & 'iph' give this error for the fallback search (any term): 

    unoLpZ9.png

    • 'its' fallback sometimes doesn't register as option:

    1xIho1k.png

    • 'its' misses a lot of things that are indeed in the itunes store (I've waited for it to load and it never does, yet it works on other things):

    G7uYjIN.png

     

    Sorry for all the requests, it's okay if you don't have the time, or just dont' want to do such craziness.

    Not to worry; nobody likes bugs. I think I've squashed at least some of them in the latest version, so let me know how it works for you.

     

     

    Any chance you could incorporate an additional key input modifier to open the web page instead of directly in iTunes. I really preferred the initial (older) method and don't want to change scripts :(

    I'm afraid that since it's just a script filter, there's no way I can see to do it without adding three more separate scripts or supporting two versions at once, neither of which is hugely appealing. I've been trying to get it to behave like this since the beginning, so I'm more inclined to stick with this version. If the search works the way it's supposed to, I imagine that most people will want to go straight to purchasing an item; if it doesn't, opening a web browser is way more memory-hogging than iTunes or the App Store.

  14. Hah, thanks! So the best I can do for now is catch the error, log it, and continue on to the next workflow hoping that things are better the next time around; it won't just fail on you, but if you notice that some workflows are conspicuously missing then it'll make sense to check the debug.log file for errors. I take this to be a slight improvement, at least, till I can figure out why this module is breaking. Self-update or download here.

  15. Sorry it took me so long to get around to this, gang, but I wasn't getting e-mail updates from this thread for some reason. I've just posted a new version of the workflow that updates some of the backend stuff, hopefully making it a bit faster, adds a direct fallback search in the App Store and iTunes Store, searches for artists, and opens the links it returns in the pertinent Store directly rather than jumping to a Web page. You can download it here or, if you've downloaded it recently, update it through Alleyoop.

×
×
  • Create New...