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

Source Code for Module bodhi.push

 1  # $Id: push.py,v 1.5 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 mail 
17  import shutil 
18  import logging 
19  import tempfile 
20  import cherrypy 
21  import commands 
22   
23  from datetime import datetime 
24  from turbogears import expose, redirect, config, identity, controllers 
25   
26  from bodhi.util import mkmetadatadir, header 
27  from bodhi.model import PackageUpdate 
28  from bodhi.metadata import ExtendedMetadata 
29  from bodhi.modifyrepo import RepoMetadata 
30   
31  from os.path import isfile, isdir, basename, join 
32   
33  log = logging.getLogger(__name__) 
34   
35 -class PushController(controllers.Controller, identity.SecureResource):
36 require = identity.in_group("releng") 37
38 - def __init__(self):
39 self.orig_repo = None
40
41 - def repodiff(self):
42 """ 43 When this method is first called, it saves a snapshot of the 44 updates-stage tree (tree -s output). When called a second time, 45 it takes another snapshot, diffs it with the original, and stores 46 the diff in 'repodiff_dir'. 47 """ 48 if not self.orig_repo: 49 self.orig_repo = tempfile.mkstemp() 50 tree = commands.getoutput("tree -s %s" % self.stage_dir) 51 os.write(self.orig_repo[0], tree) 52 else: 53 self.new_repo = tempfile.mkstemp() 54 tree = commands.getoutput("tree -s %s" % self.stage_dir) 55 os.write(self.new_repo[0], tree) 56 os.close(self.new_repo[0]) 57 os.close(self.orig_repo[0]) 58 diff = join(config.get('repodiff_dir'), '%s' % 59 datetime.now().strftime("%Y%m%d-%H%M%S")) 60 diff = open(diff, 'w') 61 diff.write(commands.getoutput("diff -u %s %s" % (self.orig_repo[1], 62 self.new_repo[1]))) 63 diff.close() 64 os.unlink(self.orig_repo[1]) 65 os.unlink(self.new_repo[1]) 66 self.orig_repo = None
67 68 @expose(template='bodhi.templates.push', allow_json=True)
69 - def index(self):
70 """ List updates tagged with a push/unpush/move request """ 71 updates = PackageUpdate.select(PackageUpdate.q.request != None) 72 return dict(updates=updates)
73 74 @expose(allow_json=True)
75 - def mash(self, updates, **kw):
76 from bodhi.masher import masher 77 if 'tg_format' in cherrypy.request.params and \ 78 cherrypy.request.params['tg_format'] == 'json': 79 import simplejson 80 updates = simplejson.loads(updates) 81 if not isinstance(updates, list): 82 updates = [updates] 83 masher.queue([PackageUpdate.byTitle(title) for title in updates]) 84 raise redirect('/admin/masher')
85