<commit_before>#!/usr/bin/env python
# 
# This script is used to compile ANTs binaries
# Inputs: ANTs folder, must be a sct fork of original ANTs folder.
# Outputs: binaries that are directly put into sct
# ants_scripts = ['ANTSLandmarksBSplineTransform',
# 				'antsApplyTransforms',
# 				'antsRegistration',
# 				'antsSliceRegularizedRegistration',
# 				'ANTSUseLandmarkImagesToGetAffineTransform',
# 				'ComposeMultiTransform']

import sys

import os
import getopt

# status, path_sct = getstatusoutput('echo $SCT_DIR')
sys.path.append('../scripts')
import sct_utils as sct

url_to_ants_repository = 'https://github.com/benjamindeleener/ANTs/archive/master.zip'
ants_downloaded_folder = 'ANTs-master'
ants_downloaded_file = ants_downloaded_folder + '.zip'
listOS = ['osx', 'linux']


class InstallationResult(object):
    SUCCESS = 0
    WARN = 1
    ERROR = 2

    def __init__(self, result, status, message):
        self.result = result
        self.status = status
        self.message = message


def open_url(url, start=0, timeout=20):
    """
    Open URL
    :param url:
    :param start:
    :param timeout:
    :return:
    """
    import urllib2
    import socket
    socket.setdefaulttimeout(timeout)
    MsgUser.debug("Attempting to download %s." % url)

    try:
        req = urllib2.Request(url)
        if start != 0:
            req.headers['Range'] = 'bytes=%s-' % start
        rf = urllib2.urlopen(req)
    except urllib2.HTTPError, err:
        MsgUser.debug("%s %s" % (url, err.msg))
        return InstallationResult(False, InstallationResult.ERROR,
                                  "Cannot find file %s on server (%s). Try again later." % (url, err.msg))<commit_msg>INST: compile_ants: minor modif<commit_after>#!/usr/bin/env python
# 
# This script is used to compile ANTs binaries
# Inputs: ANTs folder, must be a sct fork of original ANTs folder.
# Outputs: binaries that are directly put into sct
# ants_scripts = ['ANTSLandmarksBSplineTransform',
# 				'antsApplyTransforms',
# 				'antsRegistration',
# 				'antsSliceRegularizedRegistration',
# 				'ANTSUseLandmarkImagesToGetAffineTransform',
# 				'ComposeMultiTransform']

import sys

import os
import getopt

# status, path_sct = getstatusoutput('echo $SCT_DIR')
sys.path.append('../scripts')
import sct_utils as sct

url_to_ants_repository = 'https://github.com/benjamindeleener/ANTs/archive/master.zip'
ants_downloaded_folder = 'ANTs-master'
ants_downloaded_file = ants_downloaded_folder + '.zip'
listOS = ['osx', 'linux']


class InstallationResult(object):
    SUCCESS = 0
    WARN = 1
    ERROR = 2

    def __init__(self, result, status, message):
        self.result = result
        self.status = status
        self.message = message


class MsgUser(object):
    __debug = False
    __quiet = False

    @classmethod
    def debugOn(cls):
        cls.__debug = True
    @classmethod
    def debugOff(cls):
        cls.__debug = False
    @classmethod
    def quietOn(cls):
        cls.__quiet = True
    @classmethod
    def quietOff(cls):
        cls.__quiet = False

    @classmethod
    def isquiet(cls):
        return cls.__quiet

    @classmethod
    def isdebug(cls):
        return cls.__debug

    @classmethod
    def debug(cls, message, newline=True):
        if cls.__debug:
            from sys import stderr
            mess = str(message)
            if newline:
                mess += "\n"
            stderr.write(mess)

    @classmethod
    def message(cls, msg):
        if cls.__quiet:
            return
        print msg

    @classmethod
    def question(cls, msg):
        print msg,

    @classmethod
    def skipped(cls, msg):
        if cls.__quiet:
            return
        print "".join( (bcolors.magenta, "[Skipped] ", bcolors.normal, msg ) )

    @classmethod
    def ok(cls, msg):
        if cls.__quiet:
            return
        print "".join( (bcolors.green, "[OK] ", bcolors.normal, msg ) )

    @classmethod
    def failed(cls, msg):
        print "".join( (bcolors.red, "[FAILED] ", bcolors.normal, msg ) )

    @classmethod
    def warning(cls, msg):
        if cls.__quiet:
            return
        print "".join( (bcolors.yellow, bcolors.bold, "[Warning]", bcolors.normal, " ", msg ) )


def open_url(url, start=0, timeout=20):
    """
    Open URL
    :param url:
    :param start:
    :param timeout:
    :return:
    """
    import urllib2
    import socket
    socket.setdefaulttimeout(timeout)
    MsgUser.debug("Attempting to download %s." % url)

    try:
        req = urllib2.Request(url)
        if start != 0:
            req.headers['Range'] = 'bytes=%s-' % start
        rf = urllib2.urlopen(req)
    except urllib2.HTTPError, err:
        MsgUser.debug("%s %s" % (url, err.msg))
        return InstallationResult(False, InstallationResult.ERROR,
                                  "Cannot find file %s on server (%s). Try again later." % (url, err.msg))
{'fraction_non_alphanumeric': 0.11393692777212615, 'fraction_numerical': 0.004476093591047813, 'mean_word_length': 2.5830903790087465, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1842079', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1548, 'n_words': 397}