def update(): #update function updates only coordinates of objact that is already in db but to do that it has to know id # of object to identyfie it so it updates only existing objects. Cat = raw_input('Name of catalogue: ') r = requests.get('http://127.0.0.1:8000/endpoint/catalogueInfo',params={'catalogue':Cat,'format':'json'}) length = int(json.loads(r.text)['size']) it = int(json.loads(r.text)['count']) - 1 print(str(round(float(it)/float(length),4)*100) + ' %') while it < length: it +=1 Status = status_code_raw() if Status == 200: try: Data = Composer(Cat, it) print(Data.__unicode__()) PK = PKGet(Data.__unicode__()).send() coors = Data.get_data()['data']['declination'] print(PK, ' ', coors) C = CoorsSender(coors,PK) C.send() except StandardError: pass else: print('Server not reachable') break
def p_action1(self, p): """ action : up | dn | faster | slower """ if '^' in p[1]: args = {'val': len(p[1])} p[0] = Composer('raise', args) elif '_' in p[1]: args = {'val': len(p[1])} p[0] = Composer('lower', args) elif '<' in p[1]: args = {'val': len(p[1]) * 2} p[0] = Composer('faster', args) elif '>' in p[1]: args = {'val': len(p[1]) * 2} p[0] = Composer('slower', args)
def p_action3(self, p): """ action : NOTE JOIN NOTE | NOTE JOIN faster NOTE | NOTE JOIN slower NOTE """ if len(p) == 5: if '<' in p[3]: args = {'val': len(p[3]), 'note': p[1]} else: args = {'val': -len(p[3]), 'note': p[1]} else: args = {'val': 1, 'note': p[1]} p[0] = Composer('merge', args)
def main (): #create notes Director = Composer() starting = Director.create_individual_melody(5,1) notes1 = Director.create_individual_melody(3,1) notes2 = Director.create_individual_melody(3,3) notes3 = Director.create_individual_melody(5,2) notes4 = Director.create_individual_melody(2,1) FrustaNotata = Director.create_individual_melody(10,3) player = Musically(chords = starting, speed = 0) player.base_freq = 100 player.update_last_rate = 1.8 #introduction player.append_rythm_peace(notes2, repeat= 3, speed = 1, reversed= False) player.append_rythm_peace(notes4, repeat= 3, speed = 1, reversed= False) # Principal player.append_rythm_peace(notes3, repeat= 6, speed = 0.5, reversed= False) player.append_rythm_peace(notes1, repeat= 1, speed = 1) player.append_rythm_peace(notes3, repeat= 6, speed = 0.5, reversed= False) ## Resonata-fenale player.append_rythm_peace(FrustaNotata, repeat= 1, speed = 1, reversed= False) #play-Song player.create_song('mistery', 3) player.view()
def run(): # Function Updates all data for given object in db but object is recognized by it's coordinates # so to update coordinates you have to use update function Cat = raw_input('Name of catalogue: ') r = requests.get('http://127.0.0.1:8000/endpoint/catalogueInfo',params={'catalogue':Cat,'format':'json'}) length = int(json.loads(r.text)['size']) it = int(json.loads(r.text)['count']) print(str(round(float(it)/float(length),4)*100) + ' %') while it < length: it +=1 Status = status_code_raw() if Status == 200: try: Data = Composer(Cat, it) print(Data.__unicode__()) LocalSender(Data.get_data()).send() except StandardError: pass else: print('Server not reachable') break
def Parse(self, input, file, **kwargs): self.lexer = Lexer() self.lexer.Build(input, **kwargs) self.parser = yacc.yacc(module=self, **kwargs) self.commands = self.parser.parse(lexer=self.lexer.lexer) # print(f"Comandos: {self.commands}\n") Composer.compose(self.commands, self) if make_midi(self.notes, file): print( f"{bcolors.OKGREEN}File {bcolors.OKCYAN}{file}.midi{bcolors.OKGREEN} generated successfully{bcolors.RESET}" ) print( f"{bcolors.WARNING}*************************************************{bcolors.RESET}\n" ) else: print( f"{bcolors.FAIL}File {bcolors.OKCYAN}{file}.midi{bcolors.FAIL} not generated{bcolors.RESET}", file=sys.stderr) print( f"{bcolors.WARNING}*************************************************{bcolors.RESET}\n", file=sys.stderr)
class Driver: def __init__(self): self.timestep_secs = 10 self.searcher = Searcher() self.composer = Composer() self.mailer = Mailer() def sleep(self): print('==================') print('Going to sleep') time.sleep(self.timestep_secs) print('Have woken up') def loop(self): while (True): self.sleep() data = self.searcher.search() data = self.composer.compose(data) self.mailer.send(data)
def __init__(self): self.timestep_secs = 10 self.searcher = Searcher() self.composer = Composer() self.mailer = Mailer()
def p_action0(self, p): """ action : NOTE """ args = {'note': p[1]} p[0] = Composer('note', args)
def p_action_run_macro(self, p): """ action : RUNMACRO """ p[0] = Composer('run_macro', {'name': p[1][1:]})
def p_action_def_macro(self, p): r""" action : MACRO '[' music ']' """ p[0] = Composer('def_macro', {'name': p[1][:-1], 'notes': p[3]})
def p_highchord(self, p): """ highchord : HIGHCHORD """ args = {'levels': [0, 4, 7]} p[0] = Composer('hchord', args)
def p_action2(self, p): """ action : PAUSE """ args = {'val': len(p[1])} p[0] = Composer('pause', args)