You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
883 B
24 lines
883 B
2 years ago
|
from django.core import signing
|
||
|
from django.core.management import BaseCommand
|
||
|
|
||
|
from crossposting_backend.settings import SALT, BASE_DIR
|
||
|
|
||
|
|
||
|
class Command(BaseCommand):
|
||
|
def handle(self, *args, **options):
|
||
|
environments = {}
|
||
|
with open(BASE_DIR / '.env') as env_file:
|
||
|
for line in env_file:
|
||
|
env_key, env_value = line.split('=')
|
||
|
environments[env_key] = env_value
|
||
|
|
||
|
signer = signing.Signer(salt=SALT)
|
||
|
with open(BASE_DIR / '.env.encoded', 'w') as out_env_file:
|
||
|
for env_key, env_value in environments.items():
|
||
|
env_item = {
|
||
|
env_key: env_value
|
||
|
}
|
||
|
encoded_env_item = signer.sign_object(env_item)
|
||
|
line_with_encoded_value = '%s=%s\n' % (env_key, encoded_env_item)
|
||
|
out_env_file.write(line_with_encoded_value)
|