From 08e45e9e3a470d8b743f09aa1bcbafa1979fe4f3 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 10 Sep 2007 09:21:15 +0000 Subject: [PATCH] Removed old dir, created tools dir --- old/d-fuzz.py | 73 ------------------------ old/d-fuzz_loop.sh | 6 -- old/d-fuzz_template.xml | 11 ---- old/d-fuzz_tools.py | 85 ---------------------------- old/xmltodict.py | 55 ------------------ xmltodict.py => tools/xmltodict.py | 0 xmltodict2.py => tools/xmltodict2.py | 0 7 files changed, 230 deletions(-) delete mode 100755 old/d-fuzz.py delete mode 100755 old/d-fuzz_loop.sh delete mode 100644 old/d-fuzz_template.xml delete mode 100755 old/d-fuzz_tools.py delete mode 100644 old/xmltodict.py rename xmltodict.py => tools/xmltodict.py (100%) rename xmltodict2.py => tools/xmltodict2.py (100%) diff --git a/old/d-fuzz.py b/old/d-fuzz.py deleted file mode 100755 index 189796b..0000000 --- a/old/d-fuzz.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/python - -import sys, os, string - -if len(sys.argv) == 1: - print """ - dfuzz : easy and light streaming tool - - Copyright (c) 2006 Guillaume Pellerin - distributed under the terms of the GNU Public License v2 - - depends : ezstream (patched), icecast2, python, - - Usage : dfuzz $1 $2 $3 $4 $5 - where $1 : station name - $2 : type (mp3 or ogg) - $3 : number of sub-channels - $4 : working directory - $5 : audio directory - $6 : icecast2 server name - $7 : icecast2 port - """ - sys.exit('') - -radio_name = sys.argv[1] -nb_ch = int(sys.argv[3]) -type = sys.argv[2] -work_dir = sys.argv[4] -audio_dir = sys.argv[5] -server = sys.argv[6] -port = sys.argv[7] -radio_description_file = work_dir+os.sep+radio_name+'.xml' -dfuzz_dir = '/usr/local/share/d-fuzz' -ez_tools_file = dfuzz_dir+os.sep+'d-fuzz_tools.py' - -f_descr = open(radio_description_file,'r') -l_descr = f_descr.readlines() -f_descr.close() - -f_ez_tools = open(ez_tools_file,'r') -l_tools = f_ez_tools.readlines() -f_ez_tools.close() - -for i in range(1,nb_ch+1): - ch_name_i = radio_name+'_'+type+'_'+str(i) - ch_ice_name_i = radio_name+'_'+str(i) - ch_pre_i = work_dir+os.sep+ch_name_i - fi_xml = open(ch_pre_i+'.xml','w') - fi_xml.write('\n') - fi_xml.write('http://'+server+':'+port+'/'+ch_ice_name_i+'.'+type+'\n') - fi_xml.write(''+string.upper(type)+'\n') - fi_xml.write('script\n') - fi_xml.write(''+ch_pre_i+'.py\n') - for line in l_descr: - fi_xml.write(line) - fi_xml.write('') - fi_xml.close() - fi_py = open(ch_pre_i+'.py','w') - fi_py.write('#!/usr/bin/python\n\n') - fi_py.write('import sys, os, random\n\n') - fi_py.write('Playdir="'+audio_dir+os.sep+'"\n') - fi_py.write('IndexFile="'+ch_pre_i+'_index.txt"\n') - fi_py.write('RandomIndexListFile="'+ch_pre_i+'_random_index_list.txt"\n') - fi_py.write('PlaylistLengthOrigFile="'+ch_pre_i+'_playlist_length.txt"\n\n') - for line in l_tools: - fi_py.write(line) - fi_py.close() - os.chmod(work_dir+os.sep+ch_name_i+'.py',0755) - os.system('d-fuzz_loop '+ch_pre_i+' &') - sys.exit(ch_pre_i+' started !') - - - diff --git a/old/d-fuzz_loop.sh b/old/d-fuzz_loop.sh deleted file mode 100755 index 6c2feaf..0000000 --- a/old/d-fuzz_loop.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -ulimit -c unlimited -while true; do -ezstream -c $1.xml > /dev/null; -sleep 3 -done diff --git a/old/d-fuzz_template.xml b/old/d-fuzz_template.xml deleted file mode 100644 index a0dc5ca..0000000 --- a/old/d-fuzz_template.xml +++ /dev/null @@ -1,11 +0,0 @@ -xxxxxxxxx -Your title here -Your URL here -Your genre here -Your station description here -You nominal bitrate here - - -The number of voices per channel -The samplerate -1 diff --git a/old/d-fuzz_tools.py b/old/d-fuzz_tools.py deleted file mode 100755 index 851942b..0000000 --- a/old/d-fuzz_tools.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/python - -#import sys, os, random - -#Playdir='/home/cellar/Cellar_playlist/' -#IndexFile='/home/cellar/stream/d-fuzz_1_index.txt' -#RandomIndexListFile='/home/cellar/stream/d-fuzz_1_random_index_list.txt' -#PlaylistLengthOrigFile='/home/cellar/stream/d-fuzz_1_playlist_length.txt' - -def randrange(start, stop): - values = range(start, stop) - random.shuffle(values) - while values: - yield values.pop() - raise StopIteration - -if not os.path.exists(IndexFile): - fi=open(IndexFile,'w') - fi.write("%d\n" % 0) - fi.close() -if not os.path.exists(RandomIndexListFile): - fil=open(RandomIndexListFile,'w') - fil.write("%d\n" % 0) - fil.close() -if not os.path.exists(PlaylistLengthOrigFile): - fill=open(PlaylistLengthOrigFile,'w') - fill.write("%d\n" % 0) - fill.close() - -playlist = os.listdir(Playdir) -nf = len(playlist) -#print nf - -fill=open(PlaylistLengthOrigFile,'rw') - -nforig=int(fill.readline()) - -if not nf == nforig: - fil=open(RandomIndexListFile,'w') - ril=randrange(0,nf) - #print ril - k=1 - for i in ril: - fil.write("%d\n" % (i)) -# fil.close() - -fi=open(IndexFile,'rw') -fil=open(RandomIndexListFile,'rw') - -#print nforig -if nforig < nf: - nforig = nf - -f_index=int(fi.readline()) - -#tmpil = fil.readlines() -f_index_list = range(nforig) -j = 0 -for i in fil.readlines(): - f_index_list[j] = int(i) - j+=1 - #print f_index_list[j] - -fi.close() -fil.close() -fill.close() - -if f_index == nf or f_index > nf: - f_index = 0 - -#print f_index_list[f_index] -#print f_index -print Playdir + playlist[f_index_list[f_index]] - -f_index+=1 - -fi = open(IndexFile,'w') -fi.write("%d" % (f_index)) -fi.close() - -fill=open(PlaylistLengthOrigFile,'w') -fill.write("%d" % (nf)) -fill.close() - - diff --git a/old/xmltodict.py b/old/xmltodict.py deleted file mode 100644 index 0d0fe44..0000000 --- a/old/xmltodict.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python - -# Easily import simple XML data to Python dictionary -# http://www.gmta.info/publications/parsing-simple-xml-structure-to-a-python-dictionary - -import xml.dom.minidom - -def haschilds(dom): - - # Checks whether an element has any childs - # containing real tags opposed to just text. - - for childnode in dom.childNodes: - if childnode.nodeName != "#text" and childnode.nodeName != "#cdata-section": - return True - - return False - -def indexchilds(dom, enc): - - childsdict = dict() - - for childnode in dom.childNodes: - - name = childnode.nodeName.encode(enc) - - if name == "#text" or name == "#cdata-section": - # ignore whitespaces - continue - - if haschilds(childnode): - v = indexchilds(childnode, enc) - else: - v = childnode.childNodes[0].nodeValue.encode(enc) - - if name in childsdict: - - if isinstance(childsdict[name], dict): - # there is multiple instances of this node - convert to list - childsdict[name] = [childsdict[name]] - - childsdict[name].append(v) - - else: - - childsdict[name] = v - - return childsdict - -def xmltodict(data, enc=None): - - dom = xml.dom.minidom.parseString(data.strip()) - return indexchilds(dom, enc) - - diff --git a/xmltodict.py b/tools/xmltodict.py similarity index 100% rename from xmltodict.py rename to tools/xmltodict.py diff --git a/xmltodict2.py b/tools/xmltodict2.py similarity index 100% rename from xmltodict2.py rename to tools/xmltodict2.py -- 2.39.5