I am trying to build a project from scratch in python 2, it has structure shown below. In past I have created projects with a single hierarchy, so there would be single virtualenv, but this project has multiple subpackages, what is the best practice to be followed: there should be a single virtualenv inside project_root directory shared by all subpackages in it, or there should be separate virtualenv for each subpackage?
project_root/
├── commons
│ ├── hql_helper.py
│ ├── hql_helper.pyc
│ ├── __init__.py
│ └── sample_HQL.hql
├── fl_wtchr
│ ├── fl_wtchr_test.py
│ ├── fl_wtchr_test.pyc
│ ├── __init__.py
│ ├── meta_table.hql
│ ├── requirements.txt
│ ├── sftp_tmp
│ ├── sql_test.py
│ └── sql_test.pyc
├── qry_exec
│ ├── act_qry_exec_script.py
│ ├── hive_db.logs
│ ├── params.py
│ └── params.pyc
├── sqoop_a
│ ├── __init__.py
│ └── sqoop.py
└── test.py
A case could be made for creating separate virtual environments for each module; but fundamentally, you want and expect all this code to eventually be able to run without a virtualenv at all. All your modules should be able to run with whatever you install into the top-level virtual environment and so that's what you should primarily be testing against.
Related
Consider a multi binary project with the following structure.
.
├── bin1
│ ├── config
│ │ ├── config.go
│ │ └── config_test.go
│ └── utils
│ ├── utils.go
│ └── utils_test.go
├── bin2
│ ├── config
│ │ ├── config.go
│ │ └── config_test.go
│ └── utils
│ ├── utils.go
│ └── utils_test.go
├── cmd
│ ├── bin1
│ │ └── bin1.go
│ ├── bin2
│ │ └── bin2.go
│ └── bin3
│ └── bin3.go
├── go.mod
├── go.sum
└── shared
├── db
│ ├── db.go
│ └── db_test.go
├── model
│ ├── modela.go
│ ├── modela_test.go
│ ├── modelb.go
│ └── modelb_test.go
└── utils
├── utils.go
└── utils_test.go
This project has three binaries bin1, bin2 and bin3. Packages in the /shared directory (e.g. package shareddb, sharedmodel and sharedutils) are shared with binary specific packages (e.g. package bin1config, bin1utils in /bin1 directory and package bin2config, bin2utils in /bin2 directory).
How can we run
all the unit tests in this project altogether?
all the tests in a package (e.g. in shared/model)?
each tests separately?
I attempted the following.
Running go test from the project root resulted in no Go files in /projectroot.
# run all tests
go test ./...
# run all tests under a specific directory (including subdiretories)
go test ./bin2/...
# test package located in specific directory
go test ./shared/model
# test package that has specific import path
go test projectroot/shared/model
# test package in current working directory
go test
# ditto
go test .
# test package in parent directory
go test ..
# run a specific test within the package under test
go test -run=X
# run a specific sub-test within the package under test
go test -run=X/Y
For more details on the go test command, see Test packages.
For more details on the [packages] argument to go test, see Packge lists and patters.
For more details on the testing flags, see Testing flags.
I had the project on Django 3.1 with the following layout:
.
├── app
│ ├── app
│ │ ├── asgi.py
│ │ ├── __init__.py
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── core
│ │ ├── admin.py
│ │ ├── apps.py
│ │ ├── fixtures
│ │ │ ├── Client.json
│ │ │ └── DataFeed.json
│ │ ├── __init__.py
│ │ ├── migrations
│ │ │ ├── 0001_initial.py
│ │ │ ├── 0002_auto_20201009_0950.py
│ │ │ └── __init__.py
│ │ ├── models.py
│ │ └── tests
│ │ └── __init__.py
│ └── manage.py
I want to add 2 scripts to this project:
download_xml.py - to check and download .xml files from external sources by schedule (every ~30 min)
update_db_info.py - to be invoked by download_xml.py and transfer data from downloaded xml to the database
What is the best django practice for organizing a placement for this kind of scripts?
My ideas:
just create scripts folder inside of an app/core and put scripts there. Invoke them using cron
run python manage.py startapp db_update
so the new app in django will be created. I will remove migrations, views, models etc from it and put scripts there. use cron again
Create app/core/management/commands folder and put scripts there. Call them by cron using python manage.py download_xml && python manage.py download_xml update_db_info
Option 3 (mostly)
However if download_xml.py doesn't use or rely on Django, I would put it in a scripts directory outside of the Django project (but still in source control). You might decide not to do this if the script does need to be deployed with your app. It doesn't need to be a management command though.
update_db_info.py definitely sounds like it would be best suited as a management command.
I am trying to configure apache2 so that it communicates with django and I am unable to the 'sites-available' directory where I believe a 'defaults' directory should reside.
The following is my file structure under the 'etc/apache2/' directory:
├── extra
│ ├── httpd-autoindex.conf
│ ├── httpd-dav.conf
│ ├── httpd-default.conf
│ ├── httpd-info.conf
│ ├── httpd-languages.conf
│ ├── httpd-manual.conf
│ ├── httpd-mpm.conf
│ ├── httpd-multilang-errordoc.conf
│ ├── httpd-ssl.conf
│ ├── httpd-userdir.conf
│ ├── httpd-vhosts.conf
│ └── proxy-html.conf
├── httpd.conf
├── httpd.conf.bak
├── httpd.conf.pre-update
├── magic
├── mime.types
├── original
│ ├── extra
│ │ ├── httpd-autoindex.conf
│ │ ├── httpd-dav.conf
│ │ ├── httpd-default.conf
│ │ ├── httpd-info.conf
│ │ ├── httpd-languages.conf
│ │ ├── httpd-manual.conf
│ │ ├── httpd-mpm.conf
│ │ ├── httpd-multilang-errordoc.conf
│ │ ├── httpd-ssl.conf
│ │ ├── httpd-userdir.conf
│ │ ├── httpd-vhosts.conf
│ │ └── proxy-html.conf
│ └── httpd.conf
├── other
│ └── php5.conf
└── users
├── Guest.conf
├── aphexlog.conf
└── secops.conf
If anyone knows if there is a possibility of a alternative config file with the same properties or some other solution... maybe I am just being dumb but everything that I have found online indicates that I should have this properties file.
Any and all help is appreciated :)
sites-available is a concept from Debian-derived distributions of Linux. MacOS does not have it, and neither do most other Linux flavours.
Instead you need to put your configuration directly in httpd.conf.
(Note, it's unusual to run a production system on a Mac; if you're just doing this for development, you can use the built-in runserver rather than messing around with Apache.)
Is there any guide how to start with HTMLBars? I am following "building HTMLBars" section but finally I am stuck. I have run building tool and now I have files in my dist directory like this:
.
├── htmlbars-compiler.amd.js
├── htmlbars-runtime.amd.js
├── morph.amd.js
├── test
│ ├── htmlbars-compiler-tests.amd.js
│ ├── htmlbars-runtime-tests.amd.js
│ ├── index.html
│ ├── loader.js
│ ├── morph-tests.amd.js
│ ├── packages-config.js
│ ├── qunit.css
│ └── qunit.js
└── vendor
├── handlebars.amd.js
└── simple-html-tokenizer.amd.js
Which should I add to my ember project and is that all or have I to do something more? Is this library ready or it is still unusable for ember?
Not even close to ready yet, I'd love to give more info, but there really isn't any. Last I heard they wanted it as a beta in 1.9, but we'll see.
I have a Django project in Buildout which I'd like to set up with my nginx server over Phusion Passenger.
The documentation for doing this doesn't seem to exist.
There seems to be a need for creating a passenger_wsgi.py file for setting up the WSGI environment, however I'm not sure how that will work.
Since Buildout does its own internal hacks with the Python path, how can I create and supply this file, and where in my project should I put it?
My project looks like this:
.
├── bin
│ ├── buildout
│ ├── django
│ ├── django.wsgi
│ ├── gunicorn
│ ├── ipython
│ ├── multiple-part-upload.py
│ ├── nosetests
│ ├── python
│ └── test
├── conf
│ ├── deploy
│ ├── shared
│ └── vagrant
├── src
│ ├── myproject
│ └── myproject.egg-info
├── bootstrap.py
├── bower.json
├── buildout.cfg
├── README.mkd
├── setup.py
└── Vagrantfile
Where should I put passenger_wsgi.py so that a) Passenger will find it and b) my Buildout eggs will be included in the path?