webcalendar

Check-in [c6c2a85406]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Quick-n-dirty CLI display of a calendar.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:c6c2a8540639a17e369e7f69fdf588717f7342184cdd1939246eedd66fd9d1db
User & Date: ajv-899-334-8894@vsta.org 2018-01-11 23:52:32
Context
2018-01-12
00:02
cron hook for event reminders check-in: 48b1bd199d user: ajv-899-334-8894@vsta.org tags: master, trunk
2018-01-11
23:52
Quick-n-dirty CLI display of a calendar. check-in: c6c2a85406 user: ajv-899-334-8894@vsta.org tags: master, trunk
23:51
Update path. Fix false positive when we should filter by days of week. Include account name in Python event dict, sometimes useful in displaying events. check-in: 774850c495 user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added cgi-bin/ttoday.py.





















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python
#
# ttoday.py
#	Display events for today, text mode
#
import sys, time, os
from webcal import cmp_time
import webcal
import pdb

# By default, display events for Today
Target = webcal.Today

# Filled in by authen (or debug)
uname = os.environ.get("USER", "nobody")

# Set up when we're manually invoked (for testing)
def init_cli():
    global uname, Target

    if not os.isatty(0):
	raise Exception, "Bad CLI invocation"
    if len(sys.argv) > 1:
	uname = sys.argv[1]
    if len(sys.argv) > 2:
	Target = time.strptime(sys.argv[2], "%m/%d/%Y")

# Shortcut; we use it a lot
w = sys.stdout.write

# Pick out entries for today
def filter_target(ev):
    global Target
    res = ev.happens(Target)
    return res

def run():
    global w, uname, Target

    print time.strftime("%A %m/%d/%Y", Target) + ":"
    evs = sorted(webcal.load_user(uname, filter_target),
	cmp=lambda ev1,ev2: cmp_time(ev1.begin, ev2.begin))

    for ev in evs:
	if ev.untimed:
	    w("      %s\n" % (ev.name,))
	    continue
	w("%s " % (time.strftime("%H:%M", ev.begin),))
	if ev.uname != uname:
	    w("%8s " % (ev.uname,))
	else:
	    w("%8s " % (" ",))
	w("%s\n" % (ev.name,))

if __name__ == "__main__":
    init_cli()
    run()
    sys.exit(0)