Jump to content

xilopaint

Member
  • Posts

    896
  • Joined

  • Last visited

  • Days Won

    24

Posts posted by xilopaint

  1. Hey deanishe, I am thinking about starting to use Notify.app in some workflows of mine. From what I understand, I have to "install" the app with workflow.notify.install_notifier() so it's copied to data directory.


    I don't see the best implementation for this. Should I write my script in a way it checks if Notify.app is present in data directory otherwise workflow.notify.install_notifier() is executed? I feel there's a better way.

  2. 6 hours ago, deanishe said:

    Yup. Writing the status to a file is probably the best way.

     

    Another possibility is to start a server for your Script Filter to fetch the status from, but that seems like overkill. 

     

    I tried to use settings API of alfred-workflow and had some issues. In some tests the last line of the subprocess output was not added to settings.json file. Using "with statements" to write and open the files I had no issues. Is wf.settings somewhat slow or bad for using in loops?

     

    This is working well:

    proc = Popen(command, shell=True, stdout=PIPE)
    page_number = 1
    
    while proc.poll() is None:
        line = proc.stdout.readline()
        if "SOURCE PAGE" in line:
            with open(file_page_number, 'w') as f2:
                f2.write(str(page_number))
            page_number = page_number + 1

    But this is not always working:

    proc = Popen(command, shell=True, stdout=PIPE)
    page_number = 1
    
    while proc.poll() is None:
        line = proc.stdout.readline()
        if "SOURCE PAGE" in line:
            wf.settings['page_number'] = str(page_number)
            page_number = page_number + 1

    I would like to use wf.settings if possible, but it seems unreliable in my tests. I should be missing something.

  3. Thank you, @deanishe.

     

    I had already read a similar solution here. My problem is my subprocess is executed from a Run Script object and I need the capability of invoking a Script Filter whenever I want to check the progress (what can happen multiple times in a single execution with large files) . How can I better achieve this? Should I write the output of the subprocess in a file and retrieve the data with the Script Filter or there is any better way?

  4. @deanishe

     

    The Optimize action of this workflow executes a subprocess called k2pdfopt. While running, this subprocess outputs the progress of the operation (tipically informing the conclusion of each page of the PDF file). Look:

     

    ZJYMM7t.png

     

    Since the operation can take a long time in larger PDF files it would be very neat to show the progress of the operation in Alfred bar, maybe invoking a Script Filter or something that can inform how many pages were processed. Do you know if it's possible to retrieve the output of the subprocess for this purpose?

  5. On 7/21/2017 at 0:28 PM, deanishe said:

    Don't leave the forums or quit making workflows on my account. It seems I'm the only person who gets annoyed by having to remind you to post your workflow, not a picture of it, every single time.

     

    I'll stick you on my ignore list, and then everyone's happy.

     

    I'm not happy. The most funny thing in this forum was reading your angry posts in nikivi's threads. :D

×
×
  • Create New...