コード例 #1
0
ファイル: filesystem.py プロジェクト: kooplex/kooplex-hub
def garbage_assignmentsnapshot(assignment):
    try:
        archive = Filename.assignmentsnapshot(assignment)
        garbage = Filename.assignmentsnapshot_garbage(assignment)
        file_util.move_file(archive, garbage)
    except Exception as e:
        logger.error("move %s -> %s fails -- %s" % (archive, garbage, e))
コード例 #2
0
ファイル: test_file_util.py プロジェクト: 0jpq0/kbengine
 def test_move_file_exception_unpacking_rename(self):
     # see issue 22182
     with patch("os.rename", side_effect=OSError("wrong", 1)), \
          self.assertRaises(DistutilsFileError):
         with open(self.source, 'w') as fobj:
             fobj.write('spam eggs')
         move_file(self.source, self.target, verbose=0)
コード例 #3
0
ファイル: setup.py プロジェクト: foucault/pkgupdate
 def make_install_pod_manpages(self, directory, target=os.path.join("share", "man")):
     directory = os.path.abspath(directory)
     files = [os.path.join(directory, i) for i in os.listdir(directory)]
     for f in files:
         basef = os.path.basename(f)
         if os.path.isdir(f) or not re.match(".*\.\d\.rst", basef):
             continue
         (name, section, pod) = basef.split(".")
         fullname = "%s.%s" % (os.path.join(directory, name), section)
         print("Generating man page %s" % os.path.basename(fullname))
         # Generate the manpage using python 3 docutils
         publish_file(writer=manpage.Writer(), source_path=f, destination_path=fullname)
         try:
             gzip(fullname)
         except:
             print("*** Could not gzip %s, skipping" % os.path.basename(fullname))
             continue
         print("Installing man page %s" % (os.path.basename(fullname) + ".gz"))
         if self.prefix.startswith("/"):
             prefix = self.prefix[1:]
         else:
             prefix = self.prefix
         install_path = os.path.join(self.root, prefix, target, "man" + section)
         mkpath(install_path)
         move_file(fullname + ".gz", install_path)
コード例 #4
0
    def test_move_file_verbosity(self):
        f = open(self.source, 'w')
        try:
            f.write('some content')
        finally:
            f.close()

        move_file(self.source, self.target, verbose=0)
        wanted = []
        self.assertEqual(self._logs, wanted)

        # back to original state
        move_file(self.target, self.source, verbose=0)

        move_file(self.source, self.target, verbose=1)
        wanted = ['moving %s -> %s' % (self.source, self.target)]
        self.assertEqual(self._logs, wanted)

        # back to original state
        move_file(self.target, self.source, verbose=0)

        self._logs = []
        # now the target is a dir
        os.mkdir(self.target_dir)
        move_file(self.source, self.target_dir, verbose=1)
        wanted = ['moving %s -> %s' % (self.source, self.target_dir)]
        self.assertEqual(self._logs, wanted)
def sortSongs(path,pathOut):
    try:
        filesInFolder = listdir(path)
        print(path,end='\n..............................................   ') 
    except FileNotFoundError:
        print('#Invalid path.')
    l = [i[0] for i in bands]
    musicFiles = filter(__isItMusic__, filesInFolder)
    for file in musicFiles:
        t = get_file_extension(file)
        try:
            dir = pathOut + __find__(t[0].casefold(), l)
        except TypeError:
            continue
        if 1 - isdir(dir):
            mkdir(dir)
        else:
            cont2 = listdir(dir)
            cont = [i.casefold() for i in cont2]
            c = 0
            newfile = file
            while newfile in cont:
                c += 1
                newfile = t[0]+str(c)+t[1]
            if c:
                rename(pathOut+file, pathOut+newfile)
                file = newfile
        move_file(pathOut+file, dir)
    print('  Done!')
    input()
