Permalink
Browse files

add script to purge installation

  • Loading branch information...
giampaolo committed Apr 27, 2018
1 parent 553e8f7 commit 3dd56280075702472a2c1515a19edd9ae8c74252
Showing with 46 additions and 3 deletions.
  1. +2 −1 Makefile
  2. +2 −1 pyftpdlib/servers.py
  3. +0 −1 pyftpdlib/test/runner.py
  4. +42 −0 scripts/purge_installation.py
@@ -55,7 +55,8 @@ install: ## Install this package.
$(PYTHON) setup.py develop $(INSTALL_OPTS)
uninstall: ## Uninstall this package.
cd ..; $(PYTHON) -m pip uninstall -y -v pyftpdlib
cd ..; $(PYTHON) -m pip uninstall -y -v pyftpdlib || true
$(PYTHON) scripts/purge_installation.py
install-pip: ## (only if necessary)
$(PYTHON) -c \
@@ -294,7 +294,7 @@ class _SpawnerBase(FTPServer):
# or processes.
join_timeout = 5
# How often thread/process finished tasks should be cleaned up.
join_interval = 10
join_interval = 5
_lock = None
_exit = None
@@ -326,6 +326,7 @@ def _join_terminated_tasks(self):
new = []
for t in self._active_tasks:
if not t.is_alive():
self.logger.debug("join()ing task %r" % t)
t.join(self.join_timeout)
else:
new.append(t)
@@ -12,7 +12,6 @@
from pyftpdlib.test import unittest
from pyftpdlib.test import VERBOSITY
HERE = os.path.abspath(os.path.dirname(__file__))
@@ -0,0 +1,42 @@
#!/usr/bin/env python
# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
Purge pyftpdlib installation by removing pyftpdlib-related files and
directories found in site-packages directories. This is needed mainly
because sometimes "import pyftpdlib" imports a leftover installation
from site-packages directory instead of the main working directory.
"""
import os
import shutil
import site
PKGNAME = "pyftpdlib"
def rmpath(path):
if os.path.isdir(path):
print("rmdir " + path)
shutil.rmtree(path)
else:
print("rm " + path)
os.remove(path)
def main():
locations = [site.getusersitepackages()]
locations.extend(site.getsitepackages())
for root in locations:
if os.path.isdir(root):
for name in os.listdir(root):
if PKGNAME in name:
abspath = os.path.join(root, name)
rmpath(abspath)
main()

0 comments on commit 3dd5628

Please sign in to comment.