<commit_before>"""manati URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import include,url
from django.contrib import admin
from django.contrib.auth import views
from login.forms import LoginForm
from api_manager.core.modules_manager import ModulesManager
import login
from django.core import management
import threading
from manati import settings
import os
from django.db import connection

path_name = 'manati_project'

urlpatterns = [

    url(r'^'+path_name+'/manati_ui/', include('manati_ui.urls')),
    url(r'^'+path_name+'/admin/', include(admin.site.urls)),
    url(r''+path_name+'/', include('login.urls')),
    url(r'^'+path_name+'/index.html$', login.views.home, name="home"),
    url(r'^'+path_name+'/login/$', views.login, {'template_name': 'login.html', 'authentication_form': LoginForm}),
    url(r'^'+path_name+'/logout/$', views.logout, {'next_page':'/manati_project/login'}),
    url(r'^', login.views.home, name="home"),

]
def db_table_exists(table_name):
    return table_name in connection.introspection.table_names()

def __run_background_task_service__():
    path_log_file = os.path.join(settings.BASE_DIR, 'logs')
    logfile_name = os.path.join(path_log_file, "background_tasks.log")
    logfile_task_manager = os.path.join(path_log_file, "creating_task.log")
    thread = threading.Thread(target=management.call_command, args=('process_tasks',
                                                                    "--sleep", "10",
                                                                    "--log-level", "DEBUG",
                                                                    "--log-std", logfile_name))
    # thread.daemon = True  # Daemonize thread
    thread.start()

if db_table_exists('manati_externals_modules') and db_table_exists('background_task') and db_table_exists('django_content_type'):
    ModulesManager.checking_modules()
    ModulesManager.register_modules()
    __run_background_task_service__()




<commit_msg>fixing error with logs file for background process<commit_after>"""manati URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import include,url
from django.contrib import admin
from django.contrib.auth import views
from login.forms import LoginForm
from api_manager.core.modules_manager import ModulesManager
import login
from django.core import management
import threading
from manati import settings
import os
from django.db import connection

path_name = 'manati_project'

urlpatterns = [

    url(r'^'+path_name+'/manati_ui/', include('manati_ui.urls')),
    url(r'^'+path_name+'/admin/', include(admin.site.urls)),
    url(r''+path_name+'/', include('login.urls')),
    url(r'^'+path_name+'/index.html$', login.views.home, name="home"),
    url(r'^'+path_name+'/login/$', views.login, {'template_name': 'login.html', 'authentication_form': LoginForm}),
    url(r'^'+path_name+'/logout/$', views.logout, {'next_page':'/manati_project/login'}),
    url(r'^', login.views.home, name="home"),

]
def db_table_exists(table_name):
    return table_name in connection.introspection.table_names()

def __run_background_task_service__():
    path_log_file = os.path.join(settings.BASE_DIR, 'logs')
    logfile_name = os.path.join(path_log_file, "background_tasks.log")
    if not os.path.isfile(logfile_name):
        os.makedirs(path_log_file)
        f = open(logfile_name, "w")
        print('Creating file: ' + logfile_name)
    logfile_task_manager = os.path.join(path_log_file, "creating_task.log")
    thread = threading.Thread(target=management.call_command, args=('process_tasks',
                                                                    "--sleep", "10",
                                                                    "--log-level", "DEBUG",
                                                                    "--log-std", logfile_name))
    # thread.daemon = True  # Daemonize thread
    thread.start()

if db_table_exists('manati_externals_modules') and db_table_exists('background_task') and db_table_exists('django_content_type'):
    ModulesManager.checking_modules()
    ModulesManager.register_modules()
    __run_background_task_service__()





{'fraction_non_alphanumeric': 0.13006914595402727, 'fraction_numerical': 0.0037376191366099796, 'mean_word_length': 3.3300970873786406, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6292853', 'n_tokens_mistral': 1650, 'n_tokens_neox': 1617, 'n_words': 373}