def __init__(self, user, pswd, enable_pswd): Cmd.__init__(self) self.controller = DBController() self.runner = TestRunner(self.controller) self.user = user self.pswd = pswd self.enable_pswd = enable_pswd if enable_pswd else pswd self.current_results = {}
def loadContent(self): query = self.query if not self.query: query = ''' select * from Playlist ''' DBController.execute(query) self.playlistsData = list(DBController.get())
def loadContent(self): query = self.query if not self.query: query = ''' SELECT f.cod, pl.nome, a.descricao, f.tipo_comp, f.tipo_grav, f.descricao, f.tempo_exec FROM Faixa f LEFT OUTER JOIN Playlist_Faixa pf ON pf.cod_alb=f.cod_alb AND pf.cod_faixa=f.cod LEFT OUTER JOIN Playlist pl ON pl.cod=pf.cod_play LEFT OUTER JOIN Album a ON a.cod=f.cod_alb WHERE f.descricao LIKE '%{}%' '''.format(Navigate.current_search) if self.callback: DBController.execute(query, self.callback()) else: DBController.execute(query) self.songsData = list(DBController.get())
def submit(self): new_values = [ info[2].get() for i, info in enumerate(self.infos) if i > 1 ] try: DBController.execute( ''' UPDATE Album SET pr_compra=?, data_compra=?, data_grav=?, tipo_compra=?, descricao=? WHERE cod=%s ''' % (Navigate.current_data[0]), *new_values) DBController.commit() except Exception as e: tkMessageBox.showinfo( "ERRO!", "Um erro aparenta ter ocorrido, por favor, tente novamente. Veja-o abaixo:\n %s." % e) else: Navigate.goto(Navigate.current_page['key'][1:])
def __init__(self, parent): super(Song, self).__init__(parent) self.container = Frame(parent, style="DarkGray.TFrame", width=500) self.content = Frame(self.container, style="DarkGray.TFrame", width=500) self.add2playlist = Frame(self.content, style="DarkGray.TFrame") self.addLabel = Label(self.content, style="DarkGray.TLabel", text="Adicione a playlist: ") self.addSelectVar = tk.StringVar(self.content) DBController.execute(''' SELECT nome, cod FROM Playlist ''') results = [("%d- %s" % (i, result[0]), result[1]) for i, result in enumerate(DBController.get())] choices = set([result[0] for result in results]) self.addSelect = OptionMenu(self.content, self.addSelectVar, *choices) def addToPlaylist(*args): song_code = Navigate.current_data[0] DBController.execute(''' SELECT cod_alb FROM Faixa WHERE cod=%s ''' % song_code) cod_alb = list(DBController.get()) cod_alb = cod_alb[0][0] index = int(self.addSelectVar.get().split("-")[0]) cod_pl = int(results[index][1]) DBController.execute(''' DELETE FROM Playlist_Faixa WHERE cod_faixa=? AND cod_alb=? ''', song_code, cod_alb) DBController.commit() DBController.execute(''' INSERT INTO Playlist_Faixa VALUES (?, ?, ?) ''', cod_pl, song_code, cod_alb) DBController.commit() self.addSelectVar.trace('w', addToPlaylist) self.infos = []
def __init__(self, parent): # DBController.connect(database='S2spot', server="LEC17\FBDSERVER", user='******', password='******') DBController.connect(database='S2spot', server="DESKTOP-LMO6LAE\SQLEXPRESS", user=None, password=None) self.parent = parent self.container = Frame(parent) self.container.pack(fill='both', expand=True) self.right_panel = RightPanel(self.container) Navigate.setContainer(self.right_panel.main_content.container) Navigate.addPage(actived=False, key='rpl', kind='register', label="CADASTRAR PLAYLIST", component=registerplaylist.RegisterPlaylist( Navigate.container)) Navigate.addPage(actived=False, key='rsg', kind='register', label="CADASTRAR FAIXA", component=registersong.RegisterSong( Navigate.container)) Navigate.addPage(actived=False, key='rab', kind='register', label="CADASTRAR ÁLBUM", component=registeralbum.RegisterAlbum( Navigate.container)) Navigate.addPage(actived=False, key='rrd', kind='register', label="CADASTRAR GRAVADORA", component=registerrecord.RegisterRecord( Navigate.container)) Navigate.addPage(actived=False, key='rcp', kind='register', label="CADASTRAR COMPOSITOR", component=registercomposer.RegisterComposer( Navigate.container)) Navigate.addPage(actived=False, key='rmp', kind='register', label="CADASTRAR PERÍODO MUSICAL", component=registerperiod.RegisterPeriod( Navigate.container)) Navigate.addPage(actived=False, key='rit', kind='register', label="CADASTRAR INTÉRPRETE", component=registerinterpreter.RegisterInterpreter( Navigate.container)) Navigate.addPage(actived=False, key='_sg', kind='single', label="FAIXA", component=song.Song(Navigate.container)) Navigate.addPage(actived=False, key='_pl', kind='single', label="PLAYLIST", component=playlist.Playlist(Navigate.container)) Navigate.addPage(actived=False, key='_ab', kind='single', label="ÁLBUM", component=album.Album(Navigate.container)) Navigate.addPage(actived=False, key='sg', kind='list', label="FAIXAS", component=songs.Songs(Navigate.container)) Navigate.addPage(actived=False, key='pl', kind='list', label="PLAYLISTS", component=playlists.Playlists(Navigate.container)) Navigate.addPage(actived=False, key='ab', kind='list', label="ÁLBUNS", component=albums.Albums(Navigate.container)) Navigate.addPage(actived=False, key='rd', kind='list', label="GRAVADORAS", component=records.Records(Navigate.container)) Navigate.addPage(actived=False, key='cp', kind='list', label="COMPOSITORES", component=composers.Composers(Navigate.container)) Navigate.addPage(actived=False, key='mp', kind='list', label="PERÍODOS MUSICAIS", component=periods.Periods(Navigate.container)) Navigate.addPage(actived=False, key='it', kind='list', label="INTÉRPRETES", component=interpreters.Interpreters( Navigate.container)) self.left_panel = LeftPanel(self.container) Navigate.goto('sg') Navigate.setApp(self)
def loadContent(self): DBController.execute(''' SELECT a.cod, g.nome, a.pr_compra, a.data_compra, a.data_grav, a.tipo_compra, a.descricao FROM Album a INNER JOIN Gravadora g ON a.codgrav=g.cod ''') self.albumsData = list(DBController.get())
def addToPlaylist(*args): song_code = Navigate.current_data[0] DBController.execute(''' SELECT cod_alb FROM Faixa WHERE cod=%s ''' % song_code) cod_alb = list(DBController.get()) cod_alb = cod_alb[0][0] index = int(self.addSelectVar.get().split("-")[0]) cod_pl = int(results[index][1]) DBController.execute(''' DELETE FROM Playlist_Faixa WHERE cod_faixa=? AND cod_alb=? ''', song_code, cod_alb) DBController.commit() DBController.execute(''' INSERT INTO Playlist_Faixa VALUES (?, ?, ?) ''', cod_pl, song_code, cod_alb) DBController.commit()
def loadContent(self): DBController.execute(''' select * from Interprete ''') self.interpretersData = list(DBController.get())
class TestsCmd(Cmd): prompt = 'tests>' def __init__(self, user, pswd, enable_pswd): Cmd.__init__(self) self.controller = DBController() self.runner = TestRunner(self.controller) self.user = user self.pswd = pswd self.enable_pswd = enable_pswd if enable_pswd else pswd self.current_results = {} def do_listar_campus(self, line): "Lista de campus disponibles" for f in self.controller.get_campus(): print(f) def do_listar_facultades(self, line): "Lista de facultades disponibles" for f in self.controller.get_facultades(): print(f) def do_listar_oomm(self, lines): "Lista de organismos menores" for f in self.controller.get_oomms(): print(f) def do_listar_equipos_datacenter(self, lines): "Lista de equipos de datacenter" for f in self.controller.get_datacenter(): print(f) def complete_seleccionar_campus(self, text, line, begidx, endidx): if not text: options = self.controller.get_campus() else: if text.startswith('-'): options = ['-todos'] else: options = [f for f in self.controller.get_campus() if f.lower().startswith(text.lower())] return options def do_seleccionar_campus(self, line): if line: if line.startswith('-todos'): self.runner.add_facultades(self.controller.get_facultades()) else: self.runner.add_facultades(self.controller.parse_campus(line)) else: campus = self.select(self.controller.get_campus(), 'Campus? ') self.runner.add_facultades(self.controller.get_facultades_campus(campus)) def do_seleccionar_facultad(self, line): campus = self.select(self.controller.get_campus(), 'Campus? ') facultad = self.select(self.controller.get_facultades_campus(campus), 'Facultad? ') self.runner.add_facultad(facultad) def complete_seleccionar_oomm(self, text, line, begidx, endidx): if not text: options = self.controller.get_oomms() else: if text.startswith('-'): options = ['-todos'] else: options = [f for f in self.controller.get_oomms() if f.lower().startswith(text.lower())] return options def do_seleccionar_oomm(self, line): if line: if line.startswith('-todos'): self.runner.add_oomms(self.controller.get_oomms()) else: self.runner.add_oomms(self.controller.parse_oomm(line)) def do_seleccionar_todo(self, line): self.runner.add_oomms(self.controller.get_oomms()) self.runner.add_facultades(self.controller.get_facultades()) self.runner.add_datacenters(self.controller.get_datacenter()) run_parser = argparse.ArgumentParser() run_parser.add_argument('--packets', nargs='?', default=default_values.number_pings) run_parser.add_argument('--threads', nargs='?', default=default_values.default_threads) run_parser.add_argument('--destination', nargs='?', default=default_values.default_destination) run_parser.add_argument('--time', action='store_true') run_parser.add_argument('--repeat_failures', nargs=2, metavar=('NUMBER_REPETITIONS', 'WAIT_TIME'), default=[default_values.default_repeats, default_values.default_wait_time]) @with_argparser(run_parser) def do_correr_prueba(self, args): config = { 'user': self.user, 'pswd': self.pswd, 'enable_pswd': self.enable_pswd, 'pings': args.packets, 'threads': args.threads, 'destination': args.destination, 'measure_time': args.time, 'repeat_failures': True if args.repeat_failures else False, 'repetitions_config': { 'repetitions': int(args.repeat_failures[0]), 'wait_time': int(args.repeat_failures[1]) } } self.current_results = self.runner.run_selected_tests(config) save_parser = argparse.ArgumentParser() save_parser.add_argument('--output', nargs='?', default=default_values.default_output) @with_argparser(save_parser) def do_guardar_resultados(self, args): output = args.output output_path = current_path + '/' + output write_results(self.current_results, output_path) self.current_results = {} def do_ver_seleccionados(self, line): print(self.runner.get_selected()) def do_borrar(self, line): self.runner.delete_selected() ver_parser = argparse.ArgumentParser() ver_parser.add_argument('--not_ok', action='store_true') @with_argparser(ver_parser) def do_ver_resultados(self, args): for v in self.current_results.values(): for device in v: string = device['status'].print_status(args.not_ok) if string: print(device['machine']['name'] + ' ' + string) def complete_seleccionar_equipos_datacenter(self, text, line, begidx, endidx): if not text: options = self.controller.get_datacenter() else: if text.startswith('-'): options = ['-todos'] else: options = [f for f in self.controller.get_datacenter() if f.lower().startswith(text.lower())] return options def do_seleccionar_equipos_datacenter(self, line): if line: if line.startswith('-todos'): self.runner.add_datacenters(self.controller.get_datacenter()) else: self.runner.add_datacenters(self.controller.parse_datacenter(line))
def loadContent(self): DBController.execute(''' SELECT c.cod, pm.descricao, c.nome, c.cidade, c.pais, c.dt_nasc, c.dt_morte FROM Compositor c INNER JOIN Periodo_Musical pm ON c.pr_msc=pm.cod ''') self.composerData = list(DBController.get())