Python wxPython() Examples
The following are 30
code examples of wxPython().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: common.py From py with MIT License | 7 votes |
def bestrelpath(self, dest): """ return a string which is a relative path from self (assumed to be a directory) to dest such that self.join(bestrelpath) == dest and if not such path can be determined return dest. """ try: if self == dest: return os.curdir base = self.common(dest) if not base: # can be the case on windows return str(dest) self2base = self.relto(base) reldest = dest.relto(base) if self2base: n = self2base.count(self.sep) + 1 else: n = 0 l = [os.pardir] * n if reldest: l.append(reldest) target = dest.sep.join(l) return target except AttributeError: return str(dest)
Example #2
Source File: ez_setup.py From flyover with MIT License | 6 votes |
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """ Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. ``downloader_factory`` should be a function taking no arguments and returning a function for downloading a URL to a target. """ # making sure we use the absolute path to_dir = os.path.abspath(to_dir) zip_name = "setuptools-%s.zip" % version url = download_base + zip_name saveto = os.path.join(to_dir, zip_name) if not os.path.exists(saveto): # Avoid repeated downloads log.warn("Downloading %s", url) downloader = downloader_factory() downloader(url, saveto) return os.path.realpath(saveto)
Example #3
Source File: ez_setup.py From Adafruit_Python_ILI9341 with MIT License | 6 votes |
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """ Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. ``downloader_factory`` should be a function taking no arguments and returning a function for downloading a URL to a target. """ # making sure we use the absolute path to_dir = os.path.abspath(to_dir) zip_name = "setuptools-%s.zip" % version url = download_base + zip_name saveto = os.path.join(to_dir, zip_name) if not os.path.exists(saveto): # Avoid repeated downloads log.warn("Downloading %s", url) downloader = downloader_factory() downloader(url, saveto) return os.path.realpath(saveto)
Example #4
Source File: helper.py From Faraday-Software with GNU General Public License v3.0 | 6 votes |
def getLogger(self): """ Get logger configuration and create instance of a logger """ # Known paths where loggingConfig.ini can exist relpath1 = os.path.join('etc', 'faraday') relpath2 = os.path.join('..', 'etc', 'faraday') setuppath = os.path.join(sys.prefix, 'etc', 'faraday') userpath = os.path.join(os.path.expanduser('~'), '.faraday') self.path = '' # Check all directories until first instance of loggingConfig.ini for location in os.curdir, relpath1, relpath2, setuppath, userpath: try: logging.config.fileConfig(os.path.join(location, "loggingConfig.ini")) self.path = location break except ConfigParser.NoSectionError: pass self._logger = logging.getLogger(self._name) return self._logger
Example #5
Source File: model.py From benchexec with Apache License 2.0 | 6 votes |
def cmdline_for_run(tool, executable, options, sourcefiles, propertyfile, rlimits): working_directory = tool.working_directory(executable) def relpath(path): return path if os.path.isabs(path) else os.path.relpath(path, working_directory) rel_executable = relpath(executable) if os.path.sep not in rel_executable: rel_executable = os.path.join(os.curdir, rel_executable) args = tool.cmdline( rel_executable, list(options), list(map(relpath, sourcefiles)), relpath(propertyfile) if propertyfile else None, rlimits.copy(), ) assert all(args), "Tool cmdline contains empty or None argument: " + str(args) args = [os.path.expandvars(arg) for arg in args] args = [os.path.expanduser(arg) for arg in args] return args
Example #6
Source File: longclaw.py From longclaw with MIT License | 6 votes |
def build_assets(args): """ Build the longclaw assets """ # Get the path to the JS directory asset_path = path.join(path.dirname(longclaw.__file__), 'client') try: # Move into client dir curdir = os.path.abspath(os.curdir) os.chdir(asset_path) print('Compiling assets....') subprocess.check_call(['npm', 'install']) subprocess.check_call(['npm', 'run', 'build']) os.chdir(curdir) print('Complete!') except (OSError, subprocess.CalledProcessError) as err: print('Error compiling assets: {}'.format(err)) raise SystemExit(1)
Example #7
Source File: ez_setup.py From Adafruit_Python_BMP with MIT License | 6 votes |
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """ Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. ``downloader_factory`` should be a function taking no arguments and returning a function for downloading a URL to a target. """ # making sure we use the absolute path to_dir = os.path.abspath(to_dir) zip_name = "setuptools-%s.zip" % version url = download_base + zip_name saveto = os.path.join(to_dir, zip_name) if not os.path.exists(saveto): # Avoid repeated downloads log.warn("Downloading %s", url) downloader = downloader_factory() downloader(url, saveto) return os.path.realpath(saveto)
Example #8
Source File: ez_setup.py From bugbuzz-python with MIT License | 6 votes |
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """ Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. ``downloader_factory`` should be a function taking no arguments and returning a function for downloading a URL to a target. """ # making sure we use the absolute path to_dir = os.path.abspath(to_dir) zip_name = "setuptools-%s.zip" % version url = download_base + zip_name saveto = os.path.join(to_dir, zip_name) if not os.path.exists(saveto): # Avoid repeated downloads log.warn("Downloading %s", url) downloader = downloader_factory() downloader(url, saveto) return os.path.realpath(saveto)
Example #9
Source File: pycodestyle.py From linter-pylama with MIT License | 6 votes |
def normalize_paths(value, parent=os.curdir): """Parse a comma-separated list of paths. Return a list of absolute paths. """ if not value: return [] if isinstance(value, list): return value paths = [] for path in value.split(','): path = path.strip() if '/' in path: path = os.path.abspath(os.path.join(parent, path)) paths.append(path.rstrip('/')) return paths
Example #10
Source File: build_ext.py From jbox with MIT License | 6 votes |
def copy_extensions_to_source(self): build_py = self.get_finalized_command('build_py') for ext in self.extensions: fullname = self.get_ext_fullname(ext.name) filename = self.get_ext_filename(fullname) modpath = fullname.split('.') package = '.'.join(modpath[:-1]) package_dir = build_py.get_package_dir(package) dest_filename = os.path.join(package_dir, os.path.basename(filename)) src_filename = os.path.join(self.build_lib, filename) # Always copy, even if source is older than destination, to ensure # that the right extensions for the current Python/platform are # used. copy_file( src_filename, dest_filename, verbose=self.verbose, dry_run=self.dry_run ) if ext._needs_stub: self.write_stub(package_dir or os.curdir, ext, True)
Example #11
Source File: util.py From recruit with Apache License 2.0 | 6 votes |
def convert_path(pathname): """Return 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError on non-Unix-ish systems if 'pathname' either starts or ends with a slash. """ if os.sep == '/': return pathname if not pathname: return pathname if pathname[0] == '/': raise ValueError("path '%s' cannot be absolute" % pathname) if pathname[-1] == '/': raise ValueError("path '%s' cannot end with '/'" % pathname) paths = pathname.split('/') while os.curdir in paths: paths.remove(os.curdir) if not paths: return os.curdir return os.path.join(*paths)
Example #12
Source File: utils.py From linter-pylama with MIT License | 6 votes |
def normalize_path(path, parent=os.curdir): # type: (str, str) -> str """Normalize a single-path. :returns: The normalized path. :rtype: str """ # NOTE(sigmavirus24): Using os.path.sep and os.path.altsep allow for # Windows compatibility with both Windows-style paths (c:\\foo\bar) and # Unix style paths (/foo/bar). separator = os.path.sep # NOTE(sigmavirus24): os.path.altsep may be None alternate_separator = os.path.altsep or '' if separator in path or (alternate_separator and alternate_separator in path): path = os.path.abspath(os.path.join(parent, path)) return path.rstrip(separator + alternate_separator)
Example #13
Source File: util.py From jbox with MIT License | 6 votes |
def convert_path(pathname): """Return 'pathname' as a name that will work on the native filesystem. The path is split on '/' and put back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError on non-Unix-ish systems if 'pathname' either starts or ends with a slash. """ if os.sep == '/': return pathname if not pathname: return pathname if pathname[0] == '/': raise ValueError("path '%s' cannot be absolute" % pathname) if pathname[-1] == '/': raise ValueError("path '%s' cannot end with '/'" % pathname) paths = pathname.split('/') while os.curdir in paths: paths.remove(os.curdir) if not paths: return os.curdir return os.path.join(*paths)
Example #14
Source File: conanfile.py From conan-center-index with MIT License | 6 votes |
def build(self): use_windows_commands = os.name == 'nt' command = "build" if use_windows_commands else "./build.sh" if self.options.toolset != 'auto': command += " "+str(self.options.toolset) build_dir = os.path.join(self.source_folder, "source") engine_dir = os.path.join(build_dir, "src", "engine") os.chdir(engine_dir) with tools.environment_append({"VSCMD_START_DIR": os.curdir}): if self.options.use_cxx_env: # Allow use of CXX env vars. self.run(command) else: # To avoid using the CXX env vars we clear them out for the build. with tools.environment_append({"CXX": "", "CXXFLAGS": ""}): self.run(command) os.chdir(build_dir) command = os.path.join( engine_dir, "b2.exe" if use_windows_commands else "b2") full_command = \ "{0} --ignore-site-config --prefix=../output --abbreviate-paths install".format( command) self.run(full_command)
Example #15
Source File: modules.py From Nest with MIT License | 6 votes |
def _update_namespaces(self) -> None: """Get the available namespaces. """ # user defined search paths dir_list = set() self.namespaces = dict() for k, v in settings['SEARCH_PATHS'].items(): if os.path.isdir(v): meta_path = os.path.join(v, settings['NAMESPACE_CONFIG_FILENAME']) meta = U.load_yaml(meta_path)[0] if os.path.exists(meta_path) else dict() meta['module_path'] = os.path.abspath(os.path.join(v, meta.get('module_path', './'))) if os.path.isdir(meta['module_path']): self.namespaces[k] = meta dir_list.add(meta['module_path']) else: U.alert_msg('Namespace "%s" has an invalid module path "%s".' % (k, meta['module_path'])) # current path current_path = os.path.abspath(os.curdir) if not current_path in dir_list: self.namespaces['main'] = dict(module_path=current_path)
Example #16
Source File: ez_setup.py From alienfx with GNU General Public License v3.0 | 5 votes |
def use_setuptools( version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15 ): """Automatically find/download setuptools and make it available on sys.path `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where setuptools will be downloaded, if it is not already available. If `download_delay` is specified, it should be the number of seconds that will be paused before initiating a download, should one be required. If an older version of setuptools is installed, this routine will print a message to ``sys.stderr`` and raise SystemExit in an attempt to abort the calling script. """ was_imported = 'pkg_resources' in sys.modules or 'setuptools' in sys.modules def do_download(): egg = download_setuptools(version, download_base, to_dir, download_delay) sys.path.insert(0, egg) import setuptools; setuptools.bootstrap_install_from = egg try: import pkg_resources except ImportError: return do_download() try: pkg_resources.require("setuptools>="+version); return except pkg_resources.VersionConflict as e: if was_imported: print(( "The required version of setuptools (>=%s) is not available, and\n" "can't be installed while this script is running. Please install\n" " a more recent version first, using 'easy_install -U setuptools'." "\n\n(Currently using %r)" ) % (version, e.args[0]), file=sys.stderr) sys.exit(2) except pkg_resources.DistributionNotFound: pass del pkg_resources, sys.modules['pkg_resources'] # reload ok return do_download()
Example #17
Source File: semdictionary.py From mishkal with GNU General Public License v3.0 | 5 votes |
def __init__(self): """ initialisation of dictionary from a data dictionary, create indexes to speed up the access. """ # get the database path if hasattr(sys, 'frozen'): # only when running in py2exe this exists base = sys.prefix else: # otherwise this is a regular python script base = os.path.dirname(os.path.realpath(__file__)) file_path = os.path.join(base, FILE_DB) self.db_connect = False if os.path.exists(file_path): try: self.db_connect = sqlite.connect(file_path) self.db_connect.row_factory = sqlite.Row self.cursor = self.db_connect.cursor() except IOError: print("Fatal Error Can't find the database file", file_path) if __name__ == '__main__': sys.exit(); else: print(u" ".join(["Inexistant File", file_path, " current dir ", os.curdir]).encode('utf8')) if __name__ == '__main__': sys.exit();
Example #18
Source File: ez_setup.py From Adafruit_Python_BMP with MIT License | 5 votes |
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15): to_dir = os.path.abspath(to_dir) rep_modules = 'pkg_resources', 'setuptools' imported = set(sys.modules).intersection(rep_modules) try: import pkg_resources except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: pkg_resources.require("setuptools>=" + version) return except pkg_resources.DistributionNotFound: return _do_download(version, download_base, to_dir, download_delay) except pkg_resources.VersionConflict as VC_err: if imported: msg = textwrap.dedent(""" The required version of setuptools (>={version}) is not available, and can't be installed while this script is running. Please install a more recent version first, using 'easy_install -U setuptools'. (Currently using {VC_err.args[0]!r}) """).format(VC_err=VC_err, version=version) sys.stderr.write(msg) sys.exit(2) # otherwise, reload ok del pkg_resources, sys.modules['pkg_resources'] return _do_download(version, download_base, to_dir, download_delay)
Example #19
Source File: ez_setup.py From vpython-jupyter with MIT License | 5 votes |
def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, download_delay=15, no_fake=True): # making sure we use the absolute path to_dir = os.path.abspath(to_dir) was_imported = 'pkg_resources' in sys.modules or \ 'setuptools' in sys.modules try: try: import pkg_resources if not hasattr(pkg_resources, '_distribute'): if not no_fake: _fake_setuptools() raise ImportError except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: pkg_resources.require("distribute>="+version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( "The required version of distribute (>=%s) is not available,\n" "and can't be installed while this script is running. Please\n" "install a more recent version first, using\n" "'easy_install -U distribute'." "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok return _do_download(version, download_base, to_dir, download_delay) except pkg_resources.DistributionNotFound: return _do_download(version, download_base, to_dir, download_delay) finally: if not no_fake: _create_fake_setuptools_pkg_info(to_dir)
Example #20
Source File: build_ext.py From jbox with MIT License | 5 votes |
def finalize_options(self): _build_ext.finalize_options(self) self.extensions = self.extensions or [] self.check_extensions_list(self.extensions) self.shlibs = [ext for ext in self.extensions if isinstance(ext, Library)] if self.shlibs: self.setup_shlib_compiler() for ext in self.extensions: ext._full_name = self.get_ext_fullname(ext.name) for ext in self.extensions: fullname = ext._full_name self.ext_map[fullname] = ext # distutils 3.1 will also ask for module names # XXX what to do with conflicts? self.ext_map[fullname.split('.')[-1]] = ext ltd = self.shlibs and self.links_to_dynamic(ext) or False ns = ltd and use_stubs and not isinstance(ext, Library) ext._links_to_dynamic = ltd ext._needs_stub = ns filename = ext._file_name = self.get_ext_filename(fullname) libdir = os.path.dirname(os.path.join(self.build_lib, filename)) if ltd and libdir not in ext.library_dirs: ext.library_dirs.append(libdir) if ltd and use_stubs and os.curdir not in ext.runtime_library_dirs: ext.runtime_library_dirs.append(os.curdir)
Example #21
Source File: ez_setup.py From vpython-jupyter with MIT License | 5 votes |
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename `version` should be a valid distribute version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the number of seconds to pause before an actual download attempt. """ # making sure we use the absolute path to_dir = os.path.abspath(to_dir) try: from urllib.request import urlopen except ImportError: from urllib2 import urlopen tgz_name = "distribute-%s.tar.gz" % version url = download_base + tgz_name saveto = os.path.join(to_dir, tgz_name) src = dst = None if not os.path.exists(saveto): # Avoid repeated downloads try: log.warn("Downloading %s", url) src = urlopen(url) # Read/write all in one block, so we don't create a corrupt file # if the download is interrupted. data = src.read() dst = open(saveto, "wb") dst.write(data) finally: if src: src.close() if dst: dst.close() return os.path.realpath(saveto)
Example #22
Source File: egg_info.py From jbox with MIT License | 5 votes |
def check_broken_egg_info(self): bei = self.egg_name + '.egg-info' if self.egg_base != os.curdir: bei = os.path.join(self.egg_base, bei) if os.path.exists(bei): log.warn( "-" * 78 + '\n' "Note: Your current .egg-info directory has a '-' in its name;" '\nthis will not work correctly with "setup.py develop".\n\n' 'Please rename %s to %s to correct this problem.\n' + '-' * 78, bei, self.egg_info ) self.broken_egg_info = self.egg_info self.egg_info = bei # make it work for now
Example #23
Source File: egg_info.py From jbox with MIT License | 5 votes |
def get_svn_revision(): if 'svn_utils' not in globals(): return "0" return str(svn_utils.SvnInfo.load(os.curdir).get_revision())
Example #24
Source File: ez_setup.py From vpython-jupyter with MIT License | 5 votes |
def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) setuptools_file = 'setuptools-%s-py%s.egg-info' % \ (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) return log.warn('Creating %s', pkg_info) f = open(pkg_info, 'w') try: f.write(SETUPTOOLS_PKG_INFO) finally: f.close() pth_file = os.path.join(placeholder, 'setuptools.pth') log.warn('Creating %s', pth_file) f = open(pth_file, 'w') try: f.write(os.path.join(os.curdir, setuptools_file)) finally: f.close()
Example #25
Source File: easy_install.py From jbox with MIT License | 5 votes |
def make_relative(self, path): npath, last = os.path.split(normalize_path(path)) baselen = len(self.basedir) parts = [last] sep = os.altsep == '/' and '/' or os.sep while len(npath) >= baselen: if npath == self.basedir: parts.append(os.curdir) parts.reverse() return sep.join(parts) npath, last = os.path.split(npath) parts.append(last) else: return path
Example #26
Source File: __init__.py From jbox with MIT License | 5 votes |
def findall(dir=os.curdir): """ Find all files under 'dir' and return the list of full filenames. Unless dir is '.', return full filenames with dir prepended. """ files = _find_all_simple(dir) if dir == os.curdir: make_rel = functools.partial(os.path.relpath, start=dir) files = map(make_rel, files) return list(files) # fix findall bug in distutils (http://bugs.python.org/issue12885)
Example #27
Source File: download.py From jbox with MIT License | 5 votes |
def __init__(self, *args, **kw): super(DownloadCommand, self).__init__(*args, **kw) cmd_opts = self.cmd_opts cmd_opts.add_option(cmdoptions.constraints()) cmd_opts.add_option(cmdoptions.editable()) cmd_opts.add_option(cmdoptions.requirements()) cmd_opts.add_option(cmdoptions.build_dir()) cmd_opts.add_option(cmdoptions.no_deps()) cmd_opts.add_option(cmdoptions.global_options()) cmd_opts.add_option(cmdoptions.no_binary()) cmd_opts.add_option(cmdoptions.only_binary()) cmd_opts.add_option(cmdoptions.src()) cmd_opts.add_option(cmdoptions.pre()) cmd_opts.add_option(cmdoptions.no_clean()) cmd_opts.add_option(cmdoptions.require_hashes()) cmd_opts.add_option( '-d', '--dest', '--destination-dir', '--destination-directory', dest='download_dir', metavar='dir', default=os.curdir, help=("Download packages into <dir>."), ) index_opts = cmdoptions.make_option_group( cmdoptions.non_deprecated_index_group, self.parser, ) self.parser.insert_option_group(0, index_opts) self.parser.insert_option_group(0, cmd_opts)
Example #28
Source File: test_hdf5.py From sprocket with MIT License | 5 votes |
def test_HDF5_current_dir(self): listf_current = os.path.split(listf)[-1] data1d = np.random.rand(50) try: h5_write = HDF5(Path(listf_current) if sys.version_info >= (3,6) else listf_current, 'w') h5_write.save(data1d, '1d') h5_write.close() h5_read = HDF5(os.curdir + os.sep + listf_current, 'r') read_data1d = h5_read.read(ext='1d') h5_read.close() assert np.allclose(data1d, read_data1d) except: # pragma: no cover raise finally: os.remove(listf_current)
Example #29
Source File: doctest24.py From mishkal with GNU General Public License v3.0 | 5 votes |
def _module_relative_path(module, path): if not inspect.ismodule(module): raise TypeError, 'Expected a module: %r' % module if path.startswith('/'): raise ValueError, 'Module-relative files may not have absolute paths' # Find the base directory for the path. if hasattr(module, '__file__'): # A normal module/package basedir = os.path.split(module.__file__)[0] elif module.__name__ == '__main__': # An interactive session. if len(sys.argv)>0 and sys.argv[0] != '': basedir = os.path.split(sys.argv[0])[0] else: basedir = os.curdir else: # A module w/o __file__ (this includes builtins) raise ValueError("Can't resolve paths relative to the module " + module + " (it has no __file__)") # Combine the base directory and the path. return os.path.join(basedir, *(path.split('/'))) ###################################################################### ## 2. Example & DocTest ###################################################################### ## - An "example" is a <source, want> pair, where "source" is a ## fragment of source code, and "want" is the expected output for ## "source." The Example class also includes information about ## where the example was extracted from. ## ## - A "doctest" is a collection of examples, typically extracted from ## a string (such as an object's docstring). The DocTest class also ## includes information about where the string was extracted from.
Example #30
Source File: check-cocos-360.py From githubtools with MIT License | 5 votes |
def scan(path): _engine2 = [] for root, dirs, files in os.walk(path): for file in files: if file.endswith(".so"): print file fPath = os.path.join(root, file) check = check_engine(fPath) #print check for item in check: #print 'check:'+item #print _engine2.count(item) if(_engine2.count(item) == 0): #print '_engine2 add:' + item _engine2.append(item) return _engine2 # def unzip(source_filename, dest_dir): # print source_filename # with zipfile.ZipFile(source_filename) as zf: # for member in zf.infolist(): # # Path traversal defense copied from # # http://hg.python.org/cpython/file/tip/Lib/http/server.py#l789 # words = member.filename.split('/') # path = dest_dir # for word in words[:-1]: # drive, word = os.path.splitdrive(word) # head, word = os.path.split(word) # if word in (os.curdir, os.pardir, ''): continue # path = os.path.join(path, word) # zf.extract(member, path)