コード例 #6
0
    def run(self):
        """Run the distutils command"""
        log.info("installing library code to %s" % self.bdist_dir)
        
        self.dist_name = get_dist_name(self.distribution,
                                       source_only_dist=True,
                                       python_version=get_python_version()[0])
        self.dist_target = os.path.join(self.dist_dir, self.dist_name)
        log.info("distribution will be available as '%s'" % self.dist_target)
        
        # build command: just to get the build_base
        cmdbuild = self.get_finalized_command("build")
        self.build_base = cmdbuild.build_base
        
        # install command
        install = self.reinitialize_command('install_lib',
                                            reinit_subcommands=1)
        install.compile = False
        install.warn_dir = 0
        install.install_dir = self.bdist_dir
        
        log.info("installing to %s" % self.bdist_dir)
        self.run_command('install_lib')

        # install extra files
        extra_files = {
            'version.py': os.path.join(
                self.bdist_dir, os.path.normpath('mysql/connector/version.py')),
        }
        for src, dest in extra_files.items():
            self.copy_file(src, dest)
        
        # install_egg_info command
        cmd_egginfo = self.get_finalized_command('install_egg_info')
        cmd_egginfo.install_dir = self.bdist_dir
        self.run_command('install_egg_info')
        # we need the py2.x converted to py2 in the filename
        old_egginfo = cmd_egginfo.get_outputs()[0]
        new_egginfo = old_egginfo.replace(
            '-py' + sys.version[:3],
            '-py' + get_python_version()[0])
        move_file(old_egginfo, new_egginfo)
        
        # create distribution
        info_files = [
            ('README', 'README.txt'),
            ('COPYING', 'COPYING.txt')
        ]
        copy_tree(self.bdist_dir, self.dist_target)
        pkg_info = mkpath(os.path.join(self.dist_target))
        for src, dst in info_files:
            if dst is None:
                copy_file(src, self.dist_target)
            else:
                copy_file(src, os.path.join(self.dist_target, dst))

        if not self.keep_temp:
            remove_tree(self.build_base, dry_run=self.dry_run)
コード例 #7
0
ファイル: setup.py プロジェクト: M4rtinK/pykickstart
    def run(self):
        _install_scripts.run(self)

        for old in self.get_outputs():
            new = os.path.splitext(old)[0]
            # move_file doesn't have a way to tell it to overwrite, so remove
            # the existing copy to accomplish the same thing.
            if os.path.isfile(new) and os.path.exists(new):
                os.unlink(new)
            move_file(old, new)
コード例 #8
0
 def post_to_web(self, config_file_name, config, lepton_category):
     self.save_image('png', 'pdf')
     afs_base_directory = self.get_afs_base_directory(config)
     afs_directory = afs_base_directory + '/' + config['run_parameters']['label'] + '/' + lepton_category
     if not os.path.exists(afs_directory):
         os.makedirs(afs_directory)
         
     from distutils import file_util
     file_util.move_file('plot_pdfs/%s.png' % self.plot_name, afs_directory)
     file_util.copy_file('plot_pdfs/%s.pdf' % self.plot_name, afs_directory)
     file_util.copy_file('%s' % config_file_name, afs_directory)
     file_util.copy_file('utilities/index.php', afs_directory)
     file_util.copy_file('utilities/index.php', afs_base_directory + '/' + config['run_parameters']['label'])
コード例 #9
0
ファイル: bdist_deb.py プロジェクト: jonnybest/taskcoach
 def copy_sdist(self):
     ''' Copy the source distribution (.tar.gz archive) to the build dir. '''
     (dest_name, dummy_copied) = copy_file(self.sdist, self.bdist_base)
     orig_name = dest_name[:-len('.tar.gz')] + '.orig.tar.gz'
     orig_name = orig_name.lower()
     if os.path.exists(orig_name):
         os.remove(orig_name)
     self.sdist_archive = move_file(dest_name, orig_name)
コード例 #10
0
 def _move_to_dist(self):
     """Move *.deb files to dist/ (dist_dir) folder"""
     for base, dirs, files in os.walk(self.build_base):
         for filename in files:
             if '-py3' in filename and not self._have_python3:
                 continue
             if filename.endswith('.deb'):
                 newname = filename.replace(
                     '-1_',
                     '{edition}-1{platform}{version}_'.format(
                         platform=self.platform,
                         version=self.platform_version,
                         edition=self.edition or '',
                     )
                 )
                 filepath = os.path.join(base, filename)
                 copy_file(filepath, self.dist_dir)
                 move_file(os.path.join(self.dist_dir, filename),
                           os.path.join(self.dist_dir, newname))
コード例 #11
0
    def _prepare(self, tarball=None, base=None):
        dist_dirname = self.distribution.get_fullname()

        # Rename tarball to conform Debian's Policy
        if tarball:
            self.orig_tarball = os.path.join(
                os.path.dirname(tarball),
                self._get_orig_name()) + '.tar.gz'
            move_file(tarball, self.orig_tarball)

            untared_dir = unarchive_targz(self.orig_tarball)
            self.debian_base = os.path.join(
                tarball.replace('.tar.gz', ''), 'debian')
        elif base:
            self.debian_base = os.path.join(base, 'debian')

        self.mkpath(self.debian_base)
        self.mkpath(os.path.join(self.debian_base, 'source'))

        self._populate_debian()
