direnv | unclutter your .profile | Command Line Interface library
kandi X-RAY | direnv Summary
kandi X-RAY | direnv Summary
[Support room on Matrix] direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of direnv
direnv Key Features
direnv Examples and Code Snippets
Community Discussions
Trending Discussions on direnv
QUESTION
Hello SO & Django community,
My problem is related to Django 4, as the feature to use passfile to connect to Postgres has appeared in this version. Though I have went through the similar error message related questions about previous versions, I had no success in solving my problem.
What I am trying to do
I want to connect Postgres database DB_MyProject to a django MyProject. In Django 4, you may use a passfile instead of providing all user/password information in the settings.py. The documentation about this new feature is here. The concept of password file in Postgres is explained here, you may also read about connection service here.
Having followed these docs to my best understanding, I have done the following:
- Created the following DATABASES entry in settings.py of the Django project, as advised here:
ANSWER
Answered 2022-Mar-11 at 09:05- Created the following DATABASES entry in
settings.py
of the Django project:
QUESTION
Working on a heroku django project.
Goal: I want to run the server locally with same code on cloud too (makes sense).
Problem:
Environments differ from a linux server (heroku) to a local PC windows system.
Local environment variables differ from cloud Heroku config vars.
Heroku config vars can be setup easily using the CLI heroku config:set TIMES=2
.
While setting up local env vars is a total mess.
I tried the following in cmd:
py -c "import os;os.environ['Times']=2"
# To set an env var
Then ran py -c "import os;os.environ.get('Times','Not Found')"
stdout: "Not Found".
After a bit of research it appeared to be that such env vars are stored temporarily per process/session usage.
Solution theory: Redirect os.environ
to .env
file of the root heroku project instead of the PC env vars. So I found this tool direnv perfect for Unix-like OSs but not available for Windows.
views.py
code (runs perfect on cloud, sick on the local machine):
ANSWER
Answered 2021-Dec-29 at 17:42You can use environment variables which you can get via os.environ['KEY']
.
The same code will work on both local development and on Heroku.
On Heroku define these variables using ConfigVars heroku config:set KEY=val
while locally (on Windows for example) define the same variables in an .env
file (use dotenv to load them). The .env
file is never committed with the source code.
QUESTION
I'm attempting to run some unit tests on a StructBlock, which is composed of normal block fields and a StreamBlock.
The problem I'm running into is that I can construct a test that renders the block, but I cannot test the StreamBlock validation (i.e., I can't test the block's clean()
)
Stack
- Python 3.9.6
- Django 3.2
- Wagtail 2.13
- pytest 6.2
- pytest-django 4.4
Block Definitions
MyStructBlock
...ANSWER
Answered 2021-Dec-29 at 15:02Every block type has a corresponding 'native' data type for the data it expects to work with - for the simpler blocks, this data type is what you'd expect (e.g. a string for CharBlock, an Image instance for ImageChooserBlock) but for a few of the more complex ones, there's a custom type defined:
- for RichTextBlock, the native type is
wagtail.core.rich_text.RichText
(which behaves similarly to a string, but also has asource
property where e.g. page IDs in page links are kept intact) - for StreamBlock, the native type is
wagtail.core.blocks.StreamValue
(a sequence type, where each item is a StreamValue withblock_type
andvalue
properties).
The render
method will generally be quite forgiving if you use the wrong types (such as a string for RichTextBlock or a list of dicts for StreamBlock), since it's really just invoking your own template code. The clean
method will be more picky, since it's running Python logic specific to each block.
Unfortunately the correct types to use for each block aren't really formally documented, and some of them are quite fiddly to construct (e.g. a StructValue needs to be passed a reference to the corresponding StructBlock) - outside of test code, there isn't much need to create these objects from scratch, because the data will usually be coming from some outside source instead (e.g. a form submission or the database), and each block will be responsible for converting that to its native type.
With that in mind, I'd recommend that you construct your data by piggybacking on the to_python
method, which converts the JSON representation as stored in the database (consisting of just simple Python data types - integers, strings, lists, dicts) into the native data types:
QUESTION
Here is my test code, that gives my error:
...ANSWER
Answered 2021-Jul-05 at 07:16Error between seat & keyboard:
Wrong:QUESTION
Every time I try to install a pip
package with GRPCIO as a dependency inside a .direnv
project I get a build failure due to my architecture being arm64. How can I work around this while waiting for the GRPCIO crew to release an update?
ANSWER
Answered 2021-Mar-15 at 15:14I found a solution that works taking from https://github.com/grpc/grpc/issues/25082 with more detail and the removal of certain unnecessary steps. Note that this only works on python version 3.9 as of this post date.
First, install pyenv
and pyenv-virtualenv
.
QUESTION
I'm trying to write a completion for a command that takes filenames that have no root/base part, only extension (such as "foo/.ext"). Hidden files. (Specifically, ".envrc" for direnv.)
There are several examples to follow in fish's installation that use __fish_complete_suffix for files that have a root and extension, such as fish itself:
...ANSWER
Answered 2021-Jan-30 at 13:52fish doesn't add hidden files to the list of completions unless the token being completed already starts with a '.
'.
You should be able to write a custom completion that does what you want, but unfortunately a long-standing bug makes that impossible.
QUESTION
I have inherited the following code which was written and works against Type-Tiny-1.004004:
...ANSWER
Answered 2020-Nov-21 at 01:09Not sure if I should be adding the coercion to $base or $derived
Neither. You should be returning it.
QUESTION
In my script after I've cd
ed inside a folder I check if direnv
command is available in the system and if a .envrc
file has been already created. If so, I'm generating a python virtual env with:
ANSWER
Answered 2020-Nov-05 at 22:42direnv export bash
is using some bash-only syntax; specifically, ANSI C strings:
QUESTION
In an IHP project, I tried adding wreq
to default.nix
as described in https://ihp.digitallyinduced.com/Guide/recipes.html#making-a-http-request but I get
ANSWER
Answered 2020-Oct-11 at 09:03This is a known issue. To fix the RSA package that causes the build failure, create a file Config/nix/haskell-packages/RSA.nix
and paste in the following content:
QUESTION
I need to implement the waiting task in Airflow. Waiting time is to be around a couple of hours.
First, TimeDeltaSensor is just not working.
...ANSWER
Answered 2020-Jan-16 at 07:55Well, it's not exactly a solution to your problem but rather an alternate (tested) way.
What you can do is just created a bash operator and call sleep
. It will only take a thread I believe as the sleep
command on terminal does.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install direnv
direnv is packaged in most distributions already. See [the installation documentation](docs/installation.md) for details.
[hook direnv into your shell](docs/hook.md).
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page