def GET(self, id=None): if id=='0': return cherrypy.engine.exit() if id=='1': return slc.printDict(self.groups) if id == None: return('Send Codes') if id == 'mts': self.userID=self.userID+1; return str(self.userID-1)+';'+';'.join(slc.getMoviesToSelectFrom()) if 'mr' in id: vals=id.split(';') if vals[1] in self.groups.keys(): return ';'.join(slc.getSelectedMovies(self.groups[vals[1]],self.calssifier,self.umat,self.mnames)) else: return 'No group'
class Movies: norm = slc.movieSelector() calssifier, umat = slc.getMovieCalssifier() mnames = slc.getMoviesToSelectFrom(numOfMovs=0, perm=0, filt=0) userID = 1 groups = { '0': [[('Crumb (1994)', 1), ('Doom Generation, The (1995)', 2)], [('Firm, The (1993)', 3), ('All Dogs Go to Heaven 2 (1996)', 4)]] } exposed = True def GET(self, id=None): if id == '0': return cherrypy.engine.exit() if id == '1': return slc.printDict(self.groups) if id == None: return ('Send Codes') if id == 'mts': self.userID = self.userID + 1 return str(self.userID - 1) + ';' + ';'.join( slc.getMoviesToSelectFrom()) if 'mr' in id: vals = id.split(';') if vals[1] in self.groups.keys(): return ';'.join( slc.getSelectedMovies(self.groups[vals[1]], self.calssifier, self.umat, self.mnames)) else: return 'No group' def POST(self, title): gpNum, vals = slc.parseGetMSg(title) if gpNum in self.groups.keys(): tmp = self.groups[gpNum] tmp.append(vals) self.groups[gpNum] = tmp else: self.groups[gpNum] = [vals] return 'Added the data'
def GET(self, id=None): if id == '0': return cherrypy.engine.exit() if id == '1': return slc.printDict(self.groups) if id == None: return ('Send Codes') if id == 'mts': self.userID = self.userID + 1 return str(self.userID - 1) + ';' + ';'.join( slc.getMoviesToSelectFrom()) if 'mr' in id: vals = id.split(';') if vals[1] in self.groups.keys(): return ';'.join( slc.getSelectedMovies(self.groups[vals[1]], self.calssifier, self.umat, self.mnames)) else: return 'No group'
def generate(self, length='Test'): # ''.join(random.sample(string.hexdigits, int(length))) movToSelect=slc.getMoviesToSelectFrom(shownMovies) return '\n'.join(movToSelect)
# -*- coding: utf-8 -*- """ Created on Thu Nov 26 19:17:03 2015 @author: Yoav """ import sys sys.path.append('D:\\Dropbox\\DataHack\\WebSite\\'); import movieSelector as slc import json # curl -d title="0*Dead Man Walking (1995)-1*Bad Boys (1995)-3*Babe (1995)-1" -X POST "127.0.0.1:8080/api/songs/" A=[[('Crumb (1994)',1),('Babe (1995)',2)],[('Legends of the Fall (1994)',3),('All Dogs Go to Heaven 2 (1996)',4)]] #calssifier,umat=slc.getMovieCalssifier() mnames=slc.getMoviesToSelectFrom(numOfMovs=0,perm=0) #res= slc.findMatchIndex('GoldenEye (1995)',mnames) #M=slc.getSelectedMovies(A,calssifier,umat,mnames) #cmnUser=slc.comingGroupToComingUser(A) drankString='0*Dead Man Walking (1995)-1*Bad Boys (1995)-3*Ref, The (1994)-1' gpNum,vals=slc.parseGetMSg(drankString) groups={'0':[[('Crumb (1994)',1),('Doom Generation, The (1995)',2)],[('Firm, The (1993)',3),('All Dogs Go to Heaven 2 (1996)',4)]]} tmp=groups[gpNum] tmp.append(vals) groups[gpNum]=tmp B=A B.append(vals) dictString = json.dumps(B)