allow names for STOP playlist entries avoid crashing when file to open cannot be read get rid of last PyGtk2 remains
Stefan Schuermans

Stefan Schuermans commited on 2014-01-15 21:52:48
Showing 5 changed files, with 23 additions and 16 deletions.

... ...
@@ -1,7 +1,7 @@
1 1
 #! /usr/bin/env python
2 2
 
3 3
 # BlinkenArea Stage Director
4
-# Copyright 2013 Stefan Schuermans <stefan@blinkenarea.org>
4
+# Copyright 2013-2014 Stefan Schuermans <stefan@blinkenarea.org>
5 5
 # Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
6 6
 # a blinkenarea.org project - https://www.blinkenarea.org/
7 7
 
... ...
@@ -19,7 +19,7 @@ class Playlist:
19 19
     - entries are played one after another
20 20
     - playing halts at stop points
21 21
     - <entry> = <name> <whitespace> <duration>
22
-    - <stop point> = ""
22
+    - <stop point> = <name>
23 23
     - <name> = [A-Za-Z0-9_]+
24 24
     - <duration> = ((<hours>:)?<minutes>:)?<seconds>
25 25
     - <hours> = [0-9]+
... ...
@@ -33,10 +33,12 @@ class Playlist:
33 33
                       #                      "name": string, name of entry
34 34
                       #                      "durtaion": float, in seconds }
35 35
     self.reEntry = re.compile("^\s*([A-Za-z0-9_]+)\s+([0-9:.]+)\s*$")
36
+    self.reStop = re.compile("^\s*([A-Za-z0-9_]+)\s*$")
36 37
 
37 38
   def read(self, filename):
38 39
     """read the playlist from filename, replacing the current playlist"""
39 40
     self.entries = []
41
+    try:
40 42
       f = open(filename, "r")
41 43
       for line in f:
42 44
         mEntry = self.reEntry.match(line)
... ...
@@ -49,9 +51,15 @@ class Playlist:
49 51
           #print("DEBUG playlist entry normal %s %f" %
50 52
           #      (self.entries[-1]["name"], self.entries[-1]["duration"]))
51 53
         else:
52
-        self.entries.append({"type": "stop"})
54
+          mStop = self.reStop.match(line)
55
+          if mStop:
56
+            name = mStop.group(1)
57
+            self.entries.append({"type": "stop",
58
+                                 "name": name})
53 59
             #print("DEBUG playlist entry stop")
54 60
       f.close()
61
+    except IOError:
62
+      pass
55 63
 
56 64
   def update(self, store):
57 65
     """update the contents of a Gtk ListStore with the contents of this
... ...
@@ -63,7 +71,7 @@ class Playlist:
63 71
         name = entry["name"]
64 72
         duration = time_fmt.sec2str(entry["duration"])
65 73
       else:
66
-        name = ""
74
+        name = entry["name"]
67 75
         duration = "STOP"
68 76
       store.append([idx, Pango.Weight.NORMAL, name, duration])
69 77
       idx = idx + 1
... ...
@@ -1,12 +1,12 @@
1 1
 Intro 1:00
2 2
 Robots 15:00
3
-
3
+Pause_A
4 4
 Future 1:2:3
5 5
 This_is_a_very_long_name_with_a_very_long_duration 11:12:13.14
6 6
 some_entries 5:6
7 7
 to_make 7:8
8 8
 list_longer 9:0
9
-
9
+Pause_B
10 10
 TheEnd 9:8.7
11 11
 Outro 0.2
12
-
12
+Pause_C
... ...
@@ -8,7 +8,7 @@
8 8
     <property name="type_hint">dialog</property>
9 9
     <property name="program_name">BlinkenArea Stage Director</property>
10 10
     <property name="version">0.1.1</property>
11
-    <property name="copyright" translatable="yes">Copyright 2013 Stefan Schuermans &lt;stefan@blinkenarea.org&gt;
11
+    <property name="copyright" translatable="yes">Copyright 2013-2014 Stefan Schuermans &lt;stefan@blinkenarea.org&gt;
12 12
 Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
13 13
 a blinkenarea.org project - https://www.blinkenarea.org/</property>
14 14
     <property name="website">https://www.blinkenarea.org</property>
... ...
@@ -561,7 +561,7 @@ a blinkenarea.org project - https://www.blinkenarea.org/</property>
561 561
                 </child>
562 562
               </object>
563 563
               <packing>
564
-                <property name="expand">False</property>
564
+                <property name="expand">True</property>
565 565
                 <property name="fill">True</property>
566 566
                 <property name="position">2</property>
567 567
               </packing>
... ...
@@ -1,13 +1,13 @@
1 1
 #! /usr/bin/env python
2 2
 
3 3
 # BlinkenArea Stage Director
4
-# Copyright 2013 Stefan Schuermans <stefan@blinkenarea.org>
4
+# Copyright 2013-2014 Stefan Schuermans <stefan@blinkenarea.org>
5 5
 # Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
6 6
 # a blinkenarea.org project - https://www.blinkenarea.org/
7 7
 
8 8
 import os
9
+from gi.repository import GObject
9 10
 from gi.repository import Gtk
10
-import gobject
11 11
 from gi.repository import Pango
12 12
 import socket
13 13
 import struct
... ...
@@ -67,8 +67,8 @@ class StageDirector:
67 67
     self.setupSock()
68 68
     self.updateEntry()
69 69
     self.updateButtonVisibility()
70
-    gobject.timeout_add(10, self.onTimer10ms)
71
-    gobject.timeout_add(100, self.onTimer100ms)
70
+    GObject.timeout_add(10, self.onTimer10ms)
71
+    GObject.timeout_add(100, self.onTimer100ms)
72 72
 
73 73
   def showPosition(self):
74 74
     """update the position texts next to the position slider"""
... ...
@@ -121,8 +121,7 @@ class StageDirector:
121 121
       self.stEntryIdx = -1
122 122
     # get name of current entry
123 123
     self.stName = ""
124
-    if self.stEntryIdx >= 0 and \
125
-       self.playlist.entries[self.stEntryIdx]["type"] == "normal":
124
+    if self.stEntryIdx >= 0:
126 125
       self.stName = self.playlist.entries[self.stEntryIdx]["name"]
127 126
     # make current entry bold, all others non-bold
128 127
     def update(model, path, it, user_data):
... ...
@@ -1,7 +1,7 @@
1 1
 #! /usr/bin/env python
2 2
 
3 3
 # BlinkenArea Stage Director
4
-# Copyright 2013 Stefan Schuermans <stefan@blinkenarea.org>
4
+# Copyright 2013-2014 Stefan Schuermans <stefan@blinkenarea.org>
5 5
 # Copyleft: GNU public license - http://www.gnu.org/copyleft/gpl.html
6 6
 # a blinkenarea.org project - https://www.blinkenarea.org/
7 7
 
8 8