summaryrefslogtreecommitdiff
blob: 3a80f1e31d657dcbb57d3c52d1a67e5c19d1d6ee (plain)
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
Index: code/g.py
===================================================================
--- code/g.py   (revision 406)
+++ code/g.py   (revision 407)
@@ -142,14 +142,21 @@
     musicarray = []
     musicarraylen=0
     musicpath=path.join(data_loc, "..", "music")
+    default_music_available = True
     if not path.isdir(musicpath):
-        makedirs(musicpath)
-    temp_ls = listdir(musicpath)
-    temp_ls_len = len(temp_ls)
-    for file_name in temp_ls:
-        if file_name[-3:] == "ogg" or file_name[-3:] == "mp3":
-            musicarray.append(path.join(musicpath, file_name))
+        try:
+            makedirs(musicpath)
+        except:

+            # We don't have permission to write here.  Don't bother
+            # trying to load music.
+            default_music_available = False
+
+    if default_music_available:
+        for file_name in listdir(musicpath):
+            if file_name[-3:] == "ogg" or file_name[-3:] == "mp3":
+                musicarray.append(path.join(musicpath, file_name))
+
     #also, grab any user files
     musicpath=path.join(get_save_folder(True), "music")
     if not path.isdir(musicpath):