Exemple #1
0
    def get(self, app_name):
        app_name = app_name.replace('-', ' ')
        application = Application.query.filter_by(script_name=app_name).first()

        if not application:
            output = 'Application not found.'

        else:
            output = run_script_func(application.hex_id)

        return {'Output': output}
Exemple #2
0
def run_script(script_hex_id):
    application = Application.query.filter_by(hex_id=script_hex_id).first()

    out = run_script_func(script_hex_id)

    if out != 'error':
        flash(application.script_name + ' ran succussfully! Output: ' + out,
              'success')

    elif out == 'Process Started!':
        flash(out, 'success')

    else:
        flash('Something is not right. Try again', 'warning')

    return redirect(url_for('main.home'))
Exemple #3
0
    def get(self, app_name, options):
        config = ConfigParser()

        app_name = app_name.replace('-', ' ')
        application = Application.query.filter_by(script_name=app_name).first()

        if not application:
            output = 'Application not found.'

        else:
            config_path = os.path.join(lib_folder, application.hex_id + '.ini')
            config.read(config_path)
            num_options = options.count('%')
            options_index = 0
            options_list = []
            for i in range(num_options):
                end = options.find('%', options_index) + 1
                full_option = options[options_index:end]
                equal_sign = full_option.find('=') + 1
                option_name = full_option[0:equal_sign - 1]
                option_value = full_option[equal_sign:]
                option_value = option_value.replace('%', '')
                options_list.append({option_name: option_value})
                options_index = end

            for option in options_list:
                keys = option.keys()
                values = option.values()
                for key in keys:
                    option_name = key
                for value in values:
                    option_value = value
                    option_value = option_value.replace('-', ' ')
                config[application.script_name][option_name] = option_value
                with open(config_path, 'w') as configfile:
                    config.write(configfile)

            output = run_script_func(application.hex_id)

        return {'Output': output}