Esempio n. 1
0
def egginst_remove(pkg):
    fn = basename(pkg)
    pprint_fn_action(fn, 'removing')
    if dry_run:
        return
    ei = egginst.EggInst(pkg)
    ei.remove()
Esempio n. 2
0
def egginst_remove(pkg):
    fn = basename(pkg)
    pprint_fn_action(fn, 'removing')
    if dry_run:
        return
    ei = egginst.EggInst(pkg)
    ei.remove()
Esempio n. 3
0
    def fetch_dist(self,
                   dist,
                   fetch_dir,
                   force=False,
                   check_md5=False,
                   dry_run=False):
        """
        Get a distribution, i.e. copy or download the distribution into
        fetch_dir.

        force:
            force download or copy

        check_md5:
            when determining if a file needs to be downloaded or copied,
            check it's MD5.  This is, of course, slower but more reliable
            then just checking the file-size (which always done first).
            Note:
              * This option has option has nothing to do with checking the
                MD5 of a download.  The md5 is always checked when files are
                downloaded (regardless of this option).
              * If force=True, this option is has no effect, because the file
                is forcefully downloaded, ignoring any existing file (as well
                as the MD5).
        """
        md5 = self.index[dist].get('md5', None)
        size = self.index[dist].get('size', None)

        fn = dist_naming.filename_dist(dist)
        dst = join(fetch_dir, fn)
        # if force is not used, see if (i) the file exists (ii) its size is
        # the expected (iii) optionally, make sure the md5 is the expected.
        if (not force and isfile(dst) and getsize(dst) == size
                and (not check_md5 or md5_file(dst) == md5)):
            if self.verbose:
                print "Not forcing refetch, %r already exists" % dst
            return

        pprint_fn_action(fn, ['copying',
                              'downloading'][dist.startswith('http://')])
        if dry_run:
            return

        if self.verbose:
            print "Copying: %r" % dist
            print "     to: %r" % dst

        fo = open(dst + '.part', 'wb')
        write_data_from_url(fo, dist, md5, size)
        fo.close()
        rm_rf(dst)
        os.rename(dst + '.part', dst)
Esempio n. 4
0
def egginst_install(conf, dist):
    repo, fn = dist_naming.split_dist(dist)
    pkg_path = join(conf['local'], fn)

    pprint_fn_action(fn, 'installing')
    if dry_run:
        return

    ei = egginst.EggInst(pkg_path)
    ei.install()
    info = get_installed_info(cname_fn(fn))
    path = join(info['meta_dir'], '__enpkg__.txt')
    fo = open(path, 'w')
    fo.write("repo = %r\n" % repo)
    fo.close()
Esempio n. 5
0
def egginst_install(conf, dist):
    repo, fn = dist_naming.split_dist(dist)
    pkg_path = join(conf['local'], fn)

    pprint_fn_action(fn, 'installing')
    if dry_run:
        return

    ei = egginst.EggInst(pkg_path)
    ei.install()
    info = get_installed_info(cname_fn(fn))
    path = join(info['meta_dir'], '__enpkg__.txt')
    fo = open(path, 'w')
    fo.write("repo = %r\n" % repo)
    fo.close()
Esempio n. 6
0
    def fetch_dist(self, dist, fetch_dir, force=False, check_md5=False,
                   dry_run=False):
        """
        Get a distribution, i.e. copy or download the distribution into
        fetch_dir.

        force:
            force download or copy

        check_md5:
            when determining if a file needs to be downloaded or copied,
            check it's MD5.  This is, of course, slower but more reliable
            then just checking the file-size (which always done first).
            Note:
              * This option has option has nothing to do with checking the
                MD5 of a download.  The md5 is always checked when files are
                downloaded (regardless of this option).
              * If force=True, this option is has no effect, because the file
                is forcefully downloaded, ignoring any existing file (as well
                as the MD5).
        """
        md5 = self.index[dist].get('md5', None)
        size = self.index[dist].get('size', None)

        fn = dist_naming.filename_dist(dist)
        dst = join(fetch_dir, fn)
        # if force is not used, see if (i) the file exists (ii) its size is
        # the expected (iii) optionally, make sure the md5 is the expected.
        if (not force and isfile(dst) and getsize(dst) == size and
                   (not check_md5 or md5_file(dst) == md5)):
            if self.verbose:
                print "Not forcing refetch, %r already exists" % dst
            return

        pprint_fn_action(fn,
                 ['copying', 'downloading'][dist.startswith('http://')])
        if dry_run:
            return

        if self.verbose:
            print "Copying: %r" % dist
            print "     to: %r" % dst

        fo = open(dst + '.part', 'wb')
        write_data_from_url(fo, dist, md5, size)
        fo.close()
        rm_rf(dst)
        os.rename(dst + '.part', dst)
Esempio n. 7
0
def main():
    from optparse import OptionParser

    p = OptionParser(usage="usage: %prog [options] [EGGS ...]",
                     description=__doc__)

    p.add_option('-l', "--list",
                 action="store_true",
                 help="list all installed packages")

    p.add_option('-r', "--remove",
                 action="store_true",
                 help="remove package(s), requires the egg or project name(s)")

    p.add_option('-v', "--verbose", action="store_true")
    p.add_option('-n', "--dry-run", action="store_true")
    p.add_option('--version', action="store_true")

    opts, args = p.parse_args()

    if opts.version:
        from enstaller import __version__
        print "IronPkg version:", __version__
        return

    if opts.list:
        if args:
            p.error("the --list option takes no arguments")
        print_installed()
        return

    for path in args:
        ei = EggInst(path, opts.verbose)
        fn = basename(path)
        if opts.remove:
            pprint_fn_action(fn, 'removing')
            if opts.dry_run:
                continue
            ei.remove()

        else: # default is always install
            pprint_fn_action(fn, 'installing')
            if opts.dry_run:
                continue
            ei.install()
Esempio n. 8
0
def main():
    from optparse import OptionParser

    p = OptionParser(usage="usage: %prog [options] [EGGS ...]",
                     description=__doc__)

    p.add_option('-l', "--list",
                 action="store_true",
                 help="list all installed packages")

    p.add_option("--noapp",
                 action="store_true",
                 help="don't install/remove application menu items")

    p.add_option("--prefix",
                 action="store",
                 default=sys.prefix,
                 help="install prefix, defaults to %default",
                 metavar='PATH')

    p.add_option("--hook",
                 action="store_true",
                 help="don't install into site-packages (experimental)")

    p.add_option('-r', "--remove",
                 action="store_true",
                 help="remove package(s), requires the egg or project name(s)")

    p.add_option('-v', "--verbose", action="store_true")
    p.add_option('-n', "--dry-run", action="store_true")
    p.add_option('--version', action="store_true")

    opts, args = p.parse_args()

    if opts.version:
        from enstaller import __version__
        print "enstaller version:", __version__
        return

    prefix = abspath(opts.prefix)

    if opts.list:
        if args:
            p.error("the --list option takes no arguments")
        print_installed(prefix)
        return

    for path in args:
        ei = EggInst(path, prefix, opts.hook, opts.verbose, opts.noapp)
        fn = basename(path)
        if opts.remove:
            pprint_fn_action(fn, 'removing')
            if opts.dry_run:
                continue
            ei.remove()

        else: # default is always install
            pprint_fn_action(fn, 'installing')
            if opts.dry_run:
                continue
            ei.install()