Example #1
0
def add_record(name, info):
    """Add meta-info file."""
    metadir = os.path.join(get_joltdir(), "meta")
    if not os.path.isdir(metadir):
        os.makedirs(metadir)
    metafile = os.path.join(metadir, name)
    with open(metafile, "wb") as f:
        simplejson.dump(info, f)
Example #2
0
def delete_record(name):
    """Delete meta-info file."""
    metadir = os.path.join(get_joltdir(), "meta")
    if not os.path.isdir(metadir):
        os.makedirs(metadir)
    metafile = os.path.join(metadir, name)
    if os.path.exists(metafile):
        os.remove(metafile)
Example #3
0
def command_list():
    """Show the names of installed packages."""
    metadir = os.path.join(get_joltdir(), "meta")
    if not os.path.isdir(metadir):
        return
    for f in os.listdir(metadir):
        info = get_record(f)
        if info:
            print "%s: %s" % (f, info["version"])
Example #4
0
def command_update():
    """Update all packages installed."""
    metadir = os.path.join(get_joltdir(), "meta")
    if not os.path.isdir(metadir):
        return
    for f in os.listdir(metadir):
        print "updating %s ..." % f
        info = get_record(f)
        if info:
            command_install(info)
        else:
            command_install(f)
Example #5
0
def get_record(name):
    """Get meta-info from local that is stored information about the package."""
    metadir = os.path.join(get_joltdir(), "meta")
    if not os.path.isdir(metadir):
        os.makedirs(metadir)
    metafile = os.path.join(metadir, name)
    info = None
    if os.path.exists(metafile):
        try:
            with open(metafile, "rb") as f:
                info = simplejson.load(f)
        except:
            pass
    return info