0
votes

i moved a project on a different server and now i got this error everytime i build the project :

Traceback (most recent call last):
  File "E:\Applications\var\www\Gestion_Mouvements\Gestion_Mouvement\clean_html.py", line 4, in <module>
    directory = settings.CLEAN_DIRECTORY;
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 55, in __getattr__
    self._setup(name)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 43, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 99, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named Gestion_Mouvements.settings

In my wsgi.py :

import os
import sys
project_home = u'E:/Applications/var/www/Gestion_Mouvements'
if project_home not in sys.path:
    sys.path.append(project_home)
os.environ['DJANGO_SETTINGS_MODULE'] = 'Project_Gestion_Mouvement.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Gestion_Mouvements
├── Project_Gestion_Mouvement
│ ├── init.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── Gestion_Mouvement
│ ├── init.py
│ ├── admin.py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
└── manage.py

I tried most of the solutions already proposed on the multiples post about that error but nothing seem to work so far.

i can still perfectly use the app on a webpage and all, but i can't use any script manualy in the project.

Any idea on how to fix this ? Thanks in advance.

clean_html.py :

import os
from django.conf import settings

directory = settings.CLEAN_DIRECTORY;
filepath = settings.CLEAN_DETAILS_FILE_PATH;
filepathNew = settings.CLEAN_DETAILS_NEW_FILE_PATH;
filepath2 = settings.CLEAN_HISTO_FILE_PATH;
filepathNew2 = settings.CLEAN_HISTO_NEW_FILE_PATH;


bad_words = ['<link href="../static', '<script src="../static']
write_flag = False
customline = [] 
customline.append("<link href=\"{% static 'css/Gestion_Mouvements.css' %}\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/mouvementDetails.css' %}\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/css_circuit.css' %}\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/base/jquery-ui.min.css' %}\" media=\"all\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/jquery-ui.min.css' %}\" media=\"all\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/jquery.dataTables.min.css' %}\" media=\"all\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/bootstrap.min.css' rel=\"stylesheet\" %}\" media=\"all\">")
customline.append("<link href=\"{% static 'css//bootstrap-datetimepicker.min.css' %}\" media=\"all\" rel=\"stylesheet\">")
customline.append("<script src=\"{% static 'js/jquery-1.12.4.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/jquery.dataTables.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/jquery-ui.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/bootstrap.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/bootstrap-datetimepicker.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/bootstrap-datetimepicker.fr.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/wwb12.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/js_circuit.js' %}\"></script>")

with open(filepath) as oldfile, open(filepathNew, 'w') as newfile:
    for line in oldfile:
        if not any(bad_word in line for bad_word in bad_words):
            newfile.write(line)
        else:
            if write_flag == False:
                i = 0
                while i != 16:
                    newfile.write(customline[i])
                    newfile.write("\n")
                    i = i + 1
                write_flag = True

print "Fermeture et enregistrement des fichiers ..."
oldfile.close();
newfile.close();

old_file = os.path.join(directory, "mouvementDetails.html")
new_file = os.path.join(directory, "mouvementDetails_old.html")
os.rename(old_file, new_file)
os.remove(new_file)

old_file = os.path.join(directory, "mouvementDetails_new.html")
new_file = os.path.join(directory, "mouvementDetails.html")
os.rename(old_file, new_file)


customline = [] 
customline.append("<link href=\"{% static 'css/Gestion_Mouvements.css' %}\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/PageHistos.css' %}\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/base/jquery-ui.min.css' %}\" media=\"all\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/jquery.dataTables.min.css' %}\" media=\"all\" rel=\"stylesheet\">")
customline.append("<link href=\"{% static 'css/bootstrap.min.css' %}\" rel=\"stylesheet\"  media=\"all\">")
customline.append("<link href=\"{% static 'css//bootstrap-datetimepicker.min.css' %}\" media=\"all\" rel=\"stylesheet\">")
customline.append("<script src=\"{% static 'js/jquery-1.12.4.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/jquery.dataTables.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/jquery-ui.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/bootstrap.min.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/bootstrap-datetimepicker.js' %}\"></script>")
customline.append("<script src=\"{% static 'js/bootstrap-datetimepicker.fr.js' %}\"></script>")
write_flag = False
with open(filepath2) as oldfile, open(filepathNew2, 'w') as newfile:
    for line in oldfile:
        if not any(bad_word in line for bad_word in bad_words):
            newfile.write(line)
        else:
            if write_flag == False:
                i = 0
                while i != 12:
                    newfile.write(customline[i])
                    newfile.write("\n")
                    i = i + 1
                write_flag = True
oldfile.close();
newfile.close();

old_file = os.path.join(directory, "PageHistos.html")
new_file = os.path.join(directory, "PageHistos_old.html")
os.rename(old_file, new_file)
os.remove(new_file)

old_file = os.path.join(directory, "PageHistos_new.html")
new_file = os.path.join(directory, "PageHistos.html")
os.rename(old_file, new_file)
1
Please show clean_html.pySachin

1 Answers

0
votes

You have appended the wrong path in system path as it is now looking for Project_Gestion_Mouvement.settings in /path/to/Project_Gestion_Mouvement. You have to move back one directory.

Solution:

project_home = u'E:/Applications/var/www/Gestion_Mouvements'