Ejemplo n.º 1
0
def createNote(path, args):
	if "name" in args:
		global noteListDirty
		noteListDirty = True
		db.addNote(args["name"], "")
	
	return getNoteListCached()
Ejemplo n.º 2
0
def home():
    songlist = []
    if request.method == 'POST':
        if 'file' not in request.files:
            flash('No file part')
            if g.user:
                if g.user is not None and g.user.is_authenticated:
                    songlist = DatabaseAccess.getSongs()
            return render_template('home.html', list=songlist)
        file = request.files['file']
        if file.filename == '':
            flash('No selected file')
            if g.user:
                if g.user is not None and g.user.is_authenticated:
                    songlist = DatabaseAccess.getSongs()
            return render_template('home.html', list=songlist)
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            SongProcessor.process(
                os.path.join(app.config['UPLOAD_FOLDER'], filename), filename)
            if g.user:
                if g.user is not None and g.user.is_authenticated:
                    songlist = DatabaseAccess.getSongs()
            return render_template('home.html', list=songlist)
    if g.user:
        if g.user is not None and g.user.is_authenticated:
            songlist = DatabaseAccess.getSongs()
    return render_template('home.html', list=songlist)
Ejemplo n.º 3
0
def insertInDatabase(l_co):
    for e in l_co:
        if (DatabaseAccess.check(e)):
            print(
                str(e.getIpSrc()) + " Not changing from MAC " +
                str(e.getMacSrc()))
        else:
            print(str(e.getIpSrc()) + " change to " + str(e.getMacSrc()))
            DatabaseAccess.insert(e)
Ejemplo n.º 4
0
def deleteNote(path, args):
	if not "id" in args:
		return getNoteListCached()
	
	nodeId = args["id"]
	
	global noteListDirty
	noteListDirty = True
	db.deleteNote(nodeId)

	return getNoteListCached()
Ejemplo n.º 5
0
def process(file, filename):
    reader = WaveReader.WaveReader()
    translator = NoteTranslator.NoteTranslator()
    song = reader.readWave(file, filename)
    splitSignal = numpy.array_split(song.signal, song.beats)
    for index in range(0, len(splitSignal)):
        if index >= len(splitSignal):
            continue
        note = translator.signalToNote(splitSignal[index], song.sampleRate)
        song.note_on_beat.append((note, index))
    song = patternDetector(song)
    cleanpattern = song.pattern.replace("#", '')
    song.pattern = cleanpattern
    DatabaseAccess.saveSong(song, file)
Ejemplo n.º 6
0
def trackInfo():
    if g.user:
        if g.user is not None and g.user.is_authenticated:
            tracks = DatabaseAccess.getSongs()
            return render_template('trackInfo.html', tracks=tracks)
    else:
        return redirect('index')
Ejemplo n.º 7
0
def history():
    if g.user:
        if g.user is not None and g.user.is_authenticated:
            historyItems = DatabaseAccess.getHistory()
            return render_template('history.html', history=historyItems)
    else:
        return redirect('index')
Ejemplo n.º 8
0
def saveNote(path, args):
	
	if not "id" in args:
		return getNoteListCached()

	if "name" in args:
		name = args["name"]
	else:
		name = ""
	
	if "content" in args:
		content = args["content"]
	else:
		content = ""

	global noteListDirty
	noteListDirty = True
	db.updateNote(args["id"],name,content)
	
	return getNoteListCached()
Ejemplo n.º 9
0
def getNoteListCached():
	"""keeps a copy of the note list html. only building it again when notes are renamed, added, or deleted."""
	global noteListDirty, noteList

	if noteListDirty:
		noteList = ""
	
		for name,id in db.noteNameList():
			noteList += """<li onclick="loadNote('""" + str(id) + """')">""" + name + """</li>"""
		noteListDirty = False
		return noteList
	else:
		return noteList
Ejemplo n.º 10
0
def updateTrackHistory():
    if g.user:
        if g.user is not None and g.user.is_authenticated:
            user = g.user
            change = models.TrackChange()
            change.user_id = user.id
            change.currentTrack = request.args.get('currentSong', "", type=str)
            change.pattern = request.args.get('pattern', '', type=str)
            change.nextTrack = request.args.get('nextSong', "", type=str)
            change.startTime = request.args.get('startTime', 0.0, type=float)
            change.endTime = request.args.get('endTime', 0.0, type=float)
            change.timeOfChange = datetime.datetime.now()
            DatabaseAccess.AddTrackChange(change)
            return "success"
Ejemplo n.º 11
0
def readFile(filename):
    f_name = filename.split("/")
    f_n = f_name[len(f_name) - 1]
    f_dom = f_n.split("_")
    DOMAIN = f_dom[2]
    f = open(filename, "r")
    content = f.read()
    lines = content.split("\n")
    l_c = list()
    for line in lines:
        co = getData(line)
        if co != None:
            co.setDomain(DatabaseAccess.getDomain(DOMAIN))
            co.setPublicIp(f_dom[5])
            l_c.append(co)
            print co.getMacDst()
    return l_c
Ejemplo n.º 12
0
    search_ok = Button(search_root, text='Search', command=trySearch)
    search_ok.grid(row=4, column=5, padx=5, pady=5)

    search_root.mainloop()


root = Tk()
#root.resizable(0,0)
root.geometry("+700+300")
familyLabel = Label(root, text="Families:")
familyLabel.grid(row=2, padx=5, sticky=W + S)
root.minsize(width=690, height=420)
root.maxsize(width=690, height=420)

# All database access operations will be done by this object
dbAccess = DatabaseAccess()

id_List = dbAccess.getIDList()

scrollbar = Scrollbar(root)
scrollbar.grid(row=3, column=2, rowspan=3, sticky=N + S)
#scrollbar.config(height = 16)

listbox = Listbox(root, yscrollcommand=scrollbar.set)
listbox.config(width=16, height=20)
listbox.grid(row=3, column=0, rowspan=3, padx=5)

root.grid_rowconfigure(1, minsize=10)
root.grid_columnconfigure(4, minsize=50)
#root.grid_rowconfigure(10, minsize=100)
Ejemplo n.º 13
0
def loadNote(path, args):
	if not "id" in args:
		return editorHTML.format(name="", value = "", id = "")
	nodeInfo = db.getNote(args["id"])
	
	return  editorHTML.format(name=nodeInfo[0], value = nodeInfo[1], id = args["id"])
Ejemplo n.º 14
0
Serving on localhost:8080

> python SimpleNoteServer.py
Serving on localhost:8000 """

import SimpleHTTPServer
import SocketServer
import logging
import cgi

import sys
import random as rnd

import DatabaseAccess as db

print db.noteNameList()

print db.getNote("10")



if len(sys.argv) > 2:
	PORT = int(sys.argv[2])
	I = sys.argv[1]
elif len(sys.argv) > 1:
	PORT = int(sys.argv[1])
	I = ""
else:
	PORT = 8000
	I = ""
Ejemplo n.º 15
0
def getTrackSuggestions():
    pattern = request.args.get('pattern', '', type=str)
    suggestions = DatabaseAccess.getSuggestions(pattern)
    return jsonify(tracks=suggestions)