コード例 #12
0
 def move_file (self, src, dst, level=1):
     """Move a file respecting verbose and dry-run flags."""
     return file_util.move_file(src, dst,
                                self.verbose >= level,
                                self.dry_run)
コード例 #13
0
    def xacro_to_urdf(self,
                      xacro_path: Path,
                      repo_paths: Dict[str, Path],
                      args: Dict[str, str] = None) -> Path:
        """
        Convert a local .xacro file to a .urdf file.

        :param xacro_path: The path to the local .xacro file.
        :param args: Names and values for the `arg` tags in the .xacro file.
        :param repo_paths: Local paths to all required repos. Key = The description infix. Value = The local repo path.

        :return: The path to the .urdf file.
        """

        if not RobotCreator.TEMP_ROOT.exists():
            RobotCreator.TEMP_ROOT.mkdir(parents=True)

        xacro = xacro_path.read_text(encoding="utf-8")

        # Set the args.
        if args is None:
            args = {"gazebo": 'false'}
        for k in args:
            xacro = re.sub('<xacro:arg name="' + k + '" default="(.*)"',
                           f'<xacro:arg name="{k}" default="{args[k]}"', xacro)
        xacro = re.sub(r'<xacro:include (.*)gazebo(.*?)/>', "", xacro)

        # Put all required .xacro files in a temporary directory.
        xacro_dir = RobotCreator.TEMP_ROOT.joinpath("xacro")
        if not xacro_dir.exists():
            xacro_dir.mkdir(parents=True)
        x = xacro_dir.joinpath(xacro_path.name)
        x.write_text(xacro, encoding="utf-8")

        xacros: List[Path] = [x]
        checked: List[Path] = []
        while len(xacros) > 0:
            xp = xacros.pop(0)
            checked.append(xp)
            xacro = xp.read_text(encoding="utf-8")
            for description in re.findall(r"\$\(find (.*?)\)",
                                          xacro,
                                          flags=re.MULTILINE):
                xacro_repo: Optional[Path] = None
                desc = ""
                for k_desc in repo_paths:
                    if description in k_desc:
                        xacro_repo = repo_paths[k_desc]
                        desc = k_desc
                        break
                assert xacro_repo is not None, f"Couldn't find: {description} in {xacro_repo} for {xp}"
                src_urdf_dir = xacro_repo.joinpath(desc).joinpath("urdf")
                for root_dir, dirs, files in walk(str(src_urdf_dir.resolve())):
                    for f in files:
                        src = Path(root_dir).joinpath(f)
                        if src.is_file() and src.suffix == ".xacro":
                            dst = xacro_dir.joinpath(src.name)
                            if not dst.exists():
                                copy_file(src=str(src.resolve()),
                                          dst=str(dst.resolve()))
                            if src not in xacros and src not in checked:
                                xacros.append(src)
        if not self.quiet:
            print("Copied all required xacro files to a temp directory.")
        # "Repair" all of the required .xacro files.
        for f in xacro_dir.iterdir():
            if f.is_file() and f.suffix == ".xacro":
                xacro = f.read_text(encoding="utf-8")
                xacro = re.sub(r"include filename=\"\$\((.*)\)/(.*)/(.*)\"",
                               r'include filename="\3"', xacro)
                f.write_text(xacro, encoding="utf-8")
        # Finally, create the .urdf file.
        cwd = getcwd()
        chdir(str(RobotCreator.TEMP_ROOT.joinpath("xacro").resolve()))
        urdf_name = x.name.replace(".urdf.xacro",
                                   ".urdf").replace(".xacro", ".urdf")
        xacro_call = [
            "source", "/opt/ros/melodic/setup.bash", "&&", "rosrun", "xacro",
            "xacro", "-o", urdf_name, x.name
        ]
        if system() == "Windows":
            xacro_call.insert(0, "wsl")
        call(xacro_call)
        urdf_path = Path(f"../../Assets/robots/{urdf_name}")
        if urdf_path.exists():
            urdf_path.unlink()
        move_file(src=str(x.parent.joinpath(urdf_name).resolve()),
                  dst=str(urdf_path.resolve()))
        if not self.quiet:
            print(f"Created {str(urdf_path.resolve())}")
        urdf_path = Path(str(urdf_path.resolve()))
        chdir(cwd)
        # Delete temp xacro files.
        remove_tree(str(xacro_dir.resolve()))
        assert urdf_path.exists(), f"Not found: {urdf_path.resolve()}"
        return urdf_path.resolve()
