Jump to content

obstschale

Member
  • Posts

    18
  • Joined

  • Last visited

Posts posted by obstschale

  1. Hi Folks,

     

    I have a problem that Alfred does not lists all installed applications. There are several apps which Alfred cannot find. For example Microsoft Office Apps like Word or Lync are not listed. Let me quickly summarize what I tried so far to fix it:

     

    • I checked this page: http://support.alfredapp.com/kb:indexing
    • Spotlight is finding the apps
    • All Spotlight Search Results are checked in SystemPref.
    • All necessary folders are in Alfred's Search Scope (more about that later)
    • I reloaded Alfred's Cache many times (even quit it)

    I think I see a small pattern here. All Apps which are in /Applications are listed like intended. Only apps in subfolders like /Applications/Microsoft/ or /Application/Garmin are not listed. However, there are exceptions like /Applications/modelio/ or /Applications/MAMP/ are listed. Interestingly, both subfolders /Applications/Microsoft/ and /Applications/Garmin/ are in Alfred's Search Scope but /App/modelio and /App/MAMP are not in that list but Alfred knows these subfolders are in /Applications/.

     

    I have the feeling Alfred cannot recreate the index correctly. Is there a way I can force Alfred to do it?

  2. I tried so many possibilities but I can not solve the problem. I use now alp to generate the xml statement but that wasn't the problem. But I figured out that  the workflow works fine as long as the base (third argument) is less than 10. As soon as the new base has two digits Alfred will call the python script but the process does not end. But if I kill the process the correct xml statement will be printed in my log file. Totally weird!

     

    This is my python script and it works in the terminal but not with alfred. The process won't end if it tries to calculate the new number (lin 39). So think there is a problem in my int2base function. But why is it working in the terminal and with alfred upto number 9 as base?

     

    #!/usr/bin/env python
    
    """ Arguments
    	sys.argv[0] = filename
    	sys.argv[1] = number
    	sys.argv[2] = source
    	sys.argv[3] = destination
    """
    
    import sys
    import alp
    import string
    digs = string.digits + string.lowercase
    
    
    def int2base(x, base):
      if x < 0: sign = -1
      elif x==0: return '0'
      else: sign = 1
      x *= sign
      digits = []
      while x:
        digits.append(digs[x % base])
        x /= base
      if sign < 0:
        digits.append('-')
      digits.reverse()
      return ''.join(digits)
    
    
    if (len(sys.argv) == 4):
    	# calculate integer first
    	decimal = int(sys.argv[1], int(sys.argv[2]))
    	# create dictionary to create xml from it
    	decimalDic = dict(title=str(decimal), subtitle="Decimal", uid="decimal", valid=True, arg=str(decimal), icon="icons/decimal.png")
    	d = alp.Item(**decimalDic)
    
    	# calculate new number
    	conv = int2base(decimal, int(sys.argv[3]))
    	# create dictionary to create xml from it
    	convertDic = dict(title=conv, subtitle="Number to base " + str(sys.argv[3]), uid="conv", valid=True, arg=conv)
    	c = alp.Item(**convertDic)
    
    	itemsList = [d, c]
    	alp.feedback(itemsList)
    
    else:
    	errorDic = dict(title="Make sure to pass 3 numbers", subtitle="for help type \"nsc help\"", uid="error", valid=False, arg="error")
    	error = alp.Item(**errorDic)
    	alp.feedback(error)
    

     

    I call the script in alfred like this:

    python convertNumber.py {query} 2>&1 | tee nsc.log
    

     

     

    • I probably think somewhere in this forum my question is already answered, but I couldn't find it. :/

    So I was wondering what all the different workflow data is for. All the great Libs (post link) are able to find the cache dir, data dir, bundle id and different stuff. But why do I need this?

     

    David mentioned Data Storage here but I don't really understand what the difference between these two dirs is.

     

    Can any one explain me why my workflow should know the bundle ID, the cache and data dir?

  3. I encountered some issues with my workflow and David Ferguson suggested to use the module alp. This Module also includes a XML function and I guess this will also solve the lxml problem, because I will provide the XML lib with v2.1

     

    Anyhow, I still would like to see how you use the bc cmd line tool. Just for learning purpose :)

  4. First of all thx for your help David,

     

    a) I already assumed that my script is not finishing and that it has problems if not all 3 numbers were given. Therefore I check in my script if 3 parameters are given. If not I will output an valid XML error message which looks like this: http://d.pr/i/6np5

    B) I checked my XML carefully and if I run it in the terminal the xml looks good and nothing is messed up.

    c) I'm not sure about that that according to be, I tested it in the terminal and it looks good

    d) yes, otherwise it would be in my log file, wouldn't it?

  5. Hi Guys,

     

    I recently published my NSC workflow to convert numbers. But I have encountered a problem.

     

    If I try to convert a number using convert it will run the following script using

     

     

    python convertNumber.py {query} 2>&1 | tee nsc.log
    

     

    The problem is sometimes the number gets converted and everything works fine and the sometimes it is not working. Either Alfred wants to search the given string in Google or the "Please Wait" subtext will be displayed. Anyhow, whenever it is not working several Python process will start and will occupy fully the CPU.

     

    As you see above I already create a log file. If the script run perfectly the log file will contain the XML, thats fine. But if it isn't working there is no output.

     

    Do you have any idea why it isn't working?

     

    PS: All other script I use in this workflow are working just fine.

     

  6. Hi _mk_,

     

    thx for your input. I'm pretty new to python so I didn't know how to make it better so far and I installed lxml for another cmd line tool some time ago, so I know this module exist.

     

    Today I just saw another python script which uses not lxml but xml. Either I use this one (if it is a standard lib) or if you have a good suggestion just give me a pull request on github (is saw you forked my repo) and I probably will integrated your improvement. Looks like you have more python experience than me ;)

  7. NSC

     

    Workflow to convert numbers into other based systems.

     

    As a computer scientist student I deal everyday with binary, octal, hex and decimal numbers. Therefore I built this workflow with PHP for Alfred 1 and now I rebuilt it with Python for Alfred 2.

     

    Usage:

     

    5 different keywords are used:

    • decimal
    • binary
    • octal
    • hex
    • convert

    The first 4 act similar. You type the keyword (base of your number) and the number you want to convert. Alfred will show you the same number in the other 3 systems. You can select one of them and copied to your clipboard.

     

     
    readmedecimal.png

     

     

    To convert from or into another system beside these four, you use the keyword convert. Then you type your number, the base of your number and the base of the destination. NSC will display the decimal notation and the new number.

     
    To simplify this use the simple frase: "convert number 42 from with base 6 into base 4"

    readmeconvert.png
     

     

    Changelog

     

    can be found on GitHub: Changelog

     

    Download

    latest build: NSC Alfred Extension

    Requires: non
    Supports Alleyoop 2

     

    DownloadGitHubREADME

     

    _mk_ made a bash version of NSC. It can be found at GitHub.

×
×
  • Create New...