Пример #1
0
 def do_search(self, event=None):
     """Perform a search."""
     search = self.search.GetValue()
     type = self.type.GetSelection()
     if not search:
         return wx.MessageBox('You must search for something.',
                              'Nothing to search for')
     try:
         if type == library:
             results = []
             search_lower = search.lower()
             for s in application.mobile_api.get_all_songs():
                 if search_lower in s['title'].lower(
                 ) or search_lower in s['album'].lower(
                 ) or search_lower in s['artist'].lower():
                     results.append(s)
         else:
             results = application.mobile_api.search(
                 search,
                 max_results=config.config.get('library', 'max_results'))
             results = results.get(search_types[type][1])
     except functions.RE as e:
         return wx.MessageBox(*functions.format_requests_error(e))
     if not results:
         wx.MessageBox(
             'No %s found for %s.' %
             ('library results' if type == library else
              search_types[type][0].lower(), search), 'Nothing Found')
     else:
         application.main_frame.last_search = search
         application.main_frame.last_search_type = type
         if type == artists:
             results = [x['artist'] for x in results]
             dlg = wx.SingleChoiceDialog(self, 'Select an artist',
                                         'Artist Results',
                                         [x['name'] for x in results])
             if dlg.ShowModal() == wx.ID_OK:
                 res = dlg.GetSelection()
             else:
                 res = None
             dlg.Destroy()
             if res != None:
                 functions.top_tracks(functions.select_artist(
                     [results[dlg.GetSelection()]['artistId']]),
                                      interactive=True)
         elif type == albums:
             functions.artist_album(None,
                                    albums=[x['album'] for x in results])
         elif type == playlists:
             functions.select_playlist(
                 playlists=[x['playlist'] for x in results])
         else:
             # Must be songs.
             wx.CallAfter(application.main_frame.add_results,
                          results if type == library else
                          [x['track'] for x in results],
                          clear=True)
         self.Close(True)
Пример #2
0
def launch_playlist_all_prog(request):
    """
    lancement de la lecture des ba dont la date de programmation n'est pas depassee
    """
    try:
        ba_list_prog = functions.select_playlist(criteria='all_prog')
        if env_variables.random_play is True:
            shuffle(ba_list_prog)
        ba_list = functions.insert_carte_fidelite(ba_list_prog)
    except:
        logging.error("lecture des ba a echoue")
        raise
    
    logging.info("Rasberry: %s" % str(env_variables.omx))
    if env_variables.omx is True:
        logging.info("In launch_playlist_all_prog, before if not: env_variables.lock.locked = %s" % env_variables.lock.locked())
        if not env_variables.lock.locked():
            logging.info("In launch_playlist_all_prog, env_variables.lock.locked = %s" % env_variables.lock.locked())
            omx_thread = thread_ba.BaOmxThread(ba_list, timer_in_seconds=env_variables.ba_timer)
            omx_thread.start()
    else:
        vlc_thread = thread_ba.BaVlcThread(ba_list, timer_in_seconds=env_variables.ba_timer)
        vlc_thread.start()
        
    return render(request, 'bande_annonce/main_page.html', {'ba_list': ba_list})