コード例 #14
0
ファイル: setup.py プロジェクト: zhmz90/Dato-Core
    def run(self):
        import platform

        # start by running base class implementation of run
        install.run(self)

        # Check correct version of architecture (64-bit only)
        arch = platform.architecture()[0]
        if arch != '64bit':
            msg = (
                "GraphLab Create currently supports only 64-bit operating systems, and only recent Linux/OSX "
                +
                "architectures. Please install using a supported version. Your architecture is currently: %s"
                % arch)

            sys.stderr.write(msg)
            sys.exit(1)

        # Check correct version of Python
        if sys.version_info[:2] < (2, 7) or sys.version_info[0] > 2:
            msg = (
                "GraphLab Create currently only supports Python 2.7 and does not support any version of Python 3. "
                +
                "Please install using a supported version. Your current Python version is: %s"
                % sys.version)
            sys.stderr.write(msg)
            sys.exit(1)

        # if OSX, verify > 10.7
        from distutils.util import get_platform
        cur_platform = get_platform()

        if cur_platform.startswith("macosx"):
            from pkg_resources import parse_version

            mac_ver = platform.mac_ver()[0]
            if parse_version(mac_ver) < parse_version('10.8.0'):
                msg = (
                    "GraphLab Create currently does not support versions of OSX prior to 10.8. Please upgrade your Mac OSX "
                    "installation to a supported version. Your current OSX version is: %s"
                    % mac_ver)
                sys.stderr.write(msg)
                sys.exit(1)
        elif cur_platform.startswith('linux'):
            pass
        else:
            msg = (
                "Unsupported Platform: '%s'. GraphLab Create is only supported on Mac OSX and Linux."
                % cur_platform)
            sys.stderr.write(msg)
            sys.exit(1)

        print ""
        print ""
        print ""
        print "NOTE:"
        print ""
        print "Thank you for downloading and trying GraphLab Create."
        print ""
        print "GraphLab Create will send usage metrics to Dato, Inc. (when you import the graphlab module) to help us make GraphLab Create better. If you would rather these metrics are not collected, please remove GraphLab Create from your system."
        print ""
        print ""
        print ""
        if not CONFIG.version.endswith("gpu"):
            print "For Nvidia GPU CUDA support, please pip install http://static.dato.com/files/graphlab-create-" + CONFIG.version + ".gpu.tar.gz"

        from distutils import dir_util
        from distutils import file_util
        from distutils import sysconfig
        import stat
        import glob

        root_path = os.path.join(self.install_lib, PACKAGE_NAME)
        # copy the appropriate binaries and overwrite the dummy 0-byte files created
        if (cur_platform.startswith("macosx")):
            dir_util.copy_tree(os.path.join(root_path, "osx"), root_path)
        else:
            dir_util.copy_tree(os.path.join(root_path, "linux"), root_path)

        # move psutil files into place
        for psutil_file in glob.glob(os.path.join(root_path, '_psutil*.so')):
            file_util.move_file(
                psutil_file, os.path.join(root_path, '..', 'graphlab_psutil'))

        # make sure all of our binaries are executable to all
        packaged_binaries = [
            'unity_server', 'pylambda_worker', 'sftordd_pickle',
            'rddtosf_pickle', 'rddtosf_nonpickle', 'spark_pipe_wrapper'
        ]
        packaged_binary_paths = []
        for exe_name in packaged_binaries:
            exe_path = os.path.join(root_path, exe_name)
            st = os.stat(exe_path)
            os.chmod(exe_path,
                     st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)
            packaged_binary_paths.append(exe_path)

        # write uuid to disk for mixpanel metrics
        import uuid

        with open(os.path.join(root_path, "id"), "w") as id_file:
            id_file.write(str(uuid.uuid4()))

        if (cur_platform.startswith("macosx")):
            # We need to do the following rpath modifications. First
            # find all the .so files and execute the following commaands on each .so file:
            #
            # - This removes the absolute path linking against the python framework
            #   and changes it to a relative path against @rpath
            # install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python @rpath/libpython2.7.dylib
            # - This adds an rpath so that we know where to find libpython
            # install_name_tool -add_rpath LIBDIR
            # where LIBDIR = distutils.sysconfig.get_config_var('LIBDIR')
            so_glob = os.path.join(root_path, "cython", "*.so")
            # this appears to consistently tell me where is libpython or the python framework
            LIBDIR = sysconfig.get_config_var('LIBDIR')
            binaries_to_mod = glob.glob(so_glob)
            # Only add the binaries that need to search for libpython
            binaries_to_mod = binaries_to_mod + packaged_binary_paths[0:4]
            for so in binaries_to_mod:
                subprocess.call([
                    "install_name_tool", "-change",
                    "/System/Library/Frameworks/Python.framework/Versions/2.7/Python",
                    "@rpath/libpython2.7.dylib", so
                ])
                subprocess.call(
                    ["install_name_tool", "-add_rpath", LIBDIR, so])
                subprocess.call([
                    "install_name_tool", "-add_rpath",
                    os.path.abspath(os.path.join(root_path, "cython")), so
                ])
