Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [24a87e43ef]:

To Artifact [6b151802f7]:


39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53







-
+







have been made to make it work on Python 2.6 (sched module changes).
The version in Turbogears is based on the original stand-alone Kronos.
This is open-source software, released under the MIT Software License:
http://www.opensource.org/licenses/mit-license.php

"""

__version__="2.0"
__version__="2.1"

__all__ = [
    "DayTaskRescheduler",
    "ForkedIntervalTask",
    "ForkedMonthdayTask",
    "ForkedScheduler",
    "ForkedSingleTask",
271
272
273
274
275
276
277
278
279
280
281




282
283
284
285
286
287
288
271
272
273
274
275
276
277




278
279
280
281
282
283
284
285
286
287
288







-
-
-
-
+
+
+
+








    def _run(self):
        # Low-level run method to do the actual scheduling loop.
        while self.running:
            try:
                self.sched.run()
            except Exception as x:
                print >>sys.stderr, "ERROR DURING SCHEDULER EXECUTION",x
                print >>sys.stderr, "".join(
                    traceback.format_exception(*sys.exc_info()))
                print >>sys.stderr, "-" * 20
                print("ERROR DURING SCHEDULER EXECUTION",x, file=sys.stderr)
                print("".join(
                    traceback.format_exception(*sys.exc_info())), file=sys.stderr)
                print("-" * 20, file=sys.stderr)
            # queue is empty; sleep a short while before checking again
            if self.running:
                time.sleep(5)


class Task:
    """Abstract base class of all scheduler tasks"""
309
310
311
312
313
314
315
316
317
318



319
320
321
322
323
324
325
309
310
311
312
313
314
315



316
317
318
319
320
321
322
323
324
325







-
-
-
+
+
+








    def execute(self):
        """Execute the actual task."""
        self.action(*self.args, **self.kw)

    def handle_exception(self, exc):
        """Handle any exception that occured during task execution."""
        print >>sys.stderr, "ERROR DURING TASK EXECUTION", exc
        print >>sys.stderr, "".join(traceback.format_exception(*sys.exc_info()))
        print >>sys.stderr, "-" * 20
        print("ERROR DURING TASK EXECUTION", exc, file=sys.stderr)
        print("".join(traceback.format_exception(*sys.exc_info())), file=sys.stderr)
        print("-" * 20, file=sys.stderr)


class SingleTask(Task):
    """A task that only runs once."""

    def reschedule(self, scheduler):
        pass
557
558
559
560
561
562
563
564

565
566

567
568
569
570
571
572

573
574
575

576
577
578

557
558
559
560
561
562
563

564
565

566
567
568
569
570
571

572
573
574

575
576
577

578







-
+

-
+





-
+


-
+


-
+
        """Monthday Task that executes in its own process."""
        pass



if __name__=="__main__":
    def testaction(arg):
        print ">>>TASK",arg,"sleeping 3 seconds"
        print(">>>TASK",arg,"sleeping 3 seconds")
        time.sleep(3)
        print "<<<END_TASK",arg
        print("<<<END_TASK",arg)

    s=ThreadedScheduler()
    s.add_interval_task( testaction, "test action 1", 0, 4, method.threaded, ["task 1"], None )
    s.start()
    
    print "Scheduler started, waiting 15 sec...."
    print("Scheduler started, waiting 15 sec....")
    time.sleep(15)
    
    print "STOP SCHEDULER"
    print("STOP SCHEDULER")
    s.stop()
    
    print "EXITING"
    print("EXITING")