Пример #3
0
def copy_playlist(request):
    """
    vue utilisee pour charger une nouvelle bande-annonce
    """
    if request.method == "POST":
        form = CopyBaForm(request.POST)
        if form.is_valid():
            usb_ba_path = form.cleaned_data['usb_ba_path']          
            try:
                ### copie des bande annonces
                usb_ba_list = functions.select_playlist(criteria='all_prog', ba_directory=usb_ba_path) 
                local_ba_list = functions.select_playlist(criteria='all')

                # compare the local_ba_list already there and the usb_ba_list to copy only the new ba
                local_ba_basename = [ os.path.basename(x) for x in local_ba_list]
                for each_ba in usb_ba_list:
                    if not os.path.basename(each_ba) in local_ba_basename:
                        shutil.copy(each_ba, env_variables.ba_directory)

                # list again all ba
                ba_list = functions.select_playlist(criteria='all')
                whole_ba_list = sorted([os.path.basename(x) for x in ba_list])
                
                ### copie des slides
                usb_slide_list = functions.select_slides(criteria='all_prog', ba_directory=usb_ba_path) 
                local_slide_list = functions.select_slides(criteria='all')

                # compare the local_slide_list already there and the usb_slide_list to copy only the new ba
                local_slide_basename = [ os.path.basename(x) for x in local_slide_list]
                for each_slide in usb_slide_list:
                    if not os.path.basename(each_slide) in local_slide_basename:
                        shutil.copy(each_slide, env_variables.ba_directory)

                # list again all slides
                slide_list = functions.select_slides(criteria='all')
                whole_slide_list = sorted([os.path.basename(x) for x in slide_list])


                return render(request, 'bande_annonce/advanced_playlist.html',{'whole_ba_list': whole_ba_list, 'whole_slide_list': whole_slide_list})
            except:
                message = "ECHEC lors de la copie des bande annonces ou des slides"
                return render(request, 'bande_annonce/to_print.html', {'to_print': message})
    else:
        form = CopyBaForm()
        return render(request, 'bande_annonce/copy_playlist.html', {'form': form})
Пример #4
0
 def do_search(self, event = None):
  """Perform a search."""
  search = self.search.GetValue()
  type = self.type.GetSelection()
  if not search:
   return wx.MessageBox('You must search for something.', 'Nothing to search for')
  try:
   if type == library:
    results = []
    search_lower = search.lower()
    for s in application.mobile_api.get_all_songs():
     if search_lower in s['title'].lower() or search_lower in s['album'].lower() or search_lower in s['artist'].lower():
      results.append(s)
   else:
    results = application.mobile_api.search(search, max_results = config.config.get('library', 'max_results'))
    results = results.get(search_types[type][1])
  except functions.RE as e:
   return wx.MessageBox(*functions.format_requests_error(e))
  if not results:
   wx.MessageBox('No %s found for %s.' % ('library results' if type == library else search_types[type][0].lower(), search), 'Nothing Found')
  else:
   application.main_frame.last_search = search
   application.main_frame.last_search_type = type
   if type == artists:
    results = [x['artist'] for x in results]
    dlg = wx.SingleChoiceDialog(self, 'Select an artist', 'Artist Results', [x['name'] for x in results])
    if dlg.ShowModal() == wx.ID_OK:
     res = dlg.GetSelection()
    else:
     res = None
    dlg.Destroy()
    if res != None:
     functions.top_tracks(functions.select_artist([results[dlg.GetSelection()]['artistId']]), interactive = True)
   elif type == albums:
    functions.artist_album(None, albums = [x['album'] for x in results])
   elif type == playlists:
    functions.select_playlist(playlists = [x['playlist'] for x in results])
   else:
    # Must be songs.
    wx.CallAfter(application.main_frame.add_results, results if type == library else [x['track'] for x in results], clear = True)
   self.Close(True)
Пример #5
0
def main_page(request):
    """
    vue utilisee pour la page d'accueil
    """

    # selectionner les ba que l'on souhaite diffuser
    try:
        ba_list = [os.path.basename(each) for each in functions.select_playlist(criteria='all_prog')]
    except:
        ba_list = []

    return render(request, 'bande_annonce/main_page.html', {'ba_list': ba_list})
Пример #6
0
def advanced_playlist(request):
    """
    vue qui permet de voir toutes les bande annonces et d'en ajouter
    """
    # selectionner tous les repertoires du lieu de stockage
    # et les mettre sous forme de dictionnaire
    # numero de semaine: [liste des fichiers]
    ba_list = functions.select_playlist(criteria='all')
    whole_ba_list = sorted([os.path.basename(x) for x in ba_list])
    slide_list = functions.select_slides(criteria='all')
    whole_slide_list = sorted([os.path.basename(x) for x in slide_list])
    return render(request, 'bande_annonce/advanced_playlist.html',{'whole_ba_list': whole_ba_list, 'whole_slide_list': whole_slide_list})