コード例 #15
0
ファイル: cmd.py プロジェクト: mcyril/ravel-ftn
"""distutils.cmd
コード例 #16
0
# Copy files to dist/doctmp
print("\nCopying conf.py and sdk directory\n")
copy_file(os.path.join(DIST_PY_FILE_LOCATION, "doc", "conf.py"),
          os.path.join(DIST_DOCTMP_DIR, "conf.py"))
copy_tree(os.path.join(DIST_PY_FILE_LOCATION, "doc", "sdk"), DIST_DOCTMP_DIR)

# Call Sphinx build
print("\nCalling sphinx-build\n")
subprocess.check_call([
    "sphinx-build", "-b", "html", DIST_DOCTMP_DIR,
    os.path.join(DIST_DIRECTORY, "doc")
])

# Move README.html to root of dist directory
print("\nMoving README.html\n")
move_file(os.path.join(DIST_DOCTMP_DIR, "README.html"), DIST_DIRECTORY)

# Remove doctmp directory
print("\nDeleting doctmp directory\n")
remove_tree(DIST_DOCTMP_DIR)

# Call setup.py
print("\nRunning setup.py sdist\n")
run_setup(SETUP_PY,
          ["sdist", "--format", "zip", "--dist-dir", DIST_LIB_DIRECTORY])

print("\nRunning setup.py bdist_egg\n")
run_setup(SETUP_PY, ["bdist_egg", "--dist-dir", DIST_LIB_DIRECTORY])

print("\nRunning setup.py bdist_wheel\n")
run_setup(
コード例 #17
0
 def move_file (self, src, dst):
     return move_file (src, dst, verbose=self.verbose, dry_run=self.dry_run)
コード例 #18
0
 def move_file(self, src, dst, level=1):
     """Move a file respecting verbose and dry-run flags."""
     return file_util.move_file(src, dst, self.verbose >= level,
                                self.dry_run)
コード例 #19
0
## this requires napi.sh (https://github.com/dagon666/napi)
## for automatic subtitles download 
def download_subtitles(movie_path):
            if SUBTITLE_DOWNLOAD:
                out = check_output([NAPI_SH_PATH,movie_path])
                # napisy sie pobraly czyli nie znaleziono ciagu UNAV
                # poprawiam umask napisow (https://github.com/dagon666/napi/issues/33)
                if out.find("UNAV") < 0:
                    subtitle_file=movie_path.split(".")[:-1]
                    subtitle_file.append("srt")
                    subtitle_file=".".join(subtitle_file)
                    chmod(subtitle_file,SUBTITLE_DEFAULT_PERMISSIONS)

# launch from cli if not used as module
if __name__ == "__main__":
    if len(sys.argv) > 1:
        # extract final filename
        filename=path.split(sys.argv[1])[-1]
        show = get_metadata(filename)
        if show:
            dest_d=build_storage_path(show)
            dest_f=make_new_name(show)
            make_storage_path(dest_d)
            print("Moving {0} -> {1}".format(filename,path.join(dest_d,dest_f)))
            print(move_file(sys.argv[1],path.join(dest_d,dest_f)))
            ## dociagamy napisy
            download_subtitles(path.join(dest_d,dest_f))
        else:
            print "Show not parsed"

コード例 #20
0
ファイル: cmd.py プロジェクト: mcyril/ravel-ftn
"""distutils.cmd
コード例 #21
0
 def move_file(self, src, dst):
     return move_file(src, dst, dry_run=self.dry_run)
