<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
##################################################################################
#
#    Copyright 2017 <NAME> and <NAME> (i3visio, <EMAIL>)
#
#    This program is part of OSRFramework. You can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##################################################################################

__author__ = "<NAME> y <NAME> "
__copyright__ = "Copyright 2015-2017, i3visio"
__credits__ = ["<NAME>", "<NAME>"]
__license__ = "AGPLv3+"
__version__ = "v1.0"
__maintainer__ = "<NAME>, <NAME>"
__email__ = "<EMAIL>"


import argparse
import json
import os
import shlex
import sys
import time

# Server code
import flask
from flask import Flask
from flask import abort, redirect, url_for
from flask import request
from flask import render_template
from flask import send_file

from werkzeug.utils import secure_filename

# OSRFramework libraries
import osrframework
import osrframework.domainfy as domainfy
import osrframework.entify as entify
import osrframework.mailfy as mailfy
import osrframework.phonefy as phonefy
import osrframework.searchfy as searchfy
import osrframework.usufy as usufy

import osrframework.utils.configuration as configuration
import osrframework.utils.platform_selection as platform_selection
import osrframework.utils.updates as updates
import osrframework.utils.general as general


# GLOBAL VARIABLES
# -----------------
# Important notice: this configuration makes STRONGLY UNADVISABLE to deploy this
#   server in a different place to localhost for security reasons.
# Creating the SECRET TOKEN
SECRET_TOKEN = ""
# Temporal data. A dictionary of extensions.
loaded_data = {}
# Data folder
configurationPaths = configuration.getConfigPath()
DATA_FOLDER = configurationPaths["appPathData"]
STATIC_FOLDER = os.path.join(configurationPaths["appPathServer"], "static")
TEMPLATES_FOLDER = os.path.join(configurationPaths["appPathServer"], "templates")
# Header filename
HEADER = "profiles"

# Starting the app
app = Flask(
    __name__,
    static_url_path='',
    static_folder=STATIC_FOLDER,
    template_folder=TEMPLATES_FOLDER
 )

@app.route("/")
def index():
    # Getting the status of the current OSRFramework installation
    hasUpdates, version = updates.hasUpdatesOnPypi("osrframework")
    if hasUpdates:
        notice = {
            "icon": "warning",
            "message": "OSRFramework's version is " + version + ", but there is a new release on Pypi (" + version + "). We ecnourage you to <a href='https://github.com/i3visio/osrframework/blob/master/doc/INSTALL.md'>upgrade</a> soon!" ,
            "type": "warning"
        }
    else:
        notice = {
            "icon": "thumbs-up",
            "message": "OSRFramework is updated to the latest version (" + version + ").",
            "type": "success"
        }
    return render_template('home.html', mt_home='class=current', notice=notice)

<commit_msg>Fix issue #231 to avoid exceptions when Pypi is not reachable<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
##################################################################################
#
#    Copyright 2017 <NAME> and <NAME> (i3visio, <EMAIL>)
#
#    This program is part of OSRFramework. You can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##################################################################################

__author__ = "<NAME> y <NAME> "
__copyright__ = "Copyright 2015-2017, i3visio"
__credits__ = ["<NAME>", "<NAME>"]
__license__ = "AGPLv3+"
__version__ = "v1.0"
__maintainer__ = "<NAME>, <NAME>"
__email__ = "<EMAIL>"


import argparse
import json
import os
import shlex
import sys
import time

# Server code
import flask
from flask import Flask
from flask import abort, redirect, url_for
from flask import request
from flask import render_template
from flask import send_file

from werkzeug.utils import secure_filename

# OSRFramework libraries
import osrframework
import osrframework.domainfy as domainfy
import osrframework.entify as entify
import osrframework.mailfy as mailfy
import osrframework.phonefy as phonefy
import osrframework.searchfy as searchfy
import osrframework.usufy as usufy

import osrframework.utils.configuration as configuration
import osrframework.utils.platform_selection as platform_selection
import osrframework.utils.updates as updates
import osrframework.utils.general as general


# GLOBAL VARIABLES
# -----------------
# Important notice: this configuration makes STRONGLY UNADVISABLE to deploy this
#   server in a different place to localhost for security reasons.
# Creating the SECRET TOKEN
SECRET_TOKEN = ""
# Temporal data. A dictionary of extensions.
loaded_data = {}
# Data folder
configurationPaths = configuration.getConfigPath()
DATA_FOLDER = configurationPaths["appPathData"]
STATIC_FOLDER = os.path.join(configurationPaths["appPathServer"], "static")
TEMPLATES_FOLDER = os.path.join(configurationPaths["appPathServer"], "templates")
# Header filename
HEADER = "profiles"

# Starting the app
app = Flask(
    __name__,
    static_url_path='',
    static_folder=STATIC_FOLDER,
    template_folder=TEMPLATES_FOLDER
 )

@app.route("/")
def index():
    # Getting the status of the current OSRFramework installation
    try:
        hasUpdates, version = updates.hasUpdatesOnPypi("osrframework")
        if hasUpdates:
            notice = {
                "icon": "warning",
                "message": "OSRFramework's version is " + version + ", but there is a new release on Pypi (" + version + "). We ecnourage you to <a href='https://github.com/i3visio/osrframework/blob/master/doc/INSTALL.md'>upgrade</a> soon!" ,
                "type": "warning"
            }
        else:
            notice = {
                "icon": "thumbs-up",
                "message": "OSRFramework is updated to the latest version (" + version + ").",
                "type": "success"
            }
    except:
        notice = {
            "icon": "close",
            "message": "OSRFramework Server could not get connected to Pypi to find new versions. Current version is: " + str(osrframework.__version__) + ".",
            "type": "error"
        }
    return render_template('home.html', mt_home='class=current', notice=notice)


{'fraction_non_alphanumeric': 0.1362658057573312, 'fraction_numerical': 0.0057842345977939195, 'mean_word_length': 3.875409836065574, 'pattern_counts': {'":': 15, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, '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': '2537945', 'n_tokens_mistral': 2125, 'n_tokens_neox': 2041, 'n_words': 712}