<commit_before>import sys
import os
import shutil
import subprocess
import base64
import simplejson

from biokbase.Transform import script_utils

def report_exception(logger=None, report_details=None, cleanup_details=None):
    logger.error(report_details["message"])
    logger.exception(report_details["exc"])

    if report_details["ujs_job_id"] is not None:
        report_details["ujs"].complete_job(report_details["ujs_job_id"], 
                                           report_details["token"], 
                                           report_details["message"], 
                                           None, 
                                           None) 
    
    if not cleanup_details["keep_working_directory"]:
        cleanup(cleanup_details["working_directory"])
        

def cleanup(logger=None, directory=None):
    try:
        shutil.rmtree(directory)
    except IOError, e:
        report_exception("{0}".format(directory), e, ujs)


def gen_recursive_filelist(d):
    for root, directories, files in os.walk(d):
        for file in files:
            yield os.path.join(root, file)


def run_task(logger, arguments, debug=False):
    if logger is None:
        logger = script_utils.stderrlogger(__file__)

    h = TaskRunner(logger)
    h.run(arguments, debug)


class TaskRunner(object):
    def __init__(self, logger=None):
        #logger_stdout = script_utils.getStdoutLogger()
        if logger is None:
            self.logger = script_utils.stderrlogger(__file__)
        else:
            self.logger = logger


    def _build_command_list(self, arguments=None, debug=False):
        if debug:
            command_name = os.path.splitext(arguments["script_name"])[0]
        else:
            command_name = arguments["script_name"]
        
        command_list = [command_name]
        del arguments["script_name"]
        #del arguments["optional_arguments"]

        for k in arguments:
            command_list.append("--{0}".format(k))
            command_list.append("{0}".format(arguments[k]))
        print command_list

        return command_list
<commit_msg>switch else logic for debug mode on building command list<commit_after>import sys
import os
import shutil
import subprocess
import base64
import simplejson

from biokbase.Transform import script_utils

def report_exception(logger=None, report_details=None, cleanup_details=None):
    logger.error(report_details["message"])
    logger.exception(report_details["exc"])

    if report_details["ujs_job_id"] is not None:
        report_details["ujs"].complete_job(report_details["ujs_job_id"], 
                                           report_details["token"], 
                                           report_details["message"], 
                                           None, 
                                           None) 
    
    if not cleanup_details["keep_working_directory"]:
        cleanup(cleanup_details["working_directory"])
        

def cleanup(logger=None, directory=None):
    try:
        shutil.rmtree(directory)
    except IOError, e:
        report_exception("{0}".format(directory), e, ujs)


def gen_recursive_filelist(d):
    for root, directories, files in os.walk(d):
        for file in files:
            yield os.path.join(root, file)


def run_task(logger, arguments, debug=False):
    if logger is None:
        logger = script_utils.stderrlogger(__file__)

    h = TaskRunner(logger)
    h.run(arguments, debug)


class TaskRunner(object):
    def __init__(self, logger=None):
        #logger_stdout = script_utils.getStdoutLogger()
        if logger is None:
            self.logger = script_utils.stderrlogger(__file__)
        else:
            self.logger = logger


    def _build_command_list(self, arguments=None, debug=False):
        if debug:
            command_name = arguments["script_name"]
        else:
            command_name = os.path.splitext(arguments["script_name"])[0]
        
        command_list = [command_name]
        del arguments["script_name"]
        #del arguments["optional_arguments"]

        for k in arguments:
            command_list.append("--{0}".format(k))
            command_list.append("{0}".format(arguments[k]))
        print command_list

        return command_list

{'fraction_non_alphanumeric': 0.09606373008434864, 'fraction_numerical': 0.0028116213683223993, 'mean_word_length': 2.345611285266458, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '397499', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1123, 'n_words': 247}