コード例 #22
0
ファイル: test_file_util.py プロジェクト: MYSHLIFE/cpython-1
 def test_move_file_exception_unpacking_unlink(self, rename, unlink):
     # see issue 22182
     with self.assertRaises(DistutilsFileError):
         with open(self.source, 'w') as fobj:
             fobj.write('spam eggs')
         move_file(self.source, self.target, verbose=0)
コード例 #23
0
ファイル: __init__.py プロジェクト: mstriemer/dotfiles
def move_if_exists(src, dst):
    if os.path.exist(src):
        move_file(src, dst)
コード例 #24
0
 def move_debian_package_to_distdir(self):
     for deb_package in glob.glob('build/*.deb'):
         move_file(deb_package, self.dist_dir)
コード例 #25
0
"""distutils.ccompiler
コード例 #26
0
    def run(self):
        """Run the distutils command"""
        log.info("installing library code to %s" % self.bdist_dir)

        log.info("generating INFO_SRC and INFO_BIN files")
        generate_info_files()

        self.dist_name = get_dist_name(self.distribution,
                                       source_only_dist=True,
                                       python_version=get_python_version()[0])
        self.dist_target = os.path.join(self.dist_dir, self.dist_name)
        log.info("distribution will be available as '%s'" % self.dist_target)

        # build command: just to get the build_base
        cmdbuild = self.get_finalized_command("build")
        self.build_base = cmdbuild.build_base

        # install command
        install = self.reinitialize_command('install_lib',
                                            reinit_subcommands=1)
        install.compile = False
        install.warn_dir = 0
        install.install_dir = self.bdist_dir

        log.info("installing to %s" % self.bdist_dir)
        self.run_command('install_lib')

        # install extra files
        extra_files = {}
        for src, dest in extra_files.items():
            self.copy_file(src, dest)

        # install_egg_info command
        cmd_egginfo = self.get_finalized_command('install_egg_info')
        cmd_egginfo.install_dir = self.bdist_dir
        self.run_command('install_egg_info')
        # we need the py2.x converted to py2 in the filename
        old_egginfo = cmd_egginfo.get_outputs()[0]
        new_egginfo = old_egginfo.replace('-py' + sys.version[:3],
                                          '-py' + get_python_version()[0])
        move_file(old_egginfo, new_egginfo)

        # create distribution
        info_files = [
            ('README.txt', 'README.txt'),
            ('LICENSE.txt', 'LICENSE.txt'),
            ('README.rst', 'README.rst'),
            ('CONTRIBUTING.rst', 'CONTRIBUTING.rst'),
            ('docs/INFO_SRC', 'INFO_SRC'),
            ('docs/INFO_BIN', 'INFO_BIN'),
        ]
        copy_tree(self.bdist_dir, self.dist_target)
        pkg_info = mkpath(os.path.join(self.dist_target))
        for src, dst in info_files:
            if dst is None:
                copy_file(src, self.dist_target)
            else:
                copy_file(src, os.path.join(self.dist_target, dst))

        if not self.keep_temp:
            remove_tree(self.build_base, dry_run=self.dry_run)
コード例 #27
0
ファイル: bdist_deb.py プロジェクト: jonnybest/taskcoach
 def move_debian_package_to_distdir(self):
     for deb_package in glob.glob('build/*.deb'):
         move_file(deb_package, self.dist_dir)
コード例 #28
0
           longpath_win32_prefix + ECLIPSE_DISTRO_WIN32_DIR + ".BAK")
 printProgressBar(2, 2)
 print("Done.\n")
 #
 # INFO: move all files and platform-sensitive directories from root folder with no check
 #
 print("\nSplitting\n------------------------------------")
 print("\nSplitting sensitive root files...")
 linux_sensitives = listdir(ECLIPSE_DISTRO_LINUX_DIR)
 win32_sensitives = listdir(ECLIPSE_DISTRO_WIN32_DIR)
 i = 0
 printProgressBar(i, len(linux_sensitives) + len(win32_sensitives))
 for f in linux_sensitives:
     path = join(ECLIPSE_DISTRO_LINUX_DIR, f)
     if isfile(path):
         move_file(join(ECLIPSE_DISTRO_LINUX_DIR, f), ECLIPSE_LINUX_DIR)
     elif path.endswith("configuration"):
         copy_tree(
             longpath_win32_prefix + join(ECLIPSE_DISTRO_LINUX_DIR, f),
             longpath_win32_prefix + ECLIPSE_LINUX_DIR + slash +
             "configuration")
         remove_tree(longpath_win32_prefix +
                     join(ECLIPSE_DISTRO_LINUX_DIR, f))
     elif path.endswith("dropins"):
         copy_tree(
             longpath_win32_prefix + join(ECLIPSE_DISTRO_LINUX_DIR, f),
             longpath_win32_prefix + ECLIPSE_LINUX_DIR + slash + "dropins")
         remove_tree(longpath_win32_prefix +
                     join(ECLIPSE_DISTRO_LINUX_DIR, f))
     elif path.endswith("p2"):
         copy_tree(
コード例 #29
0
ファイル: setup.py プロジェクト: hamdyMostafa/Dato-Core
    def run(self):
        import platform

        # start by running base class implementation of run
        install.run(self)

        # Check correct version of architecture (64-bit only)
        arch = platform.architecture()[0]
        if arch != "64bit":
            msg = (
                "GraphLab Create currently supports only 64-bit operating systems, and only recent Linux/OSX "
                + "architectures. Please install using a supported version. Your architecture is currently: %s" % arch
            )

            sys.stderr.write(msg)
            sys.exit(1)

        # Check correct version of Python
        if sys.version_info[:2] < (2, 7) or sys.version_info[0] > 2:
            msg = (
                "GraphLab Create currently only supports Python 2.7 and does not support any version of Python 3. "
                + "Please install using a supported version. Your current Python version is: %s" % sys.version
            )
            sys.stderr.write(msg)
            sys.exit(1)

        # if OSX, verify > 10.7
        from distutils.util import get_platform

        cur_platform = get_platform()

        if cur_platform.startswith("macosx"):
            from pkg_resources import parse_version

            mac_ver = platform.mac_ver()[0]
            if parse_version(mac_ver) < parse_version("10.8.0"):
                msg = (
                    "GraphLab Create currently does not support versions of OSX prior to 10.8. Please upgrade your Mac OSX "
                    "installation to a supported version. Your current OSX version is: %s" % mac_ver
                )
                sys.stderr.write(msg)
                sys.exit(1)
        elif cur_platform.startswith("linux"):
            pass
        else:
            msg = "Unsupported Platform: '%s'. GraphLab Create is only supported on Mac OSX and Linux." % cur_platform
            sys.stderr.write(msg)
            sys.exit(1)

        print ""
        print ""
        print ""
        print "NOTE:"
        print ""
        print "Thank you for downloading and trying GraphLab Create."
        print ""
        print "GraphLab Create will send usage metrics to Dato, Inc. (when you import the graphlab module) to help us make GraphLab Create better. If you would rather these metrics are not collected, please remove GraphLab Create from your system."
        print ""
        print ""
        print ""
        if not CONFIG.version.endswith("gpu"):
            print "For Nvidia GPU CUDA support, please pip install http://static.dato.com/files/graphlab-create-" + CONFIG.version + ".gpu.tar.gz"

        from distutils import dir_util
        from distutils import file_util
        from distutils import sysconfig
        import stat
        import glob

        root_path = os.path.join(self.install_lib, PACKAGE_NAME)
        # copy the appropriate binaries and overwrite the dummy 0-byte files created
        if cur_platform.startswith("macosx"):
            dir_util.copy_tree(os.path.join(root_path, "osx"), root_path)
        else:
            dir_util.copy_tree(os.path.join(root_path, "linux"), root_path)

        # move psutil files into place
        for psutil_file in glob.glob(os.path.join(root_path, "_psutil*.so")):
            file_util.move_file(psutil_file, os.path.join(root_path, "..", "graphlab_psutil"))

        # make sure all of our binaries are executable to all
        packaged_binaries = [
            "unity_server",
            "pylambda_worker",
            "sftordd_pickle",
            "rddtosf_pickle",
            "rddtosf_nonpickle",
            "spark_pipe_wrapper",
        ]
        packaged_binary_paths = []
        for exe_name in packaged_binaries:
            exe_path = os.path.join(root_path, exe_name)
            st = os.stat(exe_path)
            os.chmod(exe_path, st.st_mode | stat.S_IEXEC | stat.S_IXOTH | stat.S_IXGRP)
            packaged_binary_paths.append(exe_path)

        # write uuid to disk for mixpanel metrics
        import uuid

        with open(os.path.join(root_path, "id"), "w") as id_file:
            id_file.write(str(uuid.uuid4()))

        if cur_platform.startswith("macosx"):
            # We need to do the following rpath modifications. First
            # find all the .so files and execute the following commaands on each .so file:
            #
            # - This removes the absolute path linking against the python framework
            #   and changes it to a relative path against @rpath
            # install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python @rpath/libpython2.7.dylib
            # - This adds an rpath so that we know where to find libpython
            # install_name_tool -add_rpath LIBDIR
            # where LIBDIR = distutils.sysconfig.get_config_var('LIBDIR')
            so_glob = os.path.join(root_path, "cython", "*.so")
            # this appears to consistently tell me where is libpython or the python framework
            LIBDIR = sysconfig.get_config_var("LIBDIR")
            binaries_to_mod = glob.glob(so_glob)
            # Only add the binaries that need to search for libpython
            binaries_to_mod = binaries_to_mod + packaged_binary_paths[0:4]
            for so in binaries_to_mod:
                subprocess.call(
                    [
                        "install_name_tool",
                        "-change",
                        "/System/Library/Frameworks/Python.framework/Versions/2.7/Python",
                        "@rpath/libpython2.7.dylib",
                        so,
                    ]
                )
                subprocess.call(["install_name_tool", "-add_rpath", LIBDIR, so])
                subprocess.call(
                    ["install_name_tool", "-add_rpath", os.path.abspath(os.path.join(root_path, "cython")), so]
                )
コード例 #30
0
 def move_file(self, src, dst):
     return move_file(src, dst, verbose=self.verbose, dry_run=self.dry_run)
コード例 #31
0
    remove_tree( BUILD_DIR )
    time.sleep( 0.5 )

os.makedirs( BUILD_DIR )

ver = minidom.parse( PDSC_FILE ).getElementsByTagName( 'release' )[ 0 ].attributes[ 'version' ].value
print 'Version', ver

pack = PACK_TEMPL % ver

if os.path.exists( pack ):
    print 'Backup', pack
    bak = pack + '.bak'
    if os.path.exists( bak ):
        os.remove( bak )
    move_file( pack, bak )

print 'Copy'
print ' ', PDSC_FILE
copy_file( PDSC_FILE, BUILD_DIR )

for op in copylist:
    p = os.path.join( BUILD_DIR, op[ 1 ])
    if not os.path.exists( p ):
        os.makedirs( p )
    print 'Copy to', p
    n = 0
    for f in glob.glob( os.path.join( SOURCE_DIR, op[ 0 ])):
        print ' ', f
        n += 1
        if os.path.isdir( f ):
コード例 #32
0
ファイル: ccompiler.py プロジェクト: mcyril/ravel-ftn
"""distutils.ccompiler
コード例 #33
0
ファイル: cmd.py プロジェクト: JoeLeclercq/jesWork
 def move_file(self, src, dst, level=1):
     """Move a file respectin dry-run flag."""
     return file_util.move_file(src, dst, dry_run=self.dry_run)
