Page 3 of 3

Re: How to Use AppleScript to Display Logs in Indigo Touch

PostPosted: Thu Feb 01, 2018 11:59 am
by Different Computers
Can you just restate the problem?

Sorry. Is there a way to trim the time stamps out of the variable result? The timestamp takes up most of the page width.

Re: How to Use AppleScript to Display Logs in Indigo Touch

PostPosted: Thu Feb 01, 2018 2:43 pm
by jay (support)
I think this'll do it (untested):

Code: Select all
import sys
import collections
import re

def tail(iterable, N):
    deq = collections.deque()
    for thing in iterable:
        if len(deq) >= N:
            deq.popleft()
        deq.append(thing)
    return list(deq)

# A list of the variable IDs - this script doesn't create them so they have to exist already
variable_ids = [1, 2, 3, 4, 5]

lines = tail(open("/Library/Application Support/Perceptive Automation/Indigo 7/Logs/indigo_log.txt"), len(variable_ids))
for index, line in enumerate(lines):
    # if the line starts with the date/time string formatted like this: 2018-02-01 00:00:24.350
    if re.match(r'^[0-9]{4}\-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}', line):
        # remove everything from the start of the line through the first tab, which removes the date
        line = "\t".join(line.split("\t")[1:])
    indigo.variable.updateValue(variable_ids[index], value=line)

Re: How to Use AppleScript to Display Logs in Indigo Touch

PostPosted: Thu Feb 01, 2018 2:50 pm
by Different Computers
Thank you!

I'll try it tonight.

Re: How to Use AppleScript to Display Logs in Indigo Touch

PostPosted: Thu Feb 01, 2018 6:01 pm
by Different Computers
Jay, thanks again.

Your script was once again perfect!