Changeset 4

Show
Ignore:
Timestamp:
11/06/07 18:53:41 (4 years ago)
Author:
francois
Message:

Ajout affichage valeur download et upload

Location:
trunk/src/server
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/server/bittorrent.py

    r3 r4  
    4040        return len(self.daemon.get_status_all()) 
    4141    def setUploadLimit(self, limit): 
    42         "" 
     42        "Set la valeur d'upload max" 
    4343        self.daemon.set_uplimit(limit) 
    4444        self.upload_limit = self.daemon.get_uplimit() 
    4545    def setDownloadLimit(self, limit): 
    46         "" 
     46        "Set la valeur de download max" 
    4747        self.daemon.set_downlimit(limit) 
    4848        self.download_limit = self.daemon.get_downlimit() 
     
    110110        except: 
    111111            pass 
    112              
    113      
  • trunk/src/server/templates/index.html

    r3 r4  
    2323            </tr> 
    2424          </thead> 
    25                 <tfoot> 
    26                   <tr> 
    27                     <th></th> 
    28                     <th></th> 
    29                     <th></th> 
    30                     <th></th> 
    31                     <th></th> 
    32                     <th> 
    33                       <form method="post" action=""> 
    34                         {{ select_download  }} 
    35                         <input type="submit" value="ok" /> 
    36                       </form> 
    37                     </th> 
    38                     <th> 
    39                       <form method="post" action=""> 
    40                         {{ select_upload }} 
    41                         <input type="submit" value="ok" /> 
    42                       </form> 
    43                     </th> 
    44                     <th></th> 
    45                     <th></th> 
    46                   </tr> 
    47                 </tfoot> 
     25          <tfoot> 
     26            <tr> 
     27              <th></th> 
     28              <th></th> 
     29              <th></th> 
     30              <th></th> 
     31              <th></th> 
     32              <th> 
     33                {{ download_speed }} 
     34                <form method="post" action=""> 
     35                  {{ select_download  }} 
     36                  <input type="submit" value="ok" /> 
     37                </form> 
     38              </th> 
     39              <th> 
     40                {{ upload_speed }} 
     41                <form method="post" action=""> 
     42                  {{ select_upload }} 
     43                  <input type="submit" value="ok" /> 
     44                </form> 
     45              </th> 
     46              <th></th> 
     47              <th></th> 
     48            </tr> 
     49          </tfoot> 
    4850                <tbody> 
    4951                        {% for torrent in torrents %} 
  • trunk/src/server/views.py

    r3 r4  
    44from django.http import HttpResponse, Http404 
    55from bittorrent import Bittorrent 
     6 
     7PREFIX_TEMPLATES = "dev" 
    68 
    79def error_page(titre = "Erreur générale",  
     
    4648        # Mise en forme humaine 
    4749        torrents = bittorrent.liste() 
     50        uploadRate = 0 
     51        downloadRate = 0 
    4852        for torrent in torrents: 
     53                uploadRate += torrent['upload_speed'] 
     54                downloadRate += torrent['download_speed'] 
    4955                torrent['taille'] = bytes2human(torrent['taille']) 
    5056                torrent['total_envoi'] = bytes2human(torrent['total_envoi']) 
     
    5460                'nb_torrent': len(torrents), 
    5561                'torrents' : torrents, 
     62                'upload_speed' : bytes2human(uploadRate) + "s", 
     63                'download_speed' : bytes2human(downloadRate) + "s", 
    5664                'download_limit' : bittorrent.download_limit, 
    5765                'upload_limit' : bittorrent.upload_limit, 
     
    6371                                                           bittorrent.upload_limit), 
    6472        }) 
    65         template = loader.get_template("index.html") 
     73        template = loader.get_template(PREFIX_TEMPLATES + "/index.html") 
    6674        return HttpResponse(template.render(c)) 
    6775                 
     
    95103        else: 
    96104                state = "NOPOST" 
    97         c = Context({ 
    98                 'etat' : state, 
    99                 'form' : form.as_p(), 
    100                 }) 
    101         template = loader.get_template("add.html") 
     105        c = Context({'etat' : state, 
     106                     'form' : form.as_p(), 
     107                     }) 
     108        template = loader.get_template(PREFIX_TEMPLATES + "/add.html") 
    102109        return HttpResponse(template.render(c)) 
    103110 
     
    126133        else: 
    127134                form = MoveTorrentForm() 
    128         template = loader.get_template("move.html") 
    129         c = Context({ 
    130                         'destination' : destination, 
    131                         'resultat' : resultat, 
    132                         'torrent' : info, 
    133                         'form' : form.as_p(), 
    134         }) 
     135        template = loader.get_template(PREFIX_TEMPLATES + "/move.html") 
     136        c = Context({'destination' : destination, 
     137                     'resultat' : resultat, 
     138                     'torrent' : info, 
     139                     'form' : form.as_p(), 
     140                     }) 
    135141        return HttpResponse(template.render(c)) 
    136142 
     
    159165                else: 
    160166                        confirmation = True 
    161  
    162167        else: 
    163168                return HttpResponse("Erreur inconnue ....") 
    164         template = loader.get_template("delete.html") 
    165         c = Context({ 
    166                         'confirmation' : confirmation, 
    167                         'idtorrent' : idtorrent, 
    168                         'torrent' : info, 
    169                         }) 
     169        template = loader.get_template(PREFIX_TEMPLATES + "/delete.html") 
     170        c = Context({'confirmation' : confirmation, 
     171                     'idtorrent' : idtorrent, 
     172                     'torrent' : info, 
     173                     }) 
    170174         
    171175        return HttpResponse(template.render(c))