コード例 #34
0
ファイル: build.py プロジェクト: in4lio/mdr1986x-pack-repo
    remove_tree( BUILD_DIR )
    time.sleep( 0.5 )

os.makedirs( BUILD_DIR )

ver = minidom.parse( PDSC_FILE ).getElementsByTagName( 'release' )[ 0 ].attributes[ 'version' ].value
print 'Version', ver

pack = PACK_TEMPL % ver

if os.path.exists( pack ):
    print 'Backup', pack
    bak = pack + '.bak'
    if os.path.exists( bak ):
        os.remove( bak )
    move_file( pack, bak )

print 'Copy'
print ' ', PDSC_FILE
copy_file( PDSC_FILE, BUILD_DIR )

for op in copylist:
    p = os.path.join( BUILD_DIR, op[ 1 ])
    if not os.path.exists( p ):
        os.makedirs( p )
    print 'Copy to', p
    n = 0
    for f in glob.glob( os.path.join( SOURCE_DIR, op[ 0 ])):
        print ' ', f
        n += 1
        if os.path.isdir( f ):
コード例 #35
0
 def move_file (self, src, dst, level=1):
     """Move a file respectin dry-run flag."""
     return file_util.move_file(src, dst, dry_run=self.dry_run)
コード例 #36
0
ファイル: cmd.py プロジェクト: bizonix/DropBoxLibrarySRC
 def move_file(self, src, dst, level = 1):
     return file_util.move_file(src, dst, dry_run=self.dry_run)
コード例 #37
0
 def move_file(self, src, dst):
     return move_file(src, dst, dry_run=self.dry_run)
コード例 #38
0
 def move_file(self, src, dst, level=1):
     return file_util.move_file(src, dst, dry_run=self.dry_run)