@@ -665,16 +665,16 @@ cryptographically valid for the server:
665
665
[source,python]
666
666
----
667
667
def _get_server_env_vars(host):
668
- env_lines = run(f' cat ~/sites/{host}/.env' ).splitlines() #<1>
669
- return dict(l.split('=' ) for l in env_lines if l)
668
+ env_lines = run(f" cat ~/sites/{host}/.env" ).splitlines() # <1>
669
+ return dict(l.split("=" ) for l in env_lines if l)
670
670
671
671
672
672
def create_session_on_server(host, email):
673
673
manage_dot_py = _get_manage_dot_py(host)
674
- with settings(host_string=f' elspeth@{host}' ):
674
+ with settings(host_string=f" elspeth@{host}" ):
675
675
env_vars = _get_server_env_vars(host)
676
- with shell_env(**env_vars): #<2>
677
- session_key = run(f' {manage_dot_py} create_session {email}' ) #<3>
676
+ with shell_env(**env_vars): # <2>
677
+ session_key = run(f" {manage_dot_py} create_session {email}" ) # <3>
678
678
return session_key.strip()
679
679
----
680
680
====
@@ -735,6 +735,7 @@ In any case, let's see if it works. First, locally, to check that we didn't
735
735
break anything:
736
736
737
737
738
+ [role="dofirst-ch21l022"]
738
739
[subs="specialcharacters,macros"]
739
740
----
740
741
$ pass:quotes[*python src/manage.py test functional_tests.test_my_lists*]
@@ -833,8 +834,8 @@ Before we finish, let's update our deployment fabfile so that it can
833
834
automatically add the `EMAIL_PASSWORD` to the _.env_ file on the server:
834
835
835
836
836
- [role="sourcecode dofirst-ch21l022 "]
837
- .deploy_tools/fabfile.py (ch18l021)
837
+ [role="sourcecode skipme "]
838
+ .src/ deploy_tools/fabfile.py (ch18l021)
838
839
====
839
840
[source,python]
840
841
----
@@ -843,16 +844,16 @@ import os
843
844
844
845
845
846
def _create_or_update_dotenv():
846
- append(' .env', ' DJANGO_DEBUG_FALSE=y' )
847
- append(' .env' , f' SITENAME={env.host}' )
848
- current_contents = run(' cat .env' )
849
- if ' DJANGO_SECRET_KEY' not in current_contents:
850
- new_secret = '' .join(random.SystemRandom().choices (
851
- ' abcdefghijklmnopqrstuvwxyz0123456789' , k=50
852
- ))
853
- append(' .env' , f' DJANGO_SECRET_KEY={new_secret}' )
854
- email_password = os.environ[' EMAIL_PASSWORD' ] #<1>
855
- append(' .env' , f' EMAIL_PASSWORD={email_password}' ) #<1>
847
+ append(" .env", " DJANGO_DEBUG_FALSE=y" )
848
+ append(" .env" , f" SITENAME={env.host}" )
849
+ current_contents = run(" cat .env" )
850
+ if " DJANGO_SECRET_KEY" not in current_contents:
851
+ new_secret = "" .join(
852
+ random.SystemRandom().choices(" abcdefghijklmnopqrstuvwxyz0123456789" , k=50)
853
+ )
854
+ append(" .env" , f" DJANGO_SECRET_KEY={new_secret}" )
855
+ email_password = os.environ[" EMAIL_PASSWORD" ] # <1>
856
+ append(" .env" , f" EMAIL_PASSWORD={email_password}" ) # <1>
856
857
----
857
858
====
858
859
0 commit comments