<commit_before>#!/usr/bin/env python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Based on runGen (T. Maeno)
#
# Authors:
# - <NAME>, <EMAIL>, 2018

import os
import time
import argparse
import logging
import urllib
import ast
import subprocess

print "=== start ==="
print time.ctime()

# Example of prun command to process
# prun --exec 'pwd && ls -l %IN %OUT' --outDS user.aforti.test$a \
#      --outputs out.dat --site=ANALY_MANC_SL7 --noBuild \
#      --inDS user.aforti.test5_out.dat.197875784


def main():

    """ Main function of run_container """
    sc = singularity_command()
    run_container(sc)
    rename_ouput()


def singularity_command():

    # Options for the command line string have default values or are mandatory

    # Base singularity command
    singularity_base = 'singularity exec -C'

    # If Cvmfs add that to bind_paths
    cvmfs = ''

    if args.ctr_cvmfs:
        cvmfs = '-B /cvmfs:/cvmfs'

    # Add Command it need to remove the
    command = urllib.unquote(args.ctr_cmd)

    singularity_cmd = "%s --pwd %s -B $PWD:%s %s %s %s" % \
                      (singularity_base,
                       args.ctr_workdir,
                       args.ctr_datadir,
                       cvmfs,
                       args.ctr_image,
                       command)

    print singularity_cmd
    return singularity_cmd


def run_container(cmd=''):

    # Just in case singularity is not the only container we run
    # os.system going to be deprecated (?) but subprocess requires more
    # thinking to handle $PWD. Later if this doesn't end in tears.
    os.system(cmd)
<commit_msg>Added Python 3 support for runcontainer script (at least for print functions)<commit_after>#!/usr/bin/env python
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Based on runGen (T. Maeno)
#
# Authors:
# - <NAME>, <EMAIL>, 2018

import os
import time
import argparse
import logging
import urllib
import ast
import subprocess

print("=== start ===")
print(time.ctime())

# Example of prun command to process
# prun --exec 'pwd && ls -l %IN %OUT' --outDS user.aforti.test$a \
#      --outputs out.dat --site=ANALY_MANC_SL7 --noBuild \
#      --inDS user.aforti.test5_out.dat.197875784


def main():

    """ Main function of run_container """
    sc = singularity_command()
    run_container(sc)
    rename_ouput()


def singularity_command():

    # Options for the command line string have default values or are mandatory

    # Base singularity command
    singularity_base = 'singularity exec -C'

    # If Cvmfs add that to bind_paths
    cvmfs = ''

    if args.ctr_cvmfs:
        cvmfs = '-B /cvmfs:/cvmfs'

    # Add Command it need to remove the
    command = urllib.unquote(args.ctr_cmd)

    singularity_cmd = "%s --pwd %s -B $PWD:%s %s %s %s" % \
                      (singularity_base,
                       args.ctr_workdir,
                       args.ctr_datadir,
                       cvmfs,
                       args.ctr_image,
                       command)

    print(singularity_cmd)
    return singularity_cmd


def run_container(cmd=''):

    # Just in case singularity is not the only container we run
    # os.system going to be deprecated (?) but subprocess requires more
    # thinking to handle $PWD. Later if this doesn't end in tears.
    os.system(cmd)

{'fraction_non_alphanumeric': 0.10057392730254168, 'fraction_numerical': 0.01065864990434545, 'mean_word_length': 2.4301780693533273, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '217936', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1120, 'n_words': 381}