Beispiel #1
0
    def __init__(self,
                 work_dir="clade",
                 cmds_file=None,
                 conf=None,
                 preset="base"):
        self.work_dir = os.path.abspath(str(work_dir))
        self.logger = get_logger("clade-api", with_name=False, conf=conf)

        if not cmds_file:
            self.cmds_file = os.path.join(self.work_dir, "cmds.txt")
        else:
            self.cmds_file = os.path.abspath(cmds_file)

        self.conf = conf if conf else dict()
        self.conf = merge_preset_to_conf(preset, self.conf)
        self.conf_file = os.path.join(self.work_dir, "conf.json")

        # "Name -> Object" storage of all available extensions
        self.extensions = dict()

        self.__prepare_to_init()

        self._cmd_graph = None
        self._src_graph = None
        self._src_info = None
        self._pid_graph = None
        self._pid_by_id = None
        self._callgraph = None
        self._functions = None
        self._functions_by_file = None
        self._cdb = None
Beispiel #2
0
    def __init__(self,
                 command,
                 cwd=os.getcwd(),
                 output: str = "cmds.txt",
                 append=False,
                 intercept_open=False,
                 intercept_envs=False,
                 conf=None):
        self.command = command
        self.cwd = cwd
        self.output = os.path.abspath(output)
        self.output_open = os.path.join(os.path.dirname(self.output),
                                        "open.txt")
        self.output_envs = os.path.join(os.path.dirname(self.output),
                                        "envs.txt")
        self.append = append
        self.intercept_open = intercept_open
        self.intercept_envs = intercept_envs
        self.conf = conf if conf else dict()

        self.clade_if_file = None
        self.logger = get_logger("Intercept", conf=self.conf)
        self.env = self._setup_env()

        if not self.append:
            if os.path.exists(self.output):
                os.remove(self.output)
            if os.path.exists(self.output_open):
                os.remove(self.output_open)
            if os.path.exists(self.output_envs):
                os.remove(self.output_envs)
Beispiel #3
0
    def __init__(self, work_dir="clade", cmds_file=None, conf=None, preset="base"):
        self.work_dir = os.path.abspath(str(work_dir))

        if not cmds_file:
            self.cmds_file = os.path.join(self.work_dir, "cmds.txt")
        else:
            self.cmds_file = os.path.abspath(cmds_file)

        self.conf = self.__prepare_conf(preset, conf)
        self.conf_file = os.path.join(self.work_dir, "conf.json")

        # "Name -> Object" storage of all available extensions
        self.extensions = dict()

        self.__prepare_to_init()

        # logger needs working directory, so it must be created after cleaning
        self.logger = get_logger("clade-api", with_name=False, conf=self.conf)

        self._cmd_graph = None
        self._cmd_type = None
        self._src_graph = None
        self._src_info = None
        self._pid_graph = None
        self._pid_by_id = None
        self._callgraph = None
        self._functions = None
        self._functions_by_file = None
        self._cdb = None
Beispiel #4
0
    def __get_logger(self):
        # Initializing logger this way serves two purposes:
        #   - as a workaround for multiprocessing not supporting passing logger
        #     objects in Python 3.5 and 3.6
        #   - and to setup logger in subprocesses

        if not self.logger:
            self.logger = get_logger("clade", with_name=False, conf=self.conf)
Beispiel #5
0
    def __init__(self, command, cwd=os.getcwd(), output="cmds.txt", append=False, conf=None):
        self.command = command
        self.cwd = cwd
        self.output = os.path.abspath(output)
        self.append = append
        self.conf = conf if conf else dict()
        self.logger = get_logger("Intercept", self.conf)
        self.env = self._setup_env()

        if not self.append and os.path.exists(self.output):
            os.remove(self.output)
Beispiel #6
0
 def __init__(self, conf, output):
     self.conf = conf
     self.output = output
     self.logger = get_logger("Server", conf=self.conf)
     self.server = self.__prepare()
     self.env = self.__setup_env()