Skip to content

Commit

Permalink
Fixed bug in pip debian
Browse files Browse the repository at this point in the history
 Test #1809
  • Loading branch information
f-amato committed Feb 25, 2016
1 parent 87ad838 commit aca5f4e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ New features in the latest update

TBA:
---
* Fixed bug in pip debian
* Fixed small bug in CSV importing
* Added support for Kali Rolling Edition

Expand Down
50 changes: 26 additions & 24 deletions faraday.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import argparse
import platform
import subprocess
import pip
import json

from utils.logs import getLogger, setUpLogger
Expand Down Expand Up @@ -202,29 +201,32 @@ def checkDependencies():
"""

if not args.ignore_deps:

modules = []
f = open(CONST_REQUIREMENTS_FILE)
for line in f:
if not line.find('#'):
break
else:
modules.append([line[:line.index('=')], (line[line.index('=')+2:]).strip()])
f.close()
pip_dist = [dist.project_name.lower() for dist in pip.get_installed_distributions()]

for module in modules:
if module[0].lower() not in pip_dist:
try:
__import__(module[0])
except ImportError:
if query_user_bool("Missing module %s."
" Do you wish to install it?" % module[0]):
pip.main(['install', "%s==%s" %
(module[0], module[1]), '--user'])

else:
return False
try:
import pip
modules = []
f = open(CONST_REQUIREMENTS_FILE)
for line in f:
if not line.find('#'):
break
else:
modules.append([line[:line.index('=')], (line[line.index('=')+2:]).strip()])
f.close()
pip_dist = [dist.project_name.lower() for dist in pip.get_installed_distributions()]

for module in modules:
if module[0].lower() not in pip_dist:
try:
__import__(module[0])
except ImportError:
if query_user_bool("Missing module %s."
" Do you wish to install it?" % module[0]):
pip.main(['install', "%s==%s" %
(module[0], module[1]), '--user'])

else:
return False
except ImportError:
pass

return True

Expand Down
11 changes: 8 additions & 3 deletions updates/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
'''
import subprocess
import pip
import couchdbkit
import model.workspace
import persistence.mappers.data_mappers as dm
Expand All @@ -34,8 +33,14 @@ def doUpdates(self):
logger.info('Checking qt3 libs')
QT().run()

logger.info('Installing missing dependencies in pip')
pip.main(['install', '-r', CONST_REQUIREMENTS_FILE, '--user'])
try:
import pip
logger.info('Installing missing dependencies in pip')
pip.main(['install', '-r', CONST_REQUIREMENTS_FILE, '--user'])
except ImportError:
logger.error("Checking missing dependencies in pip")
pass


# logger.info('Upgrading DBs to latest version')
# DB().run()
Expand Down
12 changes: 8 additions & 4 deletions utils/error_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def exception_handler(type, value, tb):
import requests
import hashlib
import platform
import pip

text = StringIO()
traceback.print_exception(type, value, tb, file=text)
Expand All @@ -59,8 +58,14 @@ def exception_handler(type, value, tb):
exception_hash = hashlib.sha256(excepts).hexdigest()
os_dist = " ".join(platform.dist())
python_version = platform.python_version()
modules_info = ",".join([ "%s=%s" % (x.key, x.version)
for x in pip.get_installed_distributions()])
modules_info = ""
try:
import pip
modules_info = ",".join([ "%s=%s" % (x.key, x.version)
for x in pip.get_installed_distributions()])
except ImportError:
pass


python_dist = "Python %s \n Modules: [ %s ]" % (python_version, modules_info)

Expand Down Expand Up @@ -90,7 +95,6 @@ def reportToDevelopers(self, *description):
import requests
import hashlib
import platform
import pip

uri = CONF.getTktPostUri()
headers = json.loads(CONF.getApiParams())
Expand Down

0 comments on commit aca5f4e

Please sign in to comment.