File tree 2 files changed +17
-7
lines changed
2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change 24
24
25
25
# PostgreSQL connection
26
26
import psycopg2
27
- conn = psycopg2 .connect (database = "test" ,
28
- user = dotcloud_env ['DOTCLOUD_DB_SQL_LOGIN' ],
29
- password = dotcloud_env ['DOTCLOUD_DB_SQL_PASSWORD' ],
30
- host = dotcloud_env ['DOTCLOUD_DB_SQL_HOST' ],
31
- port = int (dotcloud_env ['DOTCLOUD_DB_SQL_PORT' ]))
32
- cur = conn .cursor ()
27
+
28
+ try :
29
+ conn = psycopg2 .connect (database = "test" ,
30
+ user = dotcloud_env ['DOTCLOUD_DB_SQL_LOGIN' ],
31
+ password = dotcloud_env ['DOTCLOUD_DB_SQL_PASSWORD' ],
32
+ host = dotcloud_env ['DOTCLOUD_DB_SQL_HOST' ],
33
+ port = int (dotcloud_env ['DOTCLOUD_DB_SQL_PORT' ]))
34
+ cur = conn .cursor ()
35
+ except Exception as e :
36
+ print e
37
+ exit (1 )
33
38
34
39
@app .route ("/" )
35
40
def hello ():
Original file line number Diff line number Diff line change 4
4
from os import path
5
5
from time import sleep
6
6
from sys import stdout as out
7
+ import sys
7
8
8
9
dotcloud_env_file_path = path .expanduser ('~/environment.json' )
9
10
if path .exists (dotcloud_env_file_path ):
21
22
22
23
out .write ("Creating the database..." )
23
24
out .flush ()
24
- for i in xrange (1 ,30 ):
25
+ i = 60
26
+ while True :
25
27
try :
26
28
conn = psycopg2 .connect (
27
29
user = env ['DOTCLOUD_DB_SQL_LOGIN' ],
36
38
out .flush ()
37
39
break
38
40
except Exception as e :
41
+ i -= 1
42
+ if i <= 0 :
43
+ sys .exit (1 )
39
44
sleep (1 )
40
45
out .write ("." )
41
46
out .flush ()
You can’t perform that action at this time.
0 commit comments