Changeset 512

Show
Ignore:
Timestamp:
03/19/06 14:24:27 (3 years ago)
Author:
coderanger
Message:

HackInstallPlugin:

Detects what version is currently installed. 0 means unkown version, -1 means not installed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hackinstallplugin/0.9/hackinstall/core.py

    r508 r512  
    7878                        newname = '%s%s_r%s%s' % (md.group(1),md.group(2),rev,md.group(3)) 
    7979                    self.env.log.debug('Renaming %s to %s' % (f, newname)) 
     80                    os.rename(self.env.path+'/plugins/'+f,self.env.path+'/plugins/'+newname) 
     81                     
     82                # Remove all old versions 
     83                md = re.match('([^-]+)-',f) 
     84                if md: 
     85                    for f2 in os.listdir(self.env.path+'/plugins'): 
     86                        md2 = re.match('([^-]+)-',f2) 
     87                        if md2 and md.group(1) == md2.group(1): 
     88                            os.remove(self.env.path+'/plugins/'+f2) 
    8089 
    8190    def download_hack(self, name, rev): 
  • hackinstallplugin/0.9/hackinstall/templates/hackinstall_admin_plugin.cs

    r484 r512  
    77<form method="post"> 
    88<table> 
    9 <tr><td>Name</td><td>Current</td></tr> 
     9<tr><td>Name</td><td>Current</td><td>Installed</td></tr> 
    1010<?cs each:plugin = hackinstall.plugins ?> 
    1111<tr> 
    1212    <td><?cs name:plugin ?></td> 
    1313    <td><?cs var:plugin.current ?></td> 
    14     <td><input type="submit" name="download_<?cs name:plugin ?>" value="Download" /></td> 
     14    <td><?cs var:plugin.installed ?></td> 
    1515    <td><input type="submit" name="install_<?cs name:plugin ?>" value="Install" /></td> 
    1616</tr> 
  • hackinstallplugin/0.9/hackinstall/web_ui.py

    r508 r512  
    1010from db_default import default_table 
    1111from core import * 
    12 import urlparse, xmlrpclib 
     12import urlparse, xmlrpclib, re, os 
    1313 
    1414__all__ = ['HackInstallPlugin'] 
     
    115115    # Internal methods 
    116116    def _get_hacks(self, type): 
     117        # Build hash of name -> installed-rev 
     118        installed = {} 
     119        if type == 'plugin': 
     120            for f in os.listdir(self.env.path+'/plugins'): 
     121                self.log.debug("Found egg '%s'"%f) 
     122                md = re.match('([^-]+)-([^-]+)-',f) 
     123                if md: 
     124                    plugin = md.group(1).lower()+'plugin' 
     125                    md2 = re.search('r(\d+)',md.group(2)) 
     126                    if md2: 
     127                        installed[plugin] = int(md2.group(1)) 
     128                    else: 
     129                        installed[plugin] = 0 
     130                    self.log.debug('Extracted version = %s'%installed[plugin]) 
     131        elif type == 'macro': 
     132            pass # Haven't gotten here yet 
     133     
     134        # Build the rest of the data structure from the DB 
    117135        db = self.env.get_db_cnx() 
    118136        cursor = db.cursor() 
     
    120138        cursor.execute('SELECT id, name, current FROM hacks WHERE type = %s', (type,)) 
    121139        for row in cursor: 
    122             hacks[row[1]] = {'id': row[0], 'current': row[2]
     140            hacks[row[1]] = {'id': row[0], 'current': row[2], 'installed': installed.get(row[1].lower(), -1)
    123141        return hacks 
    124142