say I have a folder structure that looks like this:
.
├── CODEOWNERS
├── Makefile
├── README.rst
├── __pycache__
│ └── conftest.cpython-37-pytest-6.2.2.pyc
├── airflow
│ ├── __pycache__
│ │ └── __init__.cpython-37.pyc
│ ├── dev
│ │ └── dags
│ └── <some_file_I_need>
how do I import the file I need from the airflow local package (not the third party dependency named airflow). I have a dependency called airflow unfortunately and that gets imported when I do: import airflow.dev... and that errors out.
I have the following problem:
I created a Django app (app1) and then installed it in other one (app2). Now I'm trying to make the internationalization of the site, but I want to be able to use the installed app translations and I cannot even compile them.
Some useful information:
APP 1
.
├── MANIFEST.in
├── app1
│ ├── admin.py
│ ├── apps.py
│ ├── forms.py
│ ├── __init__.py
│ ├── locale/
│ │ ├── en-us
│ │ │ └── LC_MESSAGES
│ │ │ └── django.po
│ │ ├── es
│ │ │ └── LC_MESSAGES
│ │ │ └── django.po
│ │ └── pr
│ │ └── LC_MESSAGES
│ │ └── django.po
│ ├── migrations/
│ ├── models.py
│ ├── settings.py
│ ├── static/
│ ├── templates
│ ├── tests.py
│ ├── urls.py
│ ├── utils.py
│ └── views.py
└── setup.py
APP 2 (the one that has APP 1 installed)
├── app2/
│ ├── locale/
│ │ ├── en-us/
│ │ │ └── LC_MESSAGES
│ │ │ ├── django.mo
│ │ │ └── django.po
│ │ ├── es/
│ │ │ └── LC_MESSAGES
│ │ │ ├── django.mo
│ │ │ └── django.po
│ │ └── pr/
│ │ └── LC_MESSAGES
│ │ ├── django.mo
│ │ └── django.po
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app1.apps.App1SiteConfig',
'app2.apps.App2SiteConfig',
]
LANGUAGE_CODE = 'es'
LANGUAGES = (
('en-us', _('English')),
('es', _('Spanish')),
('pt', _('Portuguese'))
)
LOCALE_PATHS = (
os.path.join(BASE_DIR, "app2", "locale"),
)
Basically, the desired TODOs are:
compile the .mo's from App1
use the App1 transalations (it has its own templates and models so ideally they would be used there)
What I don't want:
compile the App1 .mo's from django-admin of App2 and then translate it there.
Thanks in advance!
Well.. finally I managed to solve this by my way..
With the virtualenv activated I moved to App1 dir and executed django-admin compilemessages, the .mo's has been created in the right path (app1/locale/<lang>/LC_MESSAGES/django.mo) and they're able to be used from the site.
I have following project structure,
|
├── database
│ ├── db_adapter.py
│ ├── db_layer
│ │ ├── __init__.py
│ │ └── mysql_adapter.py
│ ├── __init__.py
│ └── scripts
│ └── schema.sql
|
└── workflow
├── dags
│ ├── dss_controller.py
│ ├── __init__.py
|
├── __init__.py
├── plugins
I want to import db_adapter.py module inside dss_controller module, when I tried do it following error shown,
ModuleNotFoundError: No module named 'database'
How can I do the correct importing of the modules?
I'm trying to add pytest to a flask app. This is the project structure.
root
├── myapp
│ ├── app.py
│ ├── config.py
│ ├── module
│ │ ├── models.py
│ ├── pages
│ │ ├── forms.py
│ │ ├── templates
│ │ │ ├── base.html
│ │ │ ├── home.html
│ │ │ └── login.html
│ │ └── views.py
├── Pipfile
├── Pipfile.lock
├── __pycache__
└── tests
├── conftest.py
└── test_pages.py
The flask app is under myapp folder. The command flask run runs ok under this folder. So the app is working fine on its own.
The test folder is at the same level as myapp. If I run pytest or py.test I get this error.
conftest.py:3: in <module>
from app import app
E ModuleNotFoundError: No module named 'app'
conftest.py
from pytest import fixture
from app import app
#fixture
def client():
return app.app
I want a way to pytest to recognize myapp as the root of the project. Even if they are in different folders.
I've Googled around and searched Stack Overflow but I can't find an answer that has helped me unfortunately.
I have a small Node project with the following layout:
├── app
│ ├── config
│ │ ├── env
│ │ │ ├── development.js
│ │ │ └── production.js
│ │ ├── express.js
│ │ └── index.js
│ ├── controllers
│ │ ├── home.js
│ │ ├── index.js
│ │ ├── metric.js
│ │ ├── metricList.js
│ │ └── metrics
│ │ ├── file2.js
│ │ ├── file3
│ │ ├── file4.js
│ │ ├── file5.js
│ │ ├── file6
│ │ ├── index.js
│ │ └── points.js
│ ├── data
│ │ └── premierLeague
│ │ └── 2015-16.json
│ ├── public
│ │ └── main.css
│ │ └── bower_components
│ ├── routes.js
│ ├── server.js
│ └── views
│ ├── home.handlebars
│ ├── layouts
│ │ └── main.handlebars
│ ├── metric.handlebars
│ └── metricList.handlebars
├── bower.json
├── jsonScript.js
├── npm-debug.log
├── package.json
└── server.js
Bootstrap is located in the bower_components folder under public.
In my app/views/layouts/main.handlebars file I require the bootstrap CSS file using the following script tag:
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
In my app/config/express.js file (which does a lot of the work of getting the app going), I have this line:
app.use(express.static('./public'));
Unfortunately I always see this error in the Chrome console when I host up my app:
http://localhost:8080/bower_components/bootstrap/dist/css/bootstrap.min.css Failed to load resource: the server responded with a status of 404 (Not Found)
I'd be really grateful if someone could advise me how to either host my bower_components properly using Express or link to it successfully from my main layout. This is driving me mad, I've tried countless combinations and it never seems to work! Many thanks
Try to get the right path:
app.use(express.static(__dirname + '../public'));
The __dirname get the local directory.
And:
<link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">