Package bodhi :: Module admin
[hide private]
[frames] | no frames]

Source Code for Module bodhi.admin

 1  # $Id: admin.py,v 1.3 2007/01/08 06:07:07 lmacken Exp $ 
 2  # This program is free software; you can redistribute it and/or modify 
 3  # it under the terms of the GNU General Public License as published by 
 4  # the Free Software Foundation; version 2 of the License. 
 5  # 
 6  # This program is distributed in the hope that it will be useful, 
 7  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 8  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 9  # GNU Library General Public License for more details. 
10  # 
11  # You should have received a copy of the GNU General Public License 
12  # along with this program; if not, write to the Free Software 
13  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
14   
15  import os 
16  import bodhi.masher 
17   
18  from os.path import join, isfile, isdir 
19  from bodhi.push import PushController 
20   
21  from turbogears import expose, identity, config, redirect 
22  from turbogears.identity import SecureResource 
23  from turbogears.controllers import Controller 
24  from turbogears.toolbox.catwalk import CatWalk 
25   
26 -class AdminController(Controller, SecureResource):
27 require = identity.in_group("releng") 28 29 push = PushController() 30 catwalk = CatWalk() 31 32 @expose(template='bodhi.templates.admin')
33 - def index(self):
34 return dict()
35 36 @expose(template='bodhi.templates.repodiff')
37 - def repodiff(self, diff=None):
38 """ 39 If a diff is specified, display it; if not, show a list of diffs. 40 """ 41 if not isdir(config.get('repodiff_dir')): 42 os.mkdir(config.get('repodiff_dir')) 43 if not diff: 44 return dict(diffs=os.listdir(config.get('repodiff_dir'))) 45 else: 46 diff_file = join(config.get('repodiff_dir'), diff) 47 if isfile(diff_file): 48 diff_file = open(diff_file, 'r') 49 output = diff_file.read() 50 diff_file.close() 51 return dict(tg_template='bodhi.templates.diff', diff=output, 52 title=diff) 53 else: 54 flash("Invalid repodiff specified: %s" % diff) 55 raise redirect('/admin')
56 57 @expose(template='bodhi.templates.masher', allow_json=True)
58 - def masher(self, lastlog=None):
59 """ 60 Display the current status of the Masher 61 """ 62 m = bodhi.masher.get_masher() 63 if lastlog: 64 (logfile, data) = m.lastlog() 65 return dict(title=logfile, text=data, 66 tg_template='bodhi.templates.text') 67 return dict(masher_str=str(m))
68 69 @expose()
70 - def mash(self, tag):
71 m = bodhi.masher.get_masher() 72 m.mash_tags([tag]) 73 raise redirect('/admin/masher')
74