+def default_config(encoding="UTF-8"):
+ """Write the default config"""
+ open("%s/config" % testroot, "w").write(
+ """home %s
+collection fs %s %s/tracks
+scratch %s/scratch.ogg
+queue_pad 5
+stopword 01 02 03 04 05 06 07 08 09 10
+stopword 1 2 3 4 5 6 7 8 9
+stopword 11 12 13 14 15 16 17 18 19 20
+stopword 21 22 23 24 25 26 27 28 29 30
+stopword the a an and to too in on of we i am as im for is
+username fred
+password fredpass
+plugins
+plugins %s/plugins
+plugins %s/plugins/.libs
+player *.mp3 execraw disorder-decode
+player *.ogg execraw disorder-decode
+player *.wav execraw disorder-decode
+player *.flac execraw disorder-decode
+tracklength *.mp3 disorder-tracklength
+tracklength *.ogg disorder-tracklength
+tracklength *.wav disorder-tracklength
+tracklength *.flac disorder-tracklength
+api rtp
+broadcast 127.0.0.1 %d
+broadcast_from 127.0.0.1 %d
+mail_sender no.such.user.sorry@greenend.org.uk
+""" % (homelink, encoding, testroot, testroot, top_builddir, top_builddir,
+ port, port + 1))
+
+def common_setup():
+ global homelink
+ remove_dir(testroot)
+ os.makedirs(testroot)
+ os.makedirs("%s/home" % testroot)
+ # Establish a symlink to the home directory, to keep the socket pathnames
+ # short enough.
+ tmpdir = "/tmp"
+ for v in ["TMPDIR", "TMP"]:
+ try: tmpdir = os.environ[v]
+ except KeyError: pass
+ else: break
+ for i in xrange(1024):
+ r = base64.b64encode(os.urandom(9)).replace("/", "_")
+ f = "%s/disorder-home.%s" % (tmpdir, r)
+ try:
+ os.symlink("%s/home" % testroot, f)
+ except OSError, e:
+ if e.errno != errno.EEXIST: raise
+ else:
+ homelink = f
+ break