<commit_before>## Copyright (c) 2012-2014 Aldebaran Robotics. All rights reserved.
## Use of this source code is governed by a BSD-style license that can be
## found in the COPYING file.

""" Set of tools to perform remote operations,
downloading package or reading configs from URLs

"""

import os
import re
import sys
import ftplib
import urlparse
import urllib2
import StringIO

from qisys import ui
import qisys.command
import qisys.sh

import qibuild.config

def callback(total, done):
    """ Called during download """
    if not sys.stdout.isatty():
        return
    percent = done * 100 / total
    sys.stdout.write("Done: %i%%\r" % percent)
    sys.stdout.flush()

def get_server_access(server_name):
    """ Get server access for a remote site.

    :param server: A :ref:`qibuild-xml-node-server` in
                   the global qibuild xml configuration file

    :return: A ``qibuild.config.Access`` instance

    """
    qibuild_cfg = qibuild.config.QiBuildConfig()
    qibuild_cfg.read()
    access = qibuild_cfg.get_server_access(server_name)
    return access


def get_ftp_access(server_name):
    """ Get ftp password from the config file

    :param server: A :ref:`qibuild-xml-node-server` in
                   the global qibuild xml configuration file

    :return: A ``qibuild.config.Access`` instance

    """<commit_msg>qisys.remote: fix crash when global config file does not exist<commit_after>## Copyright (c) 2012-2014 Aldebaran Robotics. All rights reserved.
## Use of this source code is governed by a BSD-style license that can be
## found in the COPYING file.

""" Set of tools to perform remote operations,
downloading package or reading configs from URLs

"""

import os
import re
import sys
import ftplib
import urlparse
import urllib2
import StringIO

from qisys import ui
import qisys.command
import qisys.sh

import qibuild.config

def callback(total, done):
    """ Called during download """
    if not sys.stdout.isatty():
        return
    percent = done * 100 / total
    sys.stdout.write("Done: %i%%\r" % percent)
    sys.stdout.flush()

def get_server_access(server_name):
    """ Get server access for a remote site.

    :param server: A :ref:`qibuild-xml-node-server` in
                   the global qibuild xml configuration file

    :return: A ``qibuild.config.Access`` instance

    """
    qibuild_cfg = qibuild.config.QiBuildConfig()
    qibuild_cfg.read(create_if_missing=True)
    access = qibuild_cfg.get_server_access(server_name)
    return access


def get_ftp_access(server_name):
    """ Get ftp password from the config file

    :param server: A :ref:`qibuild-xml-node-server` in
                   the global qibuild xml configuration file

    :return: A ``qibuild.config.Access`` instance

    """
{'fraction_non_alphanumeric': 0.09123692751532636, 'fraction_numerical': 0.00865488640461594, 'mean_word_length': 3.3411580594679187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6681623', 'n_tokens_mistral': 877, 'n_tokens_neox': 830, 'n_words': 287}