]> git.nothing2do.fr Git - get-hack-src.git/commitdiff
Finally fixed the path issue for linux distros
authorallfro <ndouba@gmail.com>
Fri, 26 Oct 2012 02:10:25 +0000 (22:10 -0400)
committerallfro <ndouba@gmail.com>
Fri, 26 Oct 2012 02:10:25 +0000 (22:10 -0400)
src/canari/commands/common.py
src/canari/commands/install_package.py
src/canari/commands/run_transform.py
src/canari/commands/shell.py
src/canari/maltego/message.py

index 13568e8da14bf24f676785b1bcd5ea7206fb898f..2fcb2ad16a39cce4b90f48a26e5696366f5158a1 100644 (file)
@@ -4,6 +4,8 @@ from canari.config import CanariConfigParser
 
 from os import path, listdir, sep, environ, mkdir, pathsep, getcwd
 from pkg_resources import resource_filename
+from distutils.dist import Distribution
+from distutils.command.install import install
 from sys import path as pypath, platform
 from datetime import datetime
 from string import Template
@@ -20,6 +22,12 @@ __email__ = 'ndouba@gmail.com'
 __status__ = 'Development'
 
 
+def get_bin_dir():
+    d = install(Distribution())
+    d.finalize_options()
+    return d.install_scripts
+
+
 def get_commands(module='canari.commands'):
     sc = __import__(module, globals(), locals(), fromlist=['__all__'])
     commands = {}
index c02a35da4b189a3f0cef4dd58feafdd5bfe34c51..749d74eeda53ae8d6d2690c690197fc41f5baed9 100644 (file)
@@ -4,11 +4,10 @@ from ..maltego.configuration import  (MaltegoTransform, CmdCwdTransformProperty,
                                CmdLineTransformProperty, CmdParmTransformProperty, InputConstraint, TransformSet,
                                TransformSettings, CmdCwdTransformPropertySetting, CmdDbgTransformPropertySetting,
                                CmdLineTransformPropertySetting, CmdParmTransformPropertySetting)
-from common import detect_settings_dir, cmd_name, fix_pypath
+from common import detect_settings_dir, cmd_name, fix_pypath, get_bin_dir
 from ..maltego.message import  ElementTree
 
 from os import sep, path, mkdir, chdir, getcwd, name
-from distutils.sysconfig import get_config_var
 from pkg_resources import resource_filename
 from argparse import ArgumentParser
 from string import Template
@@ -125,7 +124,7 @@ def install_transform(module, name, author, spec, prefix, working_dir):
         ElementTree(transform).write(sep.join([installdir, '%s.transform' % n]))
 
         transformsettings = TransformSettings(properties=[
-            CmdLineTransformPropertySetting(path.join(get_config_var('BINDIR'), 'dispatcher')),
+            CmdLineTransformPropertySetting(path.join(get_bin_dir(), 'dispatcher')),
             CmdParmTransformPropertySetting(name),
             CmdCwdTransformPropertySetting(working_dir),
             CmdDbgTransformPropertySetting(spec.debug)
index 06c768c153859acd52252cd49f5f9c41736e44c2..4ee420e628e14100bb9229e318d98a93105dfa69 100644 (file)
@@ -1,10 +1,9 @@
 #!/usr/bin/env python
 
 from ..maltego.message import MaltegoException, MaltegoTransformResponseMessage
+from common import cmd_name, import_transform, fix_binpath, get_bin_dir
 from ..maltego.utils import onterminate, parseargs, croak, message
-from common import cmd_name, import_transform, fix_binpath
 
-from distutils.sysconfig import get_config_var
 from os import execvp, geteuid, name, path
 from argparse import ArgumentParser
 from traceback import format_exc
@@ -66,7 +65,7 @@ def run(args):
     [transform, params, value, fields] = parseargs(['canari %s' % cmd_name(__name__)] + args)
 
     m = None
-    pysudo = path.join(get_config_var('BINDIR'), 'pysudo')
+    pysudo = path.join(get_bin_dir(), 'pysudo')
 
     fix_binpath(config['default/path'])
     try:
index 355f259819fc0e28e346ae5d9675462a65242a30..cc10045af619ccd9cb62fab87df969a233374359 100644 (file)
@@ -4,7 +4,6 @@ from common import console_message, cmd_name, highlight, fix_pypath, fix_binpath
 from ..maltego.message import MaltegoTransformResponseMessage
 from ..config import config
 
-from distutils.sysconfig import get_config_var
 from os import path, name, geteuid, execvp
 from code import InteractiveConsole
 from argparse import ArgumentParser
index 4d52185c577a3dba9ebcd354b4e27b9b9eb55c91..20c8af70c266ed87358905f6fd0259f2b7ee7ef3 100644 (file)
@@ -284,14 +284,19 @@ class Entity(MaltegoElement):
 
     def __init__(self, value, **kwargs):
         super(Entity, self).__init__("Entity")
-        type = kwargs.get('type', None)
+        type = kwargs.pop('type', None)
         if type is None:
             self.type = '%s.%s' % (self.namespace, self.__class__.__name__ if self.name is None else self.name)
+        else:
+            self.type = type
         self.value = value
-        self.weight = kwargs.get('weight', self.weight)
-        self.iconurl = kwargs.get('iconurl', self.iconurl)
-        self.appendelements(kwargs.get('fields'))
-        self.appendelements(kwargs.get('labels'))
+        self.weight = kwargs.pop('weight', self.weight)
+        self.iconurl = kwargs.pop('iconurl', self.iconurl)
+        self.appendelements(kwargs.pop('fields', None))
+        self.appendelements(kwargs.pop('labels', None))
+        for p in kwargs:
+            if hasattr(self, p):
+                setattr(self, p, kwargs[p])
 
     def appendelement(self, other):
         if isinstance(other, Field):