diff --git a/floppies/giulia/noweb/cgi-bin/index.cgi b/floppies/giulia/noweb/cgi-bin/index.cgi index 869c3b7..66ff565 100755 --- a/floppies/giulia/noweb/cgi-bin/index.cgi +++ b/floppies/giulia/noweb/cgi-bin/index.cgi @@ -7,27 +7,31 @@ from jinja2 import Template # Directory => ITEMS list (all files with a timestamp name, grouped) path = "/var/www/static/gait" try: - ff = os.listdir(path) + ff = os.listdir(path) except OSError: - ff = [] + ff = [] tpat = re.compile(r"^(\d\d\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)-(\d\d)") items = {} for f in ff: - base, ext = os.path.splitext(f) - ext = ext[1:] - m = tpat.match(f) - if m: - t = m.group(0) - if t not in items: - items[t] = {} - items[t][ext] = f + base, ext = os.path.splitext(f) + ext = ext[1:] + m = tpat.match(f) + if m: + t = m.group(0) + if t not in items: + items[t] = {} + items[t][ext] = f items = [items[key] for key in sorted(items, reverse=True)] for i in items[10:]: - for f in i.items(): - print "deleting ", f - fp = os.path.join(path, f) - os.unlink(fp) + for f in i.items(): + for ext in f: + fp = os.path.join(path, f[ext]) + try: + os.unlink(fp) + except IOError as e: + print ("Error deleting", e) + pass # dump the data (debugging) # print "Content-type: text/plain" # print "" @@ -43,37 +47,37 @@ print Template(u"""
-Here you can find footage of your walks.
-Here you can find footage of your walks.
+Steal a walk from another person's video. Download it.
-Steal a walk from another person's video. Download it.
+Promise me, you're gonna start using this walk for the rest of the day.
-Promise me, you're gonna start using this walk for the rest of the day.
+