def main(): welcome() info = get_info() curr_ver = dist_naming.split_eggname(info['egg_name'])[1] print "Currently installed version: %s" % curr_ver print " installed on: %s" % info['mtime'] print conf = config.read() c = Chain(conf['IndexedRepos']) versions = c.list_versions(name) if len(versions) == 0: print "Error: no versions of %r available" % name quit() while True: print "Available versions:" print ', '.join(versions) print """ You have the following options: - press return to update to the latest available version %s - enter the version to update (or downgrade) to, e.g. %r - enter 'q' to quit (without changing anything) """ % (versions[-1], versions[0]) inp = raw_input('> ').strip() if inp.lower() in ('q', 'quit'): sys.exit() update_to = inp or versions[-1] if update_to in versions: print "Updating to: %s" % update_to check_call([enpkg_bin, '--sys-config', name, update_to]) quit() print "You have entered %r, which is not an available version" % inp
def get_status(): # the result is a dict mapping cname to ... res = {} for cname in egginst.get_installed_cnames(sys.prefix): d = defaultdict(str) info = get_installed_info(sys.prefix, cname) if info is None: continue d.update(info) res[cname] = d c = Chain(config.get('IndexedRepos')) for cname in c.groups.iterkeys(): dist = c.get_dist(Req(cname)) if dist is None: continue repo, fn = dist_naming.split_dist(dist) n, v, b = dist_naming.split_eggname(fn) if cname not in res: d = defaultdict(str) d['name'] = n res[cname] = d res[cname]['a-egg'] = fn res[cname]['a-ver'] = '%s-%d' % (v, b) def vb_egg(fn): try: n, v, b = dist_naming.split_eggname(fn) return comparable_version(v), b except: return None for d in res.itervalues(): if d['egg_name']: # installed if d['a-egg']: if vb_egg(d['egg_name']) >= vb_egg(d['a-egg']): d['status'] = 'up-to-date' else: d['status'] = 'updateable' else: d['status'] = 'installed' else: # not installed if d['a-egg']: d['status'] = 'installable' return res
def test_split_eggname(self): for fn, nvb in [ ('numpy-1.3.4-7.egg', ('numpy', '1.3.4', 7)), ('python_dateutil-0.5-12.egg', ('python_dateutil', '0.5', 12)), ]: self.assertEqual(dist_naming.split_eggname(fn), nvb)
def vb_egg(fn): try: n, v, b = dist_naming.split_eggname(fn) return comparable_version(v), b except: return None