Description: Cleanup setup.py
The setup.py makes changes that should not be done in a setup:
- change the bin path: there is no need for Kali
- install config files is the home user directory: should be done at
first launch
- configure maltego: should be done at first launch
Author: Sophie Brun <[email protected]>
Last-Update: 2017-09-04
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/setup.py
+++ b/setup.py
@@ -31,67 +31,67 @@ import site
IS_VIRTUAL_ENV = False
# Get packagesPaths depending on whether the user launched it with sudo or not
-if sys.platform == 'win32':
+#if sys.platform == 'win32':
# This will throw two folders, but we need the first one only. Typically:
# ['c:\\Users\\<a_user>\\AppData\\Roaming\\Python\\Python27\\site-packages']
- packagesPaths = site.getusersitepackages()[0]
- print "[*] The installation is going to be run as superuser."
-else:
+# packagesPaths = site.getusersitepackages()[0]
+# print "[*] The installation is going to be run as superuser."
+#else:
# We need this verification because Windows does not have a wrapper ofr os.geteuid()
- if not os.geteuid() == 0:
- try:
- packagesPaths = site.getusersitepackages()
+# if not os.geteuid() == 0:
+# try:
+# packagesPaths = site.getusersitepackages()
# TODO: Check whether the packagesPaths is in the PATH, if not, add it
- print "[*] The installation has not been launched as superuser."
- user_bin_path = site.USER_BASE + "/bin"
- print "[*] We will verify is the '" + user_bin_path + "' folder is in the path so as to make the utils available anywhere in the system."
- bin_path = os.popen("echo $PATH").read()
- if user_bin_path in bin_path:
- print "[*] Great. '" + user_bin_path + "' is in the path. No further actions needed."
- else:
- print "[*] We are manually adding the '" + user_bin_path + "' folder to the ~/.bashrc file."
+# print "[*] The installation has not been launched as superuser."
+# user_bin_path = site.USER_BASE + "/bin"
+# print "[*] We will verify is the '" + user_bin_path + "' folder is in the path so as to make the utils available anywhere in the system."
+# bin_path = os.popen("echo $PATH").read()
+# if user_bin_path in bin_path:
+# print "[*] Great. '" + user_bin_path + "' is in the path. No further actions needed."
+# else:
+# print "[*] We are manually adding the '" + user_bin_path + "' folder to the ~/.bashrc file."
# Building the commands to be added to .bashrc
- new_lines = """
+# new_lines = """
# Added by OSRFramework
# ---------------------
# Check this issue in Github for additional information about why these lines where added: <https://github.com/i3visio/osrframework/issues/187>
- export PY_USER_BIN= """ + user_bin_path + """
- export PATH=$PATH:$PY_USER_BIN
- """
-
- command = "echo '''" + new_lines + "''' >> ~/.bashrc"
- print "[*] As we want to be transparent, the command that is being run is the following:\n" + command
- a = os.popen(command).read()
- except:
- IS_VIRTUAL_ENV = True
- else:
+# export PY_USER_BIN= """ + user_bin_path + """
+# export PATH=$PATH:$PY_USER_BIN
+# """
+
+# command = "echo '''" + new_lines + "''' >> ~/.bashrc"
+# print "[*] As we want to be transparent, the command that is being run is the following:\n" + command
+# a = os.popen(command).read()
+# except:
+# IS_VIRTUAL_ENV = True
+# else:
# This will throw two folders, but we need the first one only:
# ['/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
- packagesPaths = site.getsitepackages()[0]
- print "[*] The installation is going to be run as superuser."
+# packagesPaths = site.getsitepackages()[0]
+# print "[*] The installation is going to be run as superuser."
-if not IS_VIRTUAL_ENV:
- osrframeworkSystemPath = os.path.join(packagesPaths, "osrframework")
+#if not IS_VIRTUAL_ENV:
+# osrframeworkSystemPath = os.path.join(packagesPaths, "osrframework")
- print "[*] The chosen installation path is: " + osrframeworkSystemPath
+# print "[*] The chosen installation path is: " + osrframeworkSystemPath
# Removing old installations first...
- if os.path.isdir(osrframeworkSystemPath):
- print "[!] Found an old installation at: " + osrframeworkSystemPath
- try:
- shutil.rmtree(osrframeworkSystemPath)
- print "[*] Successfully removed the old installation. Installation will resume now to upgrade it..."
- except Exception as e:
- print str(e)
- print "[E] The installed version of OSRFramework cannot be removed. Try to remove it manually in your python installation under 'local/lib/python2.7/dist-packages/'."
- print sys.exit()
- else:
- print "[*] No OSRFramework installation found in the system."
-else:
- print "[*] OSRFramework seems to be installed using `virtualenv`."
+# if os.path.isdir(osrframeworkSystemPath):
+# print "[!] Found an old installation at: " + osrframeworkSystemPath
+# try:
+# shutil.rmtree(osrframeworkSystemPath)
+# print "[*] Successfully removed the old installation. Installation will resume now to upgrade it..."
+# except Exception as e:
+# print str(e)
+# print "[E] The installed version of OSRFramework cannot be removed. Try to remove it manually in your python installation under 'local/lib/python2.7/dist-packages/'."
+# print sys.exit()
+# else:
+# print "[*] No OSRFramework installation found in the system."
+#else:
+# print "[*] OSRFramework seems to be installed using `virtualenv`."
-HERE = os.path.abspath(os.path.dirname(__file__))
+#HERE = os.path.abspath(os.path.dirname(__file__))
# Importing the temporal scripts for the setup and taking the new version number
import osrframework
@@ -100,15 +100,15 @@ NEW_VERSION = osrframework.__version__
import osrframework.utils.configuration as configuration
# Depending on the place in which the project is going to be upgraded
-try:
- raise Exception('Trying to load the markdown manually!')
- from pypandoc import convert
- read_md = lambda f: convert(f, 'rst')
-except ImportError:
- print("[!] pypandoc module not found, could not convert Markdown to RST")
- read_md = lambda f: open(f, 'r').read()
-except Exception:
- read_md = lambda f: open(f, 'r').read()
+#try:
+# raise Exception('Trying to load the markdown manually!')
+# from pypandoc import convert
+# read_md = lambda f: convert(f, 'rst')
+#except ImportError:
+# print("[!] pypandoc module not found, could not convert Markdown to RST")
+# read_md = lambda f: open(f, 'r').read()
+#except Exception:
+# read_md = lambda f: open(f, 'r').read()
# Reading the .md file
try:
@@ -206,49 +206,49 @@ setup(
############################
### Creating other files ###
############################
-print "[*] Changing permissions of the user folders..."
-try:
- configuration.changePermissionsRecursively(paths["appPath"], int(os.getenv('SUDO_UID')), int(os.getenv('SUDO_GID')))
-except:
+#print "[*] Changing permissions of the user folders..."
+#try:
+# configuration.changePermissionsRecursively(paths["appPath"], int(os.getenv('SUDO_UID')), int(os.getenv('SUDO_GID')))
+#except:
# Something happened with the permissions... We omit this.
- pass
+# pass
-print "[*] Copying relevant files..."
-files_to_copy= {
- paths["appPath"] : [
- os.path.join("config", "browser.cfg"),
- os.path.join("config", "general.cfg"),
- ],
- paths["appPathDefaults"] : [
- os.path.join("config", "accounts.cfg"),
- os.path.join("config", "api_keys.cfg"),
- os.path.join("config", "browser.cfg"),
- os.path.join("config", "general.cfg"),
- ],
- paths["appPathWrappers"] : [
- os.path.join("config", "plugins", "wrapper.py.sample"),
- ],
- paths["appPathPatterns"] : [
- os.path.join("config", "plugins", "pattern.py.sample"),
- ]
-}
+#print "[*] Copying relevant files..."
+#files_to_copy= {
+# paths["appPath"] : [
+# os.path.join("config", "browser.cfg"),
+# os.path.join("config", "general.cfg"),
+# ],
+# paths["appPathDefaults"] : [
+# os.path.join("config", "accounts.cfg"),
+# os.path.join("config", "api_keys.cfg"),
+# os.path.join("config", "browser.cfg"),
+# os.path.join("config", "general.cfg"),
+# ],
+# paths["appPathWrappers"] : [
+# os.path.join("config", "plugins", "wrapper.py.sample"),
+# ],
+# paths["appPathPatterns"] : [
+# os.path.join("config", "plugins", "pattern.py.sample"),
+# ]
+#}
# Iterating through all destinations to write the info
-for destiny in files_to_copy.keys():
+#for destiny in files_to_copy.keys():
# Grabbing each source file to be moved
- for sourceFile in files_to_copy[destiny]:
- fileToMove = os.path.join(HERE,sourceFile)
+# for sourceFile in files_to_copy[destiny]:
+# fileToMove = os.path.join(HERE,sourceFile)
# Choosing the command depending on the SO
- if sys.platform == 'win32':
- if os.path.isdir(fileToMove):
- cmd = "echo d | xcopy \"" + fileToMove + "\" \"" + destiny + "\" /s /e"
- else:
- cmd = "copy \"" + fileToMove + "\" \"" + destiny + "\""
- elif sys.platform == 'linux2' or sys.platform == 'darwin':
- if not os.geteuid() == 0:
- cmd = "cp -r -- \"" + fileToMove + "\" \"" + destiny + "\""
- else:
- cmd = "sudo cp -r -- \"" + fileToMove + "\" \"" + destiny + "\""
+# if sys.platform == 'win32':
+# if os.path.isdir(fileToMove):
+# cmd = "echo d | xcopy \"" + fileToMove + "\" \"" + destiny + "\" /s /e"
+# else:
+# cmd = "copy \"" + fileToMove + "\" \"" + destiny + "\""
+# elif sys.platform == 'linux2' or sys.platform == 'darwin':
+# if not os.geteuid() == 0:
+# cmd = "cp -r -- \"" + fileToMove + "\" \"" + destiny + "\""
+# else:
+# cmd = "sudo cp -r -- \"" + fileToMove + "\" \"" + destiny + "\""
#print cmd
- output = os.popen(cmd).read()
+# output = os.popen(cmd).read()