コード例 #1
0
def launch_module(cmd, args, redirect=False):
    """Launch a global (non-local module)"""

    module_path = "%s/%s" % (DTF_MODULES_DIR, cmd)

    # If the caller explicitly asked to save stdout, lets do it.
    if redirect:
        captured_f = compat.StringIO()

        with stdout_redirector(captured_f):

            if pm.is_bash_module(module_path):
                rtn = __launch_bash_module(module_path, args)
            else:
                rtn = __launch_python_module(module_path, cmd, args)

        out = captured_f.getvalue()
        captured_f.close()

        return out, rtn

    else:
        # If we are dealing with a bash script, just run and exit.
        if pm.is_bash_module(module_path):
            return __launch_bash_module(module_path, args)
        return __launch_python_module(module_path, cmd, args)
コード例 #2
0
ファイル: packages.py プロジェクト: Andy10101/dtf
def launch_module(cmd, args, redirect=False):

    """Launch a global (non-local module)"""

    module_path = "%s/%s" % (DTF_MODULES_DIR, cmd)

    # If the caller explicitly asked to save stdout, lets do it.
    if redirect:
        captured_f = cStringIO.StringIO()

        with stdout_redirector(captured_f):

            if pm.is_bash_module(module_path):
                rtn = __launch_bash_module(module_path, args)
            else:
                rtn = __launch_python_module(module_path, cmd, args)

        out = captured_f.getvalue()
        captured_f.close()

        return out, rtn

    else:
        # If we are dealing with a bash script, just run and exit.
        if pm.is_bash_module(module_path):
            return __launch_bash_module(module_path, args)
        return __launch_python_module(module_path, cmd, args)
コード例 #3
0
def do_checks(file_name, all_checks, strict_checks):
    """Perform checks"""

    # Update path to include libs
    update_path()

    if not os.path.isfile(file_name):
        log.e(TAG, "[FAIL] %s is not a file." % file_name)
        return -1

    base_name = os.path.basename(file_name)
    module_name = os.path.splitext(base_name)[0]

    log.d(TAG, "Full File: %s" % file_name)
    log.d(TAG, "Base name: %s" % base_name)
    log.d(TAG, "Module name: %s" % module_name)

    # First, is this python, or bash?
    if pm.is_python_module(file_name, module_name):
        log.i(TAG, "[PASS] Is python, doing python checks...")
        return do_python_checks(file_name, module_name, all_checks,
                                strict_checks)
    elif pm.is_bash_module(file_name):
        log.i(TAG, "[PASS] Is bash, doing bash checks...")
        return do_bash_checks(file_name, module_name, all_checks,
                              strict_checks)
    else:
        log.e(TAG, "[FAIL] This is not recognized as either python or bash!")
        return -2
コード例 #4
0
def launch_local_module(root, cmd, args):
    """Launch a local module"""

    module_path = "%s/%s/%s" % (root, utils.LOCAL_MODULES_DIRECTORY, cmd)

    # If we are dealing with a bash script, just run and exit.
    if pm.is_bash_module(module_path):
        log.d(TAG, "This is a bash module!")

        return __launch_bash_module(module_path, args)

    return __launch_python_module(module_path, cmd, args)
コード例 #5
0
ファイル: packages.py プロジェクト: Andy10101/dtf
def launch_local_module(root, cmd, args):

    """Launch a local module"""

    module_path = "%s/local_modules/%s" % (root, cmd)

    # If we are dealing with a bash script, just run and exit.
    if pm.is_bash_module(module_path):
        log.d(TAG, "This is a bash module!")

        return __launch_bash_module(module_path, args)

    return __launch_python_module(module_path, cmd, args)
コード例 #6
0
ファイル: pm.py プロジェクト: Andy10101/dtf
    def auto_parse_module(self, args):

        """Automatically parse module and return Item"""

        item = None
        name = args.single_name
        install_name = args.single_install_name
        local_name = args.single_local_name

        if install_name is None:
            log.d(TAG, "install_name is null, using name...")
            install_name = name
        if local_name is None:
            log.d(TAG, "local_name is null, using name...")
            local_name = name

        # Does the resource even exist?
        if not os.path.isfile(local_name):
            log.e(TAG, "Local module resource '%s' does not exist!"
                    % (local_name))
            return None

        if packagemanager.is_python_module(local_name, install_name):
            log.d(TAG, "Python mode selected")

            item = packagemanager.parse_python_module(local_name,
                                                      install_name)
            if item is None:
                log.e(TAG, "Error parsing Python module!")
                return None

        elif packagemanager.is_bash_module(local_name):
            log.d(TAG, "Bash mode selected")

            item = packagemanager.parse_bash_module(local_name,
                                                    install_name)
            if item is None:
                log.e(TAG, "Error parsing Bash module!")
                return None

        else:
            log.e(TAG, "Auto parse for Python and Bash failed!")
            return None

        return item
コード例 #7
0
ファイル: pm.py プロジェクト: 5l1v3r1/dtf
    def auto_parse_module(cls, args):
        """Automatically parse module and return Item"""

        item = None
        name = args.single_name
        install_name = args.single_install_name
        local_name = args.single_local_name

        if install_name is None:
            log.d(TAG, "install_name is null, using name...")
            install_name = os.path.basename(name)
        if local_name is None:
            log.d(TAG, "local_name is null, using name...")
            local_name = name

        # Does the resource even exist?
        if not os.path.isfile(local_name):
            log.e(TAG,
                  "Local module resource '%s' does not exist!" % (local_name))
            return None

        if packagemanager.is_python_module(local_name, install_name):
            log.d(TAG, "Python mode selected")

            item = packagemanager.parse_python_module(local_name, install_name)
            if item is None:
                log.e(TAG, "Error parsing Python module!")
                return None

        elif packagemanager.is_bash_module(local_name):
            log.d(TAG, "Bash mode selected")

            item = packagemanager.parse_bash_module(local_name, install_name)
            if item is None:
                log.e(TAG, "Error parsing Bash module!")
                return None

        else:
            log.e(TAG, "Auto parse for Python and Bash failed!")
            return None

        return item