batch mode

23 views
Skip to first unread message

Mel

unread,
Dec 2, 2020, 12:17:31 PM12/2/20
to Event and Task Manager
Is there a way to use the new etm4 in "batch" mode as there
was in 'etm3'?  I use etm as a simple calendar program and
with all previous versions I just had it running to see
alerts and I never used any of the gui features.  I have
calendar entries for an old program and I wrote a program
to convert them to ".txt" (and before that ".text") files
for etm to read.  Then, for example, to see my calendar for
say Dec 4, I run this in a terminal or from a shell script:

  etmtk.py c c ddd MMM dd yyyy -w68 -b 12/04/2020 -e 12/04/2020 + 1d

Etm3 has all I need so I'm mainly curious, if I created  data
for etm4 would it be possible to do something similar with it?

Mel

P.S.  Minor bugs
(1) The first thing I tried was exporting to json in etm3 and
    importing it into etm4. I got in file model.py function schedule:
    for the line:
        if 'c' in item and item['c'] in omit:
    exception TypeError: argument of type 'NoneType' is not iterable

    Because I needed "omit_extent: holiday" in my configuration "cfg.yaml"
    Changing the above line to:
        if omit and 'c' in item and item['c'] in omit:
    avoids the exception.  Maybe need a warning message instead?

(2) For the online user manual at https://dagraham.github.io/etm-dgraham/
    there's a small typo for the "archived reminders" link under "Notes":
        <li><a href="#archivedg-reminders">archived reminders</a></li>
should be:
        <li><a href="#archived-reminders">archived reminders</a></li>

Dan

unread,
Dec 3, 2020, 9:55:05 AM12/3/20
to Event and Task Manager
etm4 will import files with a '.text' extension that contain a single etm reminder on each line. Select 'import file' from the etm menu or press F5 and enter the file path. Some options have changed in etm3 -> etm4. E.g.,  @c is now calendar instead of context and @l is now context/location. The discussion has moved to groups.io/g/etm.

Thanks for the bug reports.

Mel

unread,
Dec 3, 2020, 6:25:11 PM12/3/20
to Event and Task Manager
I was aware of how to import/write in 'batch' mode and
was asking if there was a way to read the data using
a script.  In particular an equivalent etm4 command
like the etm3 terminal command to see the entries for
a given day(s):


  etmtk.py c c ddd MMM dd yyyy -w68 -b 12/04/2020 -e 12/04/2020 + 1d

If not, I guess I could write my own since all the info
is in the 'db.json' file.  Any suggestions of where I
should look in your source for hints on how to do that.

Dan

unread,
Dec 4, 2020, 9:57:45 AM12/4/20
to Event and Task Manager
This is built into etm4 which, after all, is itself a console script. You can execute queries on the data store by pressing 'q' to open query view. Queries from the current session are stored and you can scroll through the history with the cursor up and down keys, select a query, optionally edit it, and execute it. Results are displayed in a normal etm4 view so that items can be selected, their details displayed and/or modified. The results of the query as displayed can be copied to the system clipboard by pressing Ctrl-C. Frequently used queries can be added to cfg.yaml with shortcuts and then executed in etm using their shortcuts. Tab completion is supported for these shortcuts. One of the advantages of using the built-in query mechanism is that the data store is only loaded once when etm starts and so individual queries do not incur this overhead.   

If you want to duplicate or improve on this in your own script, the documentation for queries in https://tinydb.readthedocs.io/en/latest/index.html might be the best place to start. In etm itself,  the ETMQuery class in view.py contains most of the relevant code.

By the way,  etm+ is a shell "entry point" provided in the etm4 distribution that you can use to add reminders to the database. E.g.,  invoking

$ erm+ "the details of a reminder"

or

$ echo " the details of a reminder" | etm+

in a terminal would append the reminder to the file "inbasket.text" in your etm directory. etm iself will display an icon when this file exists to remind you to import it. This file is the default when you press F5 to import a file. The code for this is given by the function "inbasket" in __main__.py.

Please, if you want to continue this discussion, post to groups.io/g/etm so that others can share.
Reply all
Reply to author
Forward